From 60c9391af86dbc220b59a0e8eba902e42e7dee9c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 15 Oct 2016 10:07:17 -0300 Subject: [PATCH] test --- iguana/dpow/dpow_fsm.c | 18 ++++++++++++++++-- iguana/dpow/dpow_network.c | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 1a93a9286..2337484d3 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -160,20 +160,34 @@ void dpow_datahandler(struct supernet_info *myinfo,uint32_t channel,uint32_t hei int32_t dpow_update(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t utxochannel,uint32_t sigchannel,uint32_t txidchannel,bits256 srchash,int32_t myind) { - struct dpow_entry *ep; int32_t len; bits256 hash; uint8_t data[sizeof(struct dpow_entry)+2]; + struct dpow_entry *ep; int32_t i,k,len,sendutxo = 1; bits256 hash; uint8_t data[sizeof(struct dpow_entry)+2]; ep = &bp->notaries[myind]; if ( (bp->bestk= dpow_bestk(bp,&bp->bestmask)) >= 0 ) { + sendutxo = 0; + for (i=0; inumnotaries; i++) + { + k = ((bp->height % bp->numnotaries) + i) % bp->numnotaries; + if ( ((1LL << k) & bp->bestmask) != 0 && (bp->notaries[k].recvmask & (1LL << myind)) == 0 ) + { + printf("other notary.%d doesnt have our.%d utxo yet\n",k,myind); + sendutxo = 1; + break; + } + } if ( ep->masks[bp->bestk] == 0 ) dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel); else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel); } - if ( bp->state != 0xffffffff ) + if ( sendutxo != 0 ) { hash = srchash; hash.uints[0] = rand(); if ( (len= dpow_rwutxobuf(1,data,&bp->hashmsg,&bp->notaries[myind])) > 0 ) dpow_send(myinfo,bp,hash,bp->hashmsg,utxochannel,bp->height,data,len,bp->utxocrcs); + } + if ( bp->state != 0xffffffff ) + { if ( ep->masks[bp->bestk] == 0 ) dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel); else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 322e3cece..9b3ad974d 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -58,7 +58,7 @@ void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr) int32_t dpow_crc32find(struct supernet_info *myinfo,uint32_t crc32,uint32_t channel) { int32_t i,firstz = -1; - return(0); + //return(0); //if ( channel != DPOW_UTXOBTCCHANNEL && channel != DPOW_UTXOCHANNEL ) { for (i=0; iDPOW.crcs)/sizeof(*myinfo->DPOW.crcs); i++) @@ -81,9 +81,9 @@ 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,channel)) >= 0 ) + //if ( (firstz= dpow_crc32find(myinfo,crc32,channel)) >= 0 ) { - myinfo->DPOW.crcs[firstz] = crc32; + //myinfo->DPOW.crcs[firstz] = crc32; size = (int32_t)(sizeof(*np) + datalen); np = calloc(1,size); //printf("dpow_send.(%d) size.%d\n",datalen,size);