Browse Source

test

etomic
jl777 8 years ago
parent
commit
5d79ce607e
  1. 32
      iguana/kmd_lookup.h

32
iguana/kmd_lookup.h

@ -198,7 +198,7 @@ void kmd_flushfiles(struct iguana_info *coin)
FILE *kmd_txidinit(struct iguana_info *coin) FILE *kmd_txidinit(struct iguana_info *coin)
{ {
int32_t i; FILE *fp; char fname[1024],str[65]; struct kmd_transactionhh *ptr,*tmp; struct kmd_transaction T,*tx; struct kmd_voutinfo V,*vptr; long lastpos=0; int32_t i; FILE *fp; char fname[1024],str[65]; struct kmd_transactionhh *ptr; struct kmd_transaction T,*tx; struct kmd_voutinfo V; long lastpos=0;
sprintf(fname,"%s/TRANSACTIONS/%s",GLOBAL_DBDIR,coin->symbol); sprintf(fname,"%s/TRANSACTIONS/%s",GLOBAL_DBDIR,coin->symbol);
if ( (fp= fopen(fname,"rb+")) != 0 ) if ( (fp= fopen(fname,"rb+")) != 0 )
{ {
@ -231,23 +231,8 @@ FILE *kmd_txidinit(struct iguana_info *coin)
} }
} else break; } else break;
} }
printf("finished txidinit fpos %ld vs lastpos %ld\n",ftell(fp),lastpos);
fseek(fp,lastpos,SEEK_SET); fseek(fp,lastpos,SEEK_SET);
HASH_ITER(hh,coin->kmd_transactions,ptr,tmp)
{
//printf("scan for spends ht.%d\n",ptr->tx->height);
for (i=0; i<ptr->numvouts; i++)
{
vptr = &ptr->tx->vouts[i];
if ( vptr->spendvini >= 0 && bits256_nonz(vptr->spendtxid) != 0 )
{
if ( (ptr->ptrs[(i<<1) + 1]= kmd_transaction(coin,vptr->spendtxid)) == 0 )
{
printf("cant find %s spend.%d\n",bits256_str(str,vptr->spendtxid),i);
}
//else printf("set spent.%p ht.%d vout.%d\n",ptr->ptrs[(i<<1)+1],ptr->tx->height,i);
}
}
}
} else fp = fopen(fname,"wb+"); } else fp = fopen(fname,"wb+");
return(fp); return(fp);
} }
@ -268,11 +253,18 @@ FILE *kmd_spendinit(struct iguana_info *coin)
fread(&spentvout,1,sizeof(spentvout),fp) == sizeof(spentvout) ) fread(&spentvout,1,sizeof(spentvout),fp) == sizeof(spentvout) )
{ {
if ( kmd_transactionvin(coin,txid,i,spenttxid,spentvout) < 0 ) if ( kmd_transactionvin(coin,txid,i,spenttxid,spentvout) < 0 )
{
printf("error adding spend %s %d of %d\n",bits256_str(str,txid),i,numvins); printf("error adding spend %s %d of %d\n",bits256_str(str,txid),i,numvins);
} break;
}
} else break;
} }
} if ( i == numvins )
lastpos = ftell(fp);
else break;
} else break;
} }
printf("finished spendinit fpos %ld vs lastpos %ld\n",ftell(fp),lastpos);
fseek(fp,lastpos,SEEK_SET); fseek(fp,lastpos,SEEK_SET);
HASH_ITER(hh,coin->kmd_transactions,ptr,tmp) HASH_ITER(hh,coin->kmd_transactions,ptr,tmp)
{ {
@ -556,7 +548,7 @@ int32_t _kmd_bitcoinscan(struct iguana_info *coin)
{ {
flag = 0; flag = 0;
if ( (loadheight % 1000) == 0 ) if ( (loadheight % 1000) == 0 )
printf("loading ht.%d\n",loadheight); printf("loading ht.%d %s\n",loadheight,jprint(kmd_getbalance(coin,"*"),1));
if ( (blockjson= kmd_blockjson(&h,coin->symbol,coin->chain->serverport,coin->chain->userpass,0,loadheight)) != 0 ) if ( (blockjson= kmd_blockjson(&h,coin->symbol,coin->chain->serverport,coin->chain->userpass,0,loadheight)) != 0 )
{ {
if ( (txids= jarray(&numtxids,blockjson,"tx")) != 0 ) if ( (txids= jarray(&numtxids,blockjson,"tx")) != 0 )

Loading…
Cancel
Save