jl777 8 years ago
parent
commit
bdd1434c39
  1. 3
      iguana/dpow/dpow_fsm.c
  2. 21
      iguana/dpow/dpow_network.c

3
iguana/dpow/dpow_fsm.c

@ -230,7 +230,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
}
}
if ( (rand() % 10) == 0 )
printf("%s ht.%d FSM.%d %s BTC.%d masks.%llx best.(%d %llx) match.(%d sigs.%d) sigsmask.%llx\n",coin->symbol,bp->height,bp->state,coinaddr,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,match,sigmatch,(long long)sigsmask);
printf("[%d] %s ht.%d FSM.%d %s BTC.%d masks.%llx best.(%d %llx) match.(%d sigs.%d) sigsmask.%llx\n",myind,coin->symbol,bp->height,bp->state,coinaddr,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,match,sigmatch,(long long)sigsmask);
if ( sigmatch == DPOW_M(bp) )
{
printf("sigmatch.%d\n",sigmatch);
@ -243,6 +243,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
{
bp->notaries[myind].prev_hash = txid;
bp->notaries[myind].prev_vout = vout;
bp->recvmask |= (1LL << myind);
bp->state = 1;
}
if ( haveutxo < 10 && time(NULL) > dp->lastsplit+600 )

21
iguana/dpow/dpow_network.c

@ -55,18 +55,21 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
}
}
int32_t dpow_crc32find(struct supernet_info *myinfo,uint32_t crc32)
int32_t dpow_crc32find(struct supernet_info *myinfo,uint32_t crc32,uint32_t channel)
{
int32_t i,firstz = -1;
for (i=0; i<sizeof(myinfo->DPOW.crcs)/sizeof(*myinfo->DPOW.crcs); i++)
//if ( channel != DPOW_UTXOBTCCHANNEL && channel != DPOW_UTXOCHANNEL )
{
if ( myinfo->DPOW.crcs[i] == crc32 )
for (i=0; i<sizeof(myinfo->DPOW.crcs)/sizeof(*myinfo->DPOW.crcs); i++)
{
//printf("NANODUPLICATE.%08x\n",crc32);
return(-1);
if ( myinfo->DPOW.crcs[i] == crc32 )
{
//printf("NANODUPLICATE.%08x\n",crc32);
return(-1);
}
else if ( myinfo->DPOW.crcs[i] == 0 )
firstz = i;
}
else if ( myinfo->DPOW.crcs[i] == 0 )
firstz = i;
}
if ( firstz < 0 )
firstz = (rand() % (sizeof(myinfo->DPOW.crcs)/sizeof(*myinfo->DPOW.crcs)));
@ -77,7 +80,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 srchas
{
struct dpow_nanomsghdr *np; int32_t size,firstz,sentbytes = 0; uint32_t crc32;
crc32 = calc_crc32(0,data,datalen);
if ( (firstz= dpow_crc32find(myinfo,crc32)) >= 0 )
if ( (firstz= dpow_crc32find(myinfo,crc32,channel)) >= 0 )
{
myinfo->DPOW.crcs[firstz] = crc32;
size = (int32_t)(sizeof(*np) + datalen);
@ -107,7 +110,7 @@ void dpow_nanomsg_update(struct supernet_info *myinfo)
if ( np->datalen == (size - sizeof(*np)) )
{
crc32 = calc_crc32(0,np->packet,np->datalen);
if ( crc32 == np->crc32 && (firstz= dpow_crc32find(myinfo,crc32)) >= 0 )
if ( crc32 == np->crc32 && (firstz= dpow_crc32find(myinfo,crc32,np->channel)) >= 0 )
{
myinfo->DPOW.crcs[firstz] = crc32;
printf("NANORECV ht.%d channel.%08x (%d) crc32.%08x:%08x datalen.%d:%d\n",np->height,np->channel,size,np->crc32,crc32,np->datalen,(int32_t)(size - sizeof(*np)));

Loading…
Cancel
Save