Browse Source

Test

etomic
jl777 8 years ago
parent
commit
252351a8ae
  1. 15
      iguana/exchanges/LP_cache.c

15
iguana/exchanges/LP_cache.c

@ -110,14 +110,15 @@ void LP_SPV_store(struct iguana_info *coin,char *coinaddr,bits256 txid,int32_t h
} }
} }
int32_t LP_cacheitem(struct iguana_info *coin,struct LP_transaction *tx,long remains) long LP_cacheitem(struct iguana_info *coin,void *ptr,long fpos,long remains)
{ {
int32_t offset,n; uint8_t *serialized; bits256 hash; cJSON *txobj; char str[65],str2[65]; struct LP_transaction *tx; long offset; int32_t n; uint8_t *serialized; bits256 hash; cJSON *txobj; char str[65],str2[65];
offset = sizeof(*tx) + tx->numvouts*sizeof(*tx->outpoints); tx = ptr;
offset = fpos + sizeof(*tx) + tx->numvouts*sizeof(*tx->outpoints);
if ( offset+tx->len <= remains ) if ( offset+tx->len <= remains )
{ {
printf("offset.%d txlen.%d remains.%ld\n",offset,tx->len,remains); printf("offset.%ld txlen.%d remains.%ld\n",offset,tx->len,remains);
serialized = &((uint8_t *)tx)[offset]; serialized = &((uint8_t *)ptr)[offset];
hash = bits256_doublesha256(0,serialized,tx->len); hash = bits256_doublesha256(0,serialized,tx->len);
if ( bits256_cmp(hash,tx->txid) == 0 ) if ( bits256_cmp(hash,tx->txid) == 0 )
{ {
@ -150,13 +151,13 @@ void LP_cacheptrs_init(struct iguana_info *coin)
ptr = OS_portable_mapfile(fname,&fsize,0); ptr = OS_portable_mapfile(fname,&fsize,0);
while ( len < fsize ) while ( len < fsize )
{ {
if ( (n= LP_cacheitem(coin,(struct LP_transaction *)&ptr[len],fsize - len)) < 0 ) if ( (n= LP_cacheitem(coin,ptr,len,fsize - len)) < 0 )
{ {
printf("cacheitem error at %s offset.%ld when fsize.%ld\n",coin->symbol,len,fsize); printf("cacheitem error at %s offset.%ld when fsize.%ld\n",coin->symbol,len,fsize);
tflag = 1; tflag = 1;
break; break;
} }
len += n; len = n;
if ( (len & 7) != 0 ) if ( (len & 7) != 0 )
printf("odd offset at %ld\n",len); printf("odd offset at %ld\n",len);
} }

Loading…
Cancel
Save