|
|
@ -81,7 +81,7 @@ void dpow_utxosync(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow |
|
|
|
r = (rand() % bp->numnotaries); |
|
|
|
for (j=0; j<DPOW_M(bp); j++) |
|
|
|
{ |
|
|
|
i = DPOW_MODIND(bp,j+r);//((bp->height % bp->numnotaries) + j + r) % bp->numnotaries;
|
|
|
|
i = DPOW_MODIND(bp,j+r); |
|
|
|
if ( ((1LL << i) & bp->recvmask) != 0 && ((1LL << i) & recvmask) == 0 ) |
|
|
|
break; |
|
|
|
} |
|
|
@ -110,7 +110,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,uint3 |
|
|
|
bits256 txid,commit,srchash; struct dpow_block *bp = 0; uint32_t flag = 0; int32_t src_or_dest,senderind,i,myind = -1; char str[65],str2[65]; struct dpow_sigentry dsig; struct dpow_entry *ep; struct dpow_coinentry *cp; struct dpow_utxoentry U; struct iguana_info *coin; |
|
|
|
if ( (bp= dpow_heightfind(myinfo,dp,height)) == 0 ) |
|
|
|
{ |
|
|
|
if ( (rand() % 100) == 0 ) |
|
|
|
if ( (rand() % 100) == 0 && height > 0 ) |
|
|
|
printf("couldnt find height.%d | if you just started notary dapp this is normal\n",height); |
|
|
|
return(-1); |
|
|
|
} |
|
|
@ -148,7 +148,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,uint3 |
|
|
|
dpow_sync(myinfo,dp,bp,ep->recvmask,myind,srchash,channel,src_or_dest); |
|
|
|
flag = 1; |
|
|
|
} |
|
|
|
//if ( 0 && flag == 0 && bp != 0 )
|
|
|
|
if ( 0 && flag == 0 && bp != 0 ) |
|
|
|
printf("ep.%p sender.%d UTXO.%d hashmsg.(%s) txid.(%s) v%d %llx\n",ep,senderind,height,bits256_str(str,U.hashmsg),bits256_str(str2,src_or_dest!=0?U.desthash:U.srchash),src_or_dest!=0?U.destvout:U.srcvout,(long long)bp->recvmask); |
|
|
|
} |
|
|
|
else if ( channel == DPOW_SIGCHANNEL || channel == DPOW_SIGBTCCHANNEL ) |
|
|
@ -218,42 +218,33 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,uint3 |
|
|
|
//printf("bp.%p datalen.%d\n",bp,datalen);
|
|
|
|
for (i=0; i<32; i++) |
|
|
|
srchash.bytes[i] = data[i]; |
|
|
|
/*if ( srchash.ulongs[0] == 0 )
|
|
|
|
{ |
|
|
|
init_hexbytes_noT(bp->rawtx,&data[32],datalen-32); |
|
|
|
//printf("got bestk.%d %llx rawtx.(%s) set utxo\n",srchash.bytes[31],(long long)srchash.ulongs[1],bp->rawtx);
|
|
|
|
dpow_rawtxsign(myinfo,bp->coin,bp,bp->rawtx,0,srchash.bytes[31],srchash.ulongs[1],myind,bits256_nonz(bp->desttxid) == 0 ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL); |
|
|
|
} |
|
|
|
else*/ |
|
|
|
txid = bits256_doublesha256(0,&data[32],datalen-32); |
|
|
|
init_hexbytes_noT(bp->signedtx,&data[32],datalen-32); |
|
|
|
printf("signedtx.(%s)\n",bp->signedtx); |
|
|
|
if ( bits256_cmp(txid,srchash) == 0 ) |
|
|
|
{ |
|
|
|
txid = bits256_doublesha256(0,&data[32],datalen-32); |
|
|
|
init_hexbytes_noT(bp->signedtx,&data[32],datalen-32); |
|
|
|
printf("signedtx.(%s)\n",bp->signedtx); |
|
|
|
if ( bits256_cmp(txid,srchash) == 0 ) |
|
|
|
printf("verify (%s) it is properly signed! set ht.%d signedtxid to %s\n",coin->symbol,height,bits256_str(str,txid)); |
|
|
|
if ( src_or_dest != 0 ) |
|
|
|
{ |
|
|
|
printf("verify (%s) it is properly signed! set ht.%d signedtxid to %s\n",coin->symbol,height,bits256_str(str,txid)); |
|
|
|
if ( src_or_dest != 0 ) |
|
|
|
{ |
|
|
|
bp->desttxid = txid; |
|
|
|
bp->state = 1000; |
|
|
|
dp->destupdated = 0; |
|
|
|
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGCHANNEL,0); |
|
|
|
//dpow_sigscheck(myinfo,dp,bp,DPOW_SIGCHANNEL,myind,0);
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
bp->srctxid = txid; |
|
|
|
printf("set state COMPLETED\n"); |
|
|
|
bp->state = 0xffffffff; |
|
|
|
} |
|
|
|
bp->desttxid = txid; |
|
|
|
bp->state = 1000; |
|
|
|
dp->destupdated = 0; |
|
|
|
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGCHANNEL,0); |
|
|
|
//dpow_sigscheck(myinfo,dp,bp,DPOW_SIGCHANNEL,myind,0);
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
init_hexbytes_noT(bp->signedtx,data,datalen); |
|
|
|
printf("txidchannel txid %s mismatch %s (%s)\n",bits256_str(str,txid),bits256_str(str2,srchash),bp->signedtx); |
|
|
|
bp->signedtx[0] = 0; |
|
|
|
bp->srctxid = txid; |
|
|
|
printf("set state COMPLETED\n"); |
|
|
|
bp->state = 0xffffffff; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
init_hexbytes_noT(bp->signedtx,data,datalen); |
|
|
|
printf("txidchannel txid %s mismatch %s (%s)\n",bits256_str(str,txid),bits256_str(str2,srchash),bp->signedtx); |
|
|
|
bp->signedtx[0] = 0; |
|
|
|
} |
|
|
|
} else printf("unhandled channel.%x\n",channel); |
|
|
|
return(0); |
|
|
|
} |
|
|
@ -270,7 +261,7 @@ int32_t dpow_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo |
|
|
|
sendutxo = 0; |
|
|
|
for (i=0; i<bp->numnotaries; i++) |
|
|
|
{ |
|
|
|
k = DPOW_MODIND(bp,i);//((bp->height % bp->numnotaries) + i) % bp->numnotaries;
|
|
|
|
k = DPOW_MODIND(bp,i); |
|
|
|
if ( k == myind ) |
|
|
|
continue; |
|
|
|
if ( ((1LL << k) & bp->recvmask) != 0 && (bp->notaries[k].recvmask & (1LL << myind)) == 0 ) |
|
|
@ -291,19 +282,25 @@ int32_t dpow_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo |
|
|
|
if ( (len= dpow_rwutxobuf(1,data,&U,bp)) > 0 ) |
|
|
|
dpow_send(myinfo,dp,bp,srchash,bp->hashmsg,DPOW_UTXOCHANNEL,bp->height,data,len,bp->utxocrcs); |
|
|
|
} |
|
|
|
if ( ep->masks[src_or_dest][bp->bestk] == 0 ) |
|
|
|
if ( bp->bestk >= 0 && ep->masks[src_or_dest][bp->bestk] == 0 ) |
|
|
|
dpow_signedtxgen(myinfo,dp,(src_or_dest != 0) ? bp->destcoin : bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGBTCCHANNEL,src_or_dest); |
|
|
|
//else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
|
|
|
|
} |
|
|
|
else if ( bp->state != 0xffffffff ) |
|
|
|
{ |
|
|
|
src_or_dest = 0; |
|
|
|
if ( ep->masks[src_or_dest][bp->bestk] == 0 ) |
|
|
|
if ( bp->bestk >= 0 && ep->masks[src_or_dest][bp->bestk] == 0 ) |
|
|
|
dpow_signedtxgen(myinfo,dp,(src_or_dest != 0) ? bp->destcoin : bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGCHANNEL,src_or_dest); |
|
|
|
//else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
|
|
|
|
} |
|
|
|
if ( (rand() % 10) == 0 ) |
|
|
|
printf("[%d] %s ht.%d FSM.%08x masks.%llx best.(%d %llx) sigsmask.%llx %llx src.%llx\n",myind,src_or_dest != 0 ? bp->destcoin->symbol : bp->srccoin->symbol,bp->height,bp->state,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,(long long)bp->destsigsmasks[bp->bestk],(long long)(bp->destsigsmasks[bp->bestk] & bp->bestmask),(long long)bp->srcsigsmasks[bp->bestk]); |
|
|
|
if ( (rand() % 10) == 0 || bp->isratify != 0 ) |
|
|
|
{ |
|
|
|
uint64_t sigsmask,srcmask; |
|
|
|
if ( bp->bestk < 0 ) |
|
|
|
sigsmask = srcmask = 0; |
|
|
|
else sigsmask = bp->destsigsmasks[bp->bestk], srcmask = bp->srcsigsmasks[bp->bestk]; |
|
|
|
printf("[%d] %s isratify.%d ht.%d FSM.%08x masks.%llx best.(%d %llx) sigsmask.%llx %llx src.%llx\n",myind,src_or_dest != 0 ? bp->destcoin->symbol : bp->srccoin->symbol,bp->isratify,bp->height,bp->state,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,(long long)sigsmask,(long long)(sigsmask & bp->bestmask),(long long)srcmask); |
|
|
|
} |
|
|
|
if ( bp->state < 1000 && bp->bestk >= 0 && (bp->destsigsmasks[bp->bestk] & bp->bestmask) == bp->bestmask ) |
|
|
|
{ |
|
|
|
dpow_sigscheck(myinfo,dp,bp,DPOW_SIGBTCCHANNEL,myind,1); |
|
|
@ -318,7 +315,7 @@ int32_t dpow_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo |
|
|
|
uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int32_t myind,int32_t src_or_dest) |
|
|
|
{ |
|
|
|
int32_t j,incr; char *opret_symbol,coinaddr[64]; uint32_t channel,sigchannel,txidchannel; bits256 srchash,zero; |
|
|
|
if ( bp->numnotaries > 8 ) |
|
|
|
if ( 0 && bp->numnotaries > 8 ) |
|
|
|
incr = sqrt(bp->numnotaries) + 1; |
|
|
|
else incr = 1; |
|
|
|
memset(zero.bytes,0,sizeof(zero)); |
|
|
@ -336,7 +333,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info |
|
|
|
opret_symbol = dp->symbol; |
|
|
|
} |
|
|
|
bitcoin_address(coinaddr,coin->chain->pubtype,dp->minerkey33,33); |
|
|
|
if ( bits256_nonz(bp->hashmsg) == 0 && bp->height != 0 ) |
|
|
|
if ( bits256_nonz(bp->hashmsg) == 0 && bp->height >= DPOW_FIRSTRATIFY ) |
|
|
|
return(0); |
|
|
|
for (j=0; j<sizeof(srchash); j++) |
|
|
|
srchash.bytes[j] = dp->minerkey33[j+1]; |
|
|
@ -383,22 +380,30 @@ void dpow_statemachinestart(void *ptr) |
|
|
|
{ |
|
|
|
void **ptrs = ptr; |
|
|
|
struct supernet_info *myinfo; struct dpow_info *dp; struct dpow_checkpoint checkpoint; |
|
|
|
int32_t i,n,numratified,myind = -1; cJSON *ratified,*item; struct iguana_info *src,*dest; char *jsonstr,*handle,*hexstr,str[65],str2[65],srcaddr[64],destaddr[64]; bits256 zero,srchash; struct dpow_block *bp; struct dpow_entry *ep = 0; uint32_t duration,minsigs,starttime; |
|
|
|
int32_t i,destprevvout0,srcprevvout0,numratified=0,kmdheight,myind = -1; uint8_t pubkeys[64][33]; cJSON *ratified=0,*item; struct iguana_info *src,*dest; char *jsonstr,*handle,*hexstr,str[65],str2[65],srcaddr[64],destaddr[64]; bits256 zero,srchash,destprevtxid0,srcprevtxid0; struct dpow_block *bp; struct dpow_entry *ep = 0; uint32_t duration,minsigs,starttime; |
|
|
|
memset(&zero,0,sizeof(zero)); |
|
|
|
srcprevtxid0 = destprevtxid0 = zero; |
|
|
|
srcprevvout0 = destprevvout0 = -1; |
|
|
|
myinfo = ptrs[0]; |
|
|
|
dp = ptrs[1]; |
|
|
|
minsigs = (uint32_t)(long)ptrs[2]; |
|
|
|
duration = (uint32_t)(long)ptrs[3]; |
|
|
|
jsonstr = ptrs[4]; |
|
|
|
kmdheight = -1; |
|
|
|
memcpy(&checkpoint,&ptrs[5],sizeof(checkpoint)); |
|
|
|
printf("statemachinestart %s->%s %s ht.%d minsigs.%d duration.%d\n",dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration); |
|
|
|
printf("statemachinestart %s->%s %s ht.%d minsigs.%d duration.%d start.%u\n",dp->symbol,dp->dest,bits256_str(str,checkpoint.blockhash.hash),checkpoint.blockhash.height,minsigs,duration,checkpoint.timestamp); |
|
|
|
src = iguana_coinfind(dp->symbol); |
|
|
|
dest = iguana_coinfind(dp->dest); |
|
|
|
if ( strcmp(src->symbol,"KMD") == 0 ) |
|
|
|
kmdheight = checkpoint.blockhash.height; |
|
|
|
else if ( strcmp(dest->symbol,"KMD") == 0 ) |
|
|
|
kmdheight = dest->longestchain; |
|
|
|
if ( (bp= dp->blocks[checkpoint.blockhash.height]) == 0 ) |
|
|
|
{ |
|
|
|
bp = calloc(1,sizeof(*bp)); |
|
|
|
bp->minsigs = minsigs; //DPOW_MINSIGS;
|
|
|
|
bp->duration = duration; //DPOW_DURATION;
|
|
|
|
bp->minsigs = minsigs; |
|
|
|
if ( (bp->duration= duration) == DPOW_RATIFYDURATION ) |
|
|
|
bp->isratify = 1; |
|
|
|
bp->srccoin = src; |
|
|
|
bp->destcoin = dest; |
|
|
|
bp->opret_symbol = dp->symbol; |
|
|
@ -414,6 +419,13 @@ void dpow_statemachinestart(void *ptr) |
|
|
|
{ |
|
|
|
decode_hex(bp->ratified_pubkeys[i],33,hexstr); |
|
|
|
safecopy(bp->handles[i],handle,sizeof(bp->handles[i])); |
|
|
|
if ( i == 0 ) |
|
|
|
{ |
|
|
|
destprevtxid0 = jbits256(item,"destprevtxid0"); |
|
|
|
destprevvout0 = jint(item,"destprevvout0"); |
|
|
|
srcprevtxid0 = jbits256(item,"srcprevtxid0"); |
|
|
|
srcprevvout0 = jint(item,"srcprevvout0"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -438,44 +450,69 @@ void dpow_statemachinestart(void *ptr) |
|
|
|
dp->blocks[checkpoint.blockhash.height] = bp; |
|
|
|
bp->beacon = rand256(0); |
|
|
|
vcalc_sha256(0,bp->commit.bytes,bp->beacon.bytes,sizeof(bp->beacon)); |
|
|
|
if ( dp->blocks[checkpoint.blockhash.height - 1000] != 0 ) |
|
|
|
if ( checkpoint.blockhash.height >= DPOW_FIRSTRATIFY && dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] != 0 ) |
|
|
|
{ |
|
|
|
printf("purge %s.%d\n",dp->dest,checkpoint.blockhash.height - 1000); |
|
|
|
free(dp->blocks[checkpoint.blockhash.height - 1000]); |
|
|
|
dp->blocks[checkpoint.blockhash.height - 1000] = 0; |
|
|
|
printf("purge %s.%d\n",dp->dest,checkpoint.blockhash.height - DPOW_FIRSTRATIFY); |
|
|
|
free(dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY]); |
|
|
|
dp->blocks[checkpoint.blockhash.height - DPOW_FIRSTRATIFY] = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
n = (int32_t)(sizeof(Notaries)/sizeof(*Notaries)); |
|
|
|
bp->numnotaries = n; |
|
|
|
for (i=0; i<n; i++) |
|
|
|
bitcoin_address(srcaddr,src->chain->pubtype,dp->minerkey33,33); |
|
|
|
bitcoin_address(destaddr,dest->chain->pubtype,dp->minerkey33,33); |
|
|
|
if ( kmdheight >= 0 ) |
|
|
|
{ |
|
|
|
decode_hex(bp->notaries[i].pubkey,33,Notaries[i][1]); |
|
|
|
if ( memcmp(bp->notaries[i].pubkey,dp->minerkey33,33) == 0 ) |
|
|
|
bp->numnotaries = komodo_notaries(pubkeys,kmdheight); |
|
|
|
for (i=0; i<bp->numnotaries; i++) |
|
|
|
{ |
|
|
|
//for (j=0; j<33; j++)
|
|
|
|
// printf("%02x",pubkeys[i][j]);
|
|
|
|
//printf(" <= pubkey[%d]\n",i);
|
|
|
|
memcpy(bp->notaries[i].pubkey,pubkeys[i],33); |
|
|
|
if ( memcmp(bp->notaries[i].pubkey,dp->minerkey33,33) == 0 ) |
|
|
|
{ |
|
|
|
myind = i; |
|
|
|
ep = &bp->notaries[myind]; |
|
|
|
} |
|
|
|
} |
|
|
|
if ( myind < 0 || ep == 0 ) |
|
|
|
{ |
|
|
|
myind = i; |
|
|
|
ep = &bp->notaries[myind]; |
|
|
|
printf("minerkey33-> "); |
|
|
|
for (i=0; i<33; i++) |
|
|
|
printf("%02x",dp->minerkey33[i]); |
|
|
|
printf(" statemachinestart this node %s %s is not official notary numnotaries.%d\n",srcaddr,destaddr,bp->numnotaries); |
|
|
|
free(ptr); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if ( myind < 0 || ep == 0 ) |
|
|
|
else |
|
|
|
{ |
|
|
|
printf("statemachinestart this node %s %s is not official notary\n",srcaddr,destaddr); |
|
|
|
printf("statemachinestart no kmdheight.%d\n",kmdheight); |
|
|
|
free(ptr); |
|
|
|
return; |
|
|
|
} |
|
|
|
bitcoin_address(srcaddr,src->chain->pubtype,dp->minerkey33,33); |
|
|
|
bitcoin_address(destaddr,dest->chain->pubtype,dp->minerkey33,33); |
|
|
|
printf(" myaddr.(%s %s)\n",srcaddr,destaddr); |
|
|
|
if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr) < 0 ) |
|
|
|
printf(" myind.%d myaddr.(%s %s)\n",myind,srcaddr,destaddr); |
|
|
|
if ( myind == 0 && bits256_nonz(destprevtxid0) != 0 && bits256_nonz(srcprevtxid0) != 0 && destprevvout0 >= 0 && srcprevvout0 >= 0 ) |
|
|
|
{ |
|
|
|
printf("dont have %s %s utxo, please send funds\n",dp->dest,destaddr); |
|
|
|
free(ptr); |
|
|
|
return; |
|
|
|
ep->dest.prev_hash = destprevtxid0; |
|
|
|
ep->dest.prev_vout = destprevvout0; |
|
|
|
ep->src.prev_hash = srcprevtxid0; |
|
|
|
ep->src.prev_vout = srcprevvout0; |
|
|
|
printf("Use override utxo %s/v%d %s/v%d\n",bits256_str(str,destprevtxid0),destprevvout0,bits256_str(str2,srcprevtxid0),srcprevvout0); |
|
|
|
} |
|
|
|
if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr) < 0 ) |
|
|
|
else |
|
|
|
{ |
|
|
|
printf("dont have %s %s utxo, please send funds\n",dp->symbol,srcaddr); |
|
|
|
free(ptr); |
|
|
|
return; |
|
|
|
if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr) < 0 ) |
|
|
|
{ |
|
|
|
printf("dont have %s %s utxo, please send funds\n",dp->dest,destaddr); |
|
|
|
free(ptr); |
|
|
|
return; |
|
|
|
} |
|
|
|
if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr) < 0 ) |
|
|
|
{ |
|
|
|
printf("dont have %s %s utxo, please send funds\n",dp->symbol,srcaddr); |
|
|
|
free(ptr); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
bp->recvmask |= (1LL << myind); |
|
|
|
bp->notaries[myind].othermask |= (1LL << myind); |
|
|
@ -483,34 +520,45 @@ void dpow_statemachinestart(void *ptr) |
|
|
|
bp->height = checkpoint.blockhash.height; |
|
|
|
bp->timestamp = checkpoint.timestamp; |
|
|
|
bp->hashmsg = checkpoint.blockhash.hash; |
|
|
|
while ( dp->destupdated == 0 ) |
|
|
|
while ( bp->isratify == 0 && dp->destupdated == 0 ) |
|
|
|
{ |
|
|
|
if ( checkpoint.blockhash.height != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) |
|
|
|
if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) |
|
|
|
{ |
|
|
|
printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height); |
|
|
|
return; |
|
|
|
} |
|
|
|
sleep(1); |
|
|
|
} |
|
|
|
starttime = (uint32_t)time(NULL); |
|
|
|
printf("DPOW statemachine checkpoint.%d %s\n",checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash)); |
|
|
|
if ( (starttime= checkpoint.timestamp) == 0 ) |
|
|
|
starttime = (uint32_t)time(NULL); |
|
|
|
printf("isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u\n",bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),checkpoint.timestamp); |
|
|
|
for (i=0; i<sizeof(srchash); i++) |
|
|
|
srchash.bytes[i] = dp->minerkey33[i+1]; |
|
|
|
dpow_utxosync(myinfo,dp,bp,0,myind,srchash); |
|
|
|
while ( time(NULL) < starttime+bp->duration && src != 0 && dest != 0 && bp->state != 0xffffffff ) |
|
|
|
{ |
|
|
|
sleep(2); |
|
|
|
if ( checkpoint.blockhash.height != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) |
|
|
|
if ( dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) |
|
|
|
{ |
|
|
|
printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height); |
|
|
|
break; |
|
|
|
if ( bp->isratify == 0 ) |
|
|
|
{ |
|
|
|
printf("abort ht.%d due to new checkpoint.%d\n",checkpoint.blockhash.height,dp->checkpoint.blockhash.height); |
|
|
|
break; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
bp->bestk = -1; |
|
|
|
bp->bestmask = 0; |
|
|
|
bp->height = ((dp->checkpoint.blockhash.height / 10) % (DPOW_FIRSTRATIFY/10)) * 10; |
|
|
|
printf("new rotation ht.%d\n",bp->height); |
|
|
|
} |
|
|
|
} |
|
|
|
if ( bp->state != 0xffffffff ) |
|
|
|
{ |
|
|
|
//printf("dp->ht.%d ht.%d DEST.%08x %s\n",dp->checkpoint.blockhash.height,checkpoint.blockhash.height,deststate,bits256_str(str,srchash.hash));
|
|
|
|
bp->state = dpow_statemachineiterate(myinfo,dp,dest,bp,myind,1); |
|
|
|
} |
|
|
|
if ( dp->cancelratify != 0 && checkpoint.blockhash.height == 0 ) |
|
|
|
if ( dp->cancelratify != 0 && bp->isratify != 0 ) |
|
|
|
{ |
|
|
|
printf("abort pending ratify\n"); |
|
|
|
break; |
|
|
@ -520,3 +568,4 @@ void dpow_statemachinestart(void *ptr) |
|
|
|
dp->lastrecvmask = bp->recvmask; |
|
|
|
free(ptr); |
|
|
|
} |
|
|
|
|
|
|
|