jl777 8 years ago
parent
commit
f31b733381
  1. 17
      iguana/dpow/dpow_rpc.c
  2. 2
      iguana/iguana_notary.c
  3. 1
      includes/iguana_structs.h

17
iguana/dpow/dpow_rpc.c

@ -55,11 +55,11 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t kmdheight)
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *retstr; bits256 blockhash;
if ( 0 && strcmp(coin->symbol,"USD") == 0 )
printf("dpow_getbestblockhash %s FULLNODE.%d\n",coin->symbol,coin->FULLNODE);
memset(blockhash.bytes,0,sizeof(blockhash));
if ( coin->FULLNODE < 0 )
{
if ( coin->lastbesthashtime+20 < time(NULL) && bits256_nonz(coin->lastbesthash) != 0 )
return(coin->lastbesthash);
if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getbestblockhash","")) != 0 )
{
if ( 0 && strcmp(coin->symbol,"USD") == 0 )
@ -76,6 +76,11 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c
else
{
}
if ( bits256_nonz(blockhash) != 0 )
{
coin->lastbesthash = blockhash;
coin->lastbesthashtime = (uint32_t)time(NULL);
}
return(blockhash);
}
@ -265,15 +270,17 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin)
{
int32_t n,i,height = -1,maxtx = *numtxp; bits256 besthash; cJSON *array,*json;
int32_t n,i,height = -1,maxtx = *numtxp; bits256 besthash,oldhash; cJSON *array,*json;
*numtxp = *blocktimep = 0;
oldhash = coin->lastbesthash;
*blockhashp = besthash = dpow_getbestblockhash(myinfo,coin);
if ( bits256_nonz(besthash) != 0 )
if ( bits256_nonz(besthash) != 0 && bits256_cmp(oldhash,besthash) != 0 )
{
if ( (json= dpow_getblock(myinfo,coin,besthash)) != 0 )
{
if ( (height= juint(json,"height")) != 0 && (*blocktimep= juint(json,"time")) != 0 )
{
coin->lastbestheight = height;
if ( height > coin->longestchain )
coin->longestchain = height;
if ( (array= jarray(&n,json,"tx")) != 0 )
@ -288,7 +295,7 @@ int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32
free_json(json);
}
}
return(height);
return(coin->lastbestheight);
}
int32_t dpow_vini_ismine(struct supernet_info *myinfo,struct dpow_info *dp,cJSON *item)

2
iguana/iguana_notary.c

@ -143,7 +143,7 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
//printf("dp.%p dPoWupdate (%s -> %s)\n",dp,dp!=0?dp->symbol:"",dp!=0?dp->dest:"");
if ( src != 0 && dest != 0 )
{
if ( strcmp(dp->dest,"BTC") != 0 )
if ( strcmp(dp->dest,"KMD") == 0 )
dp->KMDHEIGHT = dpow_issuer_iteration(dp,src,dp->KMDHEIGHT,&dp->KMDREALTIME);
dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx);
if ( (height= dpow_getchaintip(myinfo,&blockhash,&blocktime,dp->desttx,&dp->numdesttx,dest)) != dp->destchaintip.blockhash.height && height >= 0 )

1
includes/iguana_structs.h

@ -509,6 +509,7 @@ struct iguana_info
FILE *utxofp;
bits256 markedunspents[1024];
char seedipaddr[64];
uint32_t lastbesthashtime; bits256 lastbesthash; int32_t lastbestheight;
struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536];
struct iguana_RTtxid *RTdataset; struct iguana_RTaddr *RTaddrs;
};

Loading…
Cancel
Save