Browse Source

Test

etomic
jl777 7 years ago
parent
commit
2cd41e6a43
  1. 26
      iguana/exchanges/LP_cache.c

26
iguana/exchanges/LP_cache.c

@ -106,26 +106,32 @@ int32_t LP_cacheitem(struct iguana_info *coin,struct LP_transaction *tx,long rem
long LP_cacheptrs_init(FILE **wfp,struct iguana_info *coin) long LP_cacheptrs_init(FILE **wfp,struct iguana_info *coin)
{ {
char fname[1024]; FILE *fp; long n,fsize=0,len = 0; uint8_t *ptr = 0; char fname[1024]; FILE *fp; int32_t flag = 0; long n,fsize=0,len = 0; uint8_t *ptr = 0;
sprintf(fname,"%s/UNSPENTS/%s.SPV",GLOBAL_DBDIR,coin->symbol), OS_portable_path(fname); sprintf(fname,"%s/UNSPENTS/%s.SPV",GLOBAL_DBDIR,coin->symbol), OS_portable_path(fname);
fp = fopen(fname,"rb"); fp = fopen(fname,"rb");
if ( ((*wfp)= OS_appendfile(fname)) != 0 ) if ( ((*wfp)= OS_appendfile(fname)) != 0 )
{ {
if ( fp != 0 ) if ( fp != 0 )
{ {
fseek(fp,0,SEEK_END);
if ( ftell(fp) > sizeof(struct LP_transaction) )
flag = 1;
fclose(fp); fclose(fp);
ptr = OS_portable_mapfile(fname,&fsize,0); if ( flag != 0 )
while ( len < fsize )
{ {
if ( (n= LP_cacheitem(coin,(struct LP_transaction *)&ptr[len],fsize - len)) < 0 ) ptr = OS_portable_mapfile(fname,&fsize,0);
while ( len < fsize )
{ {
printf("cacheitem error at %s offset.%ld when fsize.%ld\n",coin->symbol,len,fsize); if ( (n= LP_cacheitem(coin,(struct LP_transaction *)&ptr[len],fsize - len)) < 0 )
fseek(*wfp,len,SEEK_SET); {
break; printf("cacheitem error at %s offset.%ld when fsize.%ld\n",coin->symbol,len,fsize);
fseek(*wfp,len,SEEK_SET);
break;
}
len += n;
if ( (len & 1) != 0 )
printf("odd offset at %ld\n",len);
} }
len += n;
if ( (len & 1) != 0 )
printf("odd offset at %ld\n",len);
} }
} }
} }

Loading…
Cancel
Save