jl777 8 years ago
parent
commit
573b71bc3d
  1. 23
      iguana/iguana_notary.c

23
iguana/iguana_notary.c

@ -829,10 +829,11 @@ void dpow_txidupdate(struct supernet_info *myinfo,struct dpow_info *dp,struct ig
uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,uint32_t state,bits256 hashmsg,int32_t heightmsg,bits256 btctxid,struct dpow_entry notaries[DPOW_MAXRELAYS],int32_t numnotaries,int32_t myind,uint64_t *recvmaskp,bits256 *signedtxidp,char *signedtx,uint32_t timestamp,bits256 beacon)
{
// todo: add RBF support
bits256 txid,signedtxid,commit; int32_t vout,completed,i,len,nonz,j,k,m,incr,haveutxo = 0; cJSON *addresses; char *sendtx,*rawtx,*retstr,coinaddr[64]; uint8_t data[4096]; uint32_t channel; bits256 srchash,desthash; uint64_t mask;
bits256 txid,signedtxid,commit; int32_t vout,responded,completed,i,len,nonz,j,k,m,incr,haveutxo = 0; cJSON *addresses,*retarray; char *sendtx,*rawtx,*retstr,coinaddr[64]; uint8_t data[4096]; uint32_t channel; bits256 srchash,desthash,zero; uint64_t mask;
if ( numnotaries > 8 )
incr = sqrt(numnotaries) + 1;
else incr = 1;
memset(zero.bytes,0,sizeof(zero));
vcalc_sha256(0,commit.bytes,beacon.bytes,sizeof(beacon));
channel = 'd' | ('P' << 8) | ('o' << 16) | ('W' << 24);
if ( bits256_nonz(btctxid) == 0 )
@ -869,14 +870,20 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
if ( (haveutxo= dpow_haveutxo(myinfo,coin,&txid,&vout,coinaddr)) != 0 && vout >= 0 && vout < 0x100 )
{
len = dpow_rwutxobuf(1,data,&hashmsg,&txid,&vout,&commit,myinfo->DPOW.minerkey33);
for (i=0; i<numnotaries; i++)
responded = 0;
while ( responded <= numnotaries/2 )
{
//if ( i == myind )
// continue;
for (j=0; j<sizeof(srchash); j++)
desthash.bytes[j] = notaries[i].pubkey[j+1];
char str[65],str2[65]; printf("STATE1: %s send %s %s/v%d\n",coin->symbol,bits256_str(str,hashmsg),bits256_str(str2,txid),vout);
basilisk_channelsend(myinfo,srchash,desthash,channel,heightmsg,data,len,120);
for (i=(myind % incr); i<numnotaries; i+=incr)
{
for (j=0; j<sizeof(srchash); j++)
desthash.bytes[j] = notaries[i].pubkey[j+1];
basilisk_channelsend(myinfo,srchash,desthash,channel,heightmsg,data,len,120);
}
if ( (retarray= basilisk_channelget(myinfo,srchash,zero,channel,heightmsg,0)) != 0 )
{
responded = cJSON_GetArraySize(retarray);
free_json(retarray);
}
}
state = 2;
}

Loading…
Cancel
Save