From 195489a6f96aa1be0cfcd5342462c5c82c23deec Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 19:20:41 +0300 Subject: [PATCH 1/7] +print --- iguana/dpow/dpow_network.c | 17 ++++++++++------- iguana/m_notary_run | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index e9972454e..120709958 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1944,7 +1944,7 @@ void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct d void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen) { - struct dpow_nanomsghdr *np; int32_t i,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; + struct dpow_nanomsghdr *np; int32_t i,maxiters,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; if ( bp->myind < 0 ) return; if ( time(NULL) < myinfo->nanoinit+5 ) @@ -1995,18 +1995,21 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo memcpy(np->packet,data,datalen); sentbytes = -1; // deadlocks! portable_mutex_lock(&myinfo->dpowmutex); - for (i=0; i<100; i++) + maxiters = 100; + for (i=0; idpowsock; pfd.events = NN_POLLOUT; - if ( nn_poll(&pfd,1,100) > 0 ) + if ( nn_poll(&pfd,1,1) > 0 ) { sentbytes = signed_nn_send(myinfo,myinfo->ctx,myinfo->persistent_priv,myinfo->dpowsock,np,size); break; } usleep(1000); } + if ( i == maxiters ) + printf("maxiters expired for signed_nn_send\n"); //portable_mutex_unlock(&myinfo->dpowmutex); free(np); if ( 0 && bp->myind <= 2 ) @@ -2123,7 +2126,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) } else flags |= 1; if ( freeptr != 0 ) nn_freemsg(freeptr), np = 0, freeptr = 0; - if ( 0 && myinfo->dexsock >= 0 ) // from servers + /*if ( 0 && myinfo->dexsock >= 0 ) // from servers { freeptr = 0; if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 ) @@ -2140,8 +2143,8 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) } else flags |= 2; if ( freeptr != 0 ) nn_freemsg(freeptr), dexp = 0, freeptr = 0; - } - if ( 0 && myinfo->repsock >= 0 ) // from clients + }*/ + /*if ( 0 && myinfo->repsock >= 0 ) // from clients { dexp = 0; if ( (flags & 4) == 0 && (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 ) @@ -2184,7 +2187,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) } else flags |= 4; if ( dexp != 0 ) nn_freemsg(dexp), dexp = 0; - } + }*/ if ( (num + n + num2) != lastval ) { //printf("lastval.%d: num.%d n.%d num2.%d rep packets\n",lastval,num,n,num2); diff --git a/iguana/m_notary_run b/iguana/m_notary_run index 8f0a152c3..92ffa8979 100755 --- a/iguana/m_notary_run +++ b/iguana/m_notary_run @@ -19,6 +19,8 @@ sleep 3 curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"78.47.196.146\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"82.202.193.98\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"54.95.68.31\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"142.54.164.114\"}" + #tests/addnotarys_7776 coins/btc_7776 #coins/ltc_7776 From bac0df42501f52ca0e40306d9bd46c73917cac2f Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 19:23:53 +0300 Subject: [PATCH 2/7] +print --- iguana/dpow/dpow_network.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 120709958..f6980d21a 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1946,9 +1946,15 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo { struct dpow_nanomsghdr *np; int32_t i,maxiters,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; if ( bp->myind < 0 ) + { + printf("bp->myind.%d error\n",bp->myind); return; + } if ( time(NULL) < myinfo->nanoinit+5 ) + { + printf("dpow_send waiting for init\n"); return; + } crc32 = calc_crc32(0,data,datalen); //dp->crcs[firstz] = crc32; size = (int32_t)(sizeof(*np) + datalen); @@ -2009,7 +2015,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo usleep(1000); } if ( i == maxiters ) - printf("maxiters expired for signed_nn_send\n"); + printf("maxiters expired for signed_nn_send dpowsock.%d\n",myinfo->dpowsock); //portable_mutex_unlock(&myinfo->dpowmutex); free(np); if ( 0 && bp->myind <= 2 ) From 4911b69396fa9d215f849605b9e50673a46c5069 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 1 May 2018 20:59:24 +0300 Subject: [PATCH 3/7] Test --- iguana/dpow/dpow_network.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index f6980d21a..68a9a9677 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -82,9 +82,9 @@ int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,in if ( memcmp(pubkey33,signpubkey33,33) == 0 ) { sentbytes = nn_send(sock,sigpacket,size + sizeof(*sigpacket),0); - //for (i=0; i Date: Tue, 1 May 2018 21:27:00 +0300 Subject: [PATCH 4/7] -print --- iguana/dpow/dpow_network.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 68a9a9677..dfa7a592b 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -82,9 +82,9 @@ int32_t signed_nn_send(struct supernet_info *myinfo,void *ctx,bits256 privkey,in if ( memcmp(pubkey33,signpubkey33,33) == 0 ) { sentbytes = nn_send(sock,sigpacket,size + sizeof(*sigpacket),0); - for (i=0; i Date: Wed, 2 May 2018 00:48:09 +0300 Subject: [PATCH 5/7] Only set bests if valid --- iguana/dpow/dpow_network.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index dfa7a592b..61122da51 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1824,8 +1824,9 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru { //fprintf(stderr,"{%d %x} ",senderind,paxwdcrc); } - if ( (bp->notaries[senderind].bestk= bestk) >= 0 ) + if ( bestk >= 0 ) { + bp->notaries[senderind].bestk = bestk; if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) { memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]); From d9116fced86d9815340284cb1683a010f3cf295d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 2 May 2018 01:19:54 +0300 Subject: [PATCH 6/7] Latched best --- iguana/dpow/dpow_network.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 61122da51..475ba0081 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1830,14 +1830,14 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) { memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]); - if ( bestk == bp->bestk && bestmask == bp->bestmask ) + if ( bestk == bp->notaries[bp->myind].bestk && bestmask == bp->bestmask ) bp->srcsigsmasks[bestk] |= (1LL << senderind); else bp->srcsigsmasks[bestk] &= ~(1LL << senderind); } if ( (bp->notaries[senderind].dest.siglens[bestk]= siglens[1]) != 0 ) { memcpy(bp->notaries[senderind].dest.sigs[bestk],sigs[1],siglens[1]); - if ( bestk == bp->bestk && bestmask == bp->bestmask ) + if ( bestk == bp->notaries[bp->myind].bestk && bestmask == bp->bestmask ) bp->destsigsmasks[bestk] |= (1LL << senderind); else bp->destsigsmasks[bestk] &= ~(1LL << senderind); } @@ -1862,7 +1862,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru { if ( bp->paxwdcrc == bp->notaries[i].paxwdcrc ) paxmatches++; - if ( bp->bestk >= 0 && bp->notaries[i].bestk == bp->bestk && bp->notaries[i].bestmask == bp->bestmask ) + if ( bp->notaries[bp->myind].bestk >= 0 && bp->notaries[i].bestk == bp->notaries[bp->myind].bestk && bp->notaries[i].bestmask == bp->bestmask ) { matches++; if ( ((1LL << i) & bp->bestmask) != 0 ) @@ -1890,22 +1890,22 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru printf("recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d\n",(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches); if ( bestmatches >= bp->minsigs && paxbestmatches >= bp->minsigs ) { - if ( bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask ) + if ( bp->pendingbestk != bp->notaries[bp->myind].bestk || bp->pendingbestmask != bp->bestmask ) { printf("new PENDING BESTK (%d %llx) state.%d\n",bp->bestk,(long long)bp->bestmask,bp->state); - bp->pendingbestk = bp->bestk; + bp->pendingbestk = bp->notaries[bp->myind].bestk; bp->pendingbestmask = bp->bestmask; - dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0); + dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->notaries[bp->myind].bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0); //printf("finished signing\n"); } - if ( bp->destsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs + if ( bp->destsigsmasks[bp->notaries[bp->myind].bestk] == bp->bestmask ) // have all sigs { if ( bp->state < 1000 ) - dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->bestk,bp->bestmask,0,0); - if ( bp->srcsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs + dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->notaries[bp->myind].bestk,bp->bestmask,0,0); + if ( bp->srcsigsmasks[bp->notaries[bp->myind].bestk] == bp->bestmask ) // have all sigs { if ( bp->state != 0xffffffff ) - dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->bestk,bp->bestmask,0,0); + dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->notaries[bp->myind].bestk,bp->bestmask,0,0); } //else printf("srcmask.%llx != bestmask.%llx\n",(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->bestmask); } //else printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask); } From 1418109c809f35c6af5cb2241e4b24d4f825e674 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 2 May 2018 01:49:15 +0300 Subject: [PATCH 7/7] Go back to simpler change --- iguana/dpow/dpow_network.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 475ba0081..61122da51 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1830,14 +1830,14 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) { memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]); - if ( bestk == bp->notaries[bp->myind].bestk && bestmask == bp->bestmask ) + if ( bestk == bp->bestk && bestmask == bp->bestmask ) bp->srcsigsmasks[bestk] |= (1LL << senderind); else bp->srcsigsmasks[bestk] &= ~(1LL << senderind); } if ( (bp->notaries[senderind].dest.siglens[bestk]= siglens[1]) != 0 ) { memcpy(bp->notaries[senderind].dest.sigs[bestk],sigs[1],siglens[1]); - if ( bestk == bp->notaries[bp->myind].bestk && bestmask == bp->bestmask ) + if ( bestk == bp->bestk && bestmask == bp->bestmask ) bp->destsigsmasks[bestk] |= (1LL << senderind); else bp->destsigsmasks[bestk] &= ~(1LL << senderind); } @@ -1862,7 +1862,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru { if ( bp->paxwdcrc == bp->notaries[i].paxwdcrc ) paxmatches++; - if ( bp->notaries[bp->myind].bestk >= 0 && bp->notaries[i].bestk == bp->notaries[bp->myind].bestk && bp->notaries[i].bestmask == bp->bestmask ) + if ( bp->bestk >= 0 && bp->notaries[i].bestk == bp->bestk && bp->notaries[i].bestmask == bp->bestmask ) { matches++; if ( ((1LL << i) & bp->bestmask) != 0 ) @@ -1890,22 +1890,22 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru printf("recv.%llx best.(%d %llx) m.%d p.%d:%d b.%d\n",(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask,matches,paxmatches,paxbestmatches,bestmatches); if ( bestmatches >= bp->minsigs && paxbestmatches >= bp->minsigs ) { - if ( bp->pendingbestk != bp->notaries[bp->myind].bestk || bp->pendingbestmask != bp->bestmask ) + if ( bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask ) { printf("new PENDING BESTK (%d %llx) state.%d\n",bp->bestk,(long long)bp->bestmask,bp->state); - bp->pendingbestk = bp->notaries[bp->myind].bestk; + bp->pendingbestk = bp->bestk; bp->pendingbestmask = bp->bestmask; - dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->notaries[bp->myind].bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0); + dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0); //printf("finished signing\n"); } - if ( bp->destsigsmasks[bp->notaries[bp->myind].bestk] == bp->bestmask ) // have all sigs + if ( bp->destsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs { if ( bp->state < 1000 ) - dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->notaries[bp->myind].bestk,bp->bestmask,0,0); - if ( bp->srcsigsmasks[bp->notaries[bp->myind].bestk] == bp->bestmask ) // have all sigs + dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->bestk,bp->bestmask,0,0); + if ( bp->srcsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs { if ( bp->state != 0xffffffff ) - dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->notaries[bp->myind].bestk,bp->bestmask,0,0); + dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->bestk,bp->bestmask,0,0); } //else printf("srcmask.%llx != bestmask.%llx\n",(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->bestmask); } //else printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask); }