From 15ad55a04a6dc00c845cc542014b830e777951b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 17:32:41 -0300 Subject: [PATCH 01/11] test --- iguana/iguana_recv.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 881cb67f8..67a2573e0 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -919,10 +919,29 @@ int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,str return(-1); } } - req = iguana_bundlereq(coin,addr,'H',0,0); - req->blocks = zblocks, req->n = n; - HDRnet++; - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + i = 0; + if ( n >= 2*coin->chain->bundlesize+1 ) + { + while ( n-i*coin->chain->bundlesize >= 2*coin->chain->bundlesize+1 ) + { + req = iguana_bundlereq(coin,addr,'H',0,0); + req->blocks = mycalloc('r',coin->chain->bundlesize,sizeof(*zblocks)); + memcpy(req->blocks,&zblocks[i++ * coin->chain->bundlesize],coin->chain->bundlesize * sizeof(*zblocks)); + req->n = coin->chain->bundlesize; + HDRnet++; + queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + } + } + else + { + req = iguana_bundlereq(coin,addr,'H',0,0); + req->blocks = zblocks, req->n = n; + HDRnet++; + queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + zblocks = 0; + } + if ( zblocks != 0 ) + myfree(zblocks,sizeof(*zblocks)*n); return(0); } From 38d6f44017d65e55f75976760a4f347e3a682f06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 17:40:13 -0300 Subject: [PATCH 02/11] test --- iguana/iguana_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 67a2573e0..b1d19bb2f 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1022,7 +1022,7 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin //n = 0; //if ( bp->hdrsi < coin->MAXBUNDLES || (coin->current != 0 && coin->lastpending != 0 && bp->hdrsi >= coin->current->hdrsi && bp->hdrsi <= coin->lastpending->hdrsi) ) // n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); - if ( 0 && n > 2 ) + //if ( 1 && n > 2 ) printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n); //if ( bp->queued == 0 ) // iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500)); From 68ce0386e5d8a24aec8074d68d1cadfec28b25ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 17:44:07 -0300 Subject: [PATCH 03/11] test --- iguana/iguana_recv.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index b1d19bb2f..0b60eb7fe 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1022,7 +1022,7 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin //n = 0; //if ( bp->hdrsi < coin->MAXBUNDLES || (coin->current != 0 && coin->lastpending != 0 && bp->hdrsi >= coin->current->hdrsi && bp->hdrsi <= coin->lastpending->hdrsi) ) // n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); - //if ( 1 && n > 2 ) + if ( 0 && n > 2 ) printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n); //if ( bp->queued == 0 ) // iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500)); @@ -1390,14 +1390,15 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc iguana_bundleQ(myinfo,coin,firstbp,1000); } } - if ( i == n && i == match && firstbp == coin->current && (addr= req->addr) != 0 ) + if ( (addr= req->addr) != 0 && n >= coin->chain->bundlesize ) { - addr->RThashes[i] = firstbp->hashes[0]; + addr->RThashes[0] = firstbp->hashes[0]; for (i=1; ichain->bundlesize; i++) { iguana_serialize_block(myinfo,coin->chain,&addr->RThashes[i],serialized,(struct iguana_block *)&zblocks[i]); } - addr->numRThashes = n; + addr->numRThashes = coin->chain->bundlesize; + printf("firstbp.[%d] call allhashes\n",firstbp->hdrsi); if ( iguana_allhashcmp(myinfo,coin,firstbp,addr->RThashes,coin->chain->bundlesize) > 0 ) return(req); } From 822257e3641ecb3a779cdec8a7981b2ae7a18073 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 17:46:41 -0300 Subject: [PATCH 04/11] test --- iguana/iguana_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 0b60eb7fe..10ffde4b5 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1390,7 +1390,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc iguana_bundleQ(myinfo,coin,firstbp,1000); } } - if ( (addr= req->addr) != 0 && n >= coin->chain->bundlesize ) + if ( firstbp != 0 && (addr= req->addr) != 0 && n >= coin->chain->bundlesize ) { addr->RThashes[0] = firstbp->hashes[0]; for (i=1; ichain->bundlesize; i++) From 0aca7a577970ca0b8504665a3c97fa9da20cee7e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 17:58:22 -0300 Subject: [PATCH 05/11] test --- iguana/iguana_recv.c | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 10ffde4b5..197a223be 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1335,7 +1335,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc if ( zblocks != 0 && n > 0 ) { memset(prevhash2.bytes,0,sizeof(prevhash2)); - for (i=1,match=0; ichain->bundlesize; i++) + for (i==match=0; ichain->bundlesize; i++) { //fprintf(stderr,"i.%d of %d bundleset\n",i,n); if ( bits256_cmp(zblocks[i].RO.prev_block,coin->blocks.hwmchain.RO.hash2) == 0 ) @@ -1343,7 +1343,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc bp = 0, bundlei = -2; if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) != 0 ) { - if ( i == 1 ) + if ( firstbp == 0 ) firstbp = bp; if ( block->height >= 0 && block->height+1 > coin->longestchain ) coin->longestchain = block->height+1; @@ -1351,45 +1351,45 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc } //char str[65]; printf("HWM in hdr's prev[%d] bp.%p bundlei.%d block.%p %s\n",i,bp,bundlei,block,bp!=0?bits256_str(str,bp->hashes[bundlei]):"()"); } - if ( i > 0 && bits256_cmp(prevhash2,zblocks[i].RO.prev_block) == 0 ) + bp = 0, bundlei = -2; + if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) == 0 ) { bp = 0, bundlei = -2; - if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) != 0 ) + if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i].RO.prev_block)) != 0 ) { - bp->dirty++; - if ( bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 ) - { - bp->issued[bundlei] = 1; - iguana_blockQ("recvhdr",coin,bp,bundlei,block->RO.hash2,0); - } - //printf("{%d:%d} ",bp->hdrsi,bundlei); - if ( i == 1 ) - { - firstbp = bp; - iguana_checklongestchain(coin,bp,coin->chain->bundlesize); - } - if ( bundlei == i+1 && bp == firstbp ) - match++; - else if ( 0 ) + if ( bundlei < coin->chain->bundlesize-1 ) + bundlei++; + else { - if ( bp != coin->current && i != coin->chain->bundlesize-1 ) - fprintf(stderr,"recvhdr: ht.%d[%d] vs i.%d\n",bp->bundleheight,bundlei,i); + bundlei = 0; + bp = coin->bundles[bp->hdrsi+1]; } } } + if ( bp != 0 ) + { + bp->dirty++; + if ( bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 ) + { + bp->issued[bundlei] = 1; + iguana_blockQ("recvhdr",coin,bp,bundlei,block->RO.hash2,0); + } + if ( bundlei == i && bp == firstbp ) + match++; + } prevhash2 = zblocks[i].RO.hash2; } char str[65]; - if ( 0 && bp == coin->current ) + //if ( 0 && bp == coin->current ) printf("i.%d n.%d match.%d blockhdrs.%s hdrsi.%d\n",i,n,match,bits256_str(str,zblocks[0].RO.hash2),firstbp!=0?firstbp->hdrsi:-1); - if ( firstbp != 0 && match == coin->chain->bundlesize-1 && n == firstbp->n ) + /*if ( firstbp != 0 && match >= coin->chain->bundlesize-1 ) { if ( firstbp->queued == 0 ) { //fprintf(stderr,"firstbp blockQ %d\n",firstbp->bundleheight); iguana_bundleQ(myinfo,coin,firstbp,1000); } - } + }*/ if ( firstbp != 0 && (addr= req->addr) != 0 && n >= coin->chain->bundlesize ) { addr->RThashes[0] = firstbp->hashes[0]; From 4c273cefbc93cf953f11c03a939b49e1b44c9518 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 17:59:18 -0300 Subject: [PATCH 06/11] test --- iguana/iguana_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 197a223be..4ce78e5d3 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1335,7 +1335,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc if ( zblocks != 0 && n > 0 ) { memset(prevhash2.bytes,0,sizeof(prevhash2)); - for (i==match=0; ichain->bundlesize; i++) + for (i=match=0; ichain->bundlesize; i++) { //fprintf(stderr,"i.%d of %d bundleset\n",i,n); if ( bits256_cmp(zblocks[i].RO.prev_block,coin->blocks.hwmchain.RO.hash2) == 0 ) From fd2fb67fb7d73beedd0f45f47d6dbf866f1a7e83 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 18:02:25 -0300 Subject: [PATCH 07/11] test --- iguana/iguana_recv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 4ce78e5d3..899895744 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1368,14 +1368,16 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc } if ( bp != 0 ) { + if ( firstbp == 0 ) + firstbp = bp, matches++; + else if ( bp == firstbp ) + matches++; bp->dirty++; if ( bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 ) { bp->issued[bundlei] = 1; iguana_blockQ("recvhdr",coin,bp,bundlei,block->RO.hash2,0); } - if ( bundlei == i && bp == firstbp ) - match++; } prevhash2 = zblocks[i].RO.hash2; } From 4b233c6a8892a04975a4ea61b21995417a451648 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 18:03:01 -0300 Subject: [PATCH 08/11] test --- iguana/iguana_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 899895744..92bacdbd8 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1369,9 +1369,9 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc if ( bp != 0 ) { if ( firstbp == 0 ) - firstbp = bp, matches++; + firstbp = bp, match++; else if ( bp == firstbp ) - matches++; + match++; bp->dirty++; if ( bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 ) { From ddf0f9656723977a6730c8611026214d23e05290 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 18:07:43 -0300 Subject: [PATCH 09/11] test --- iguana/iguana_recv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 92bacdbd8..ccc4aa542 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -911,7 +911,7 @@ int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,str } if ( strcmp("BTC",coin->symbol) != 0 && n == 2 ) iguana_sendblockreqPT(coin,addr,0,-1,zblocks[1].RO.hash2,0); - if ( 0 ) + if ( 1 ) { for (i=0; ibundlescount; i++) { @@ -1022,7 +1022,7 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin //n = 0; //if ( bp->hdrsi < coin->MAXBUNDLES || (coin->current != 0 && coin->lastpending != 0 && bp->hdrsi >= coin->current->hdrsi && bp->hdrsi <= coin->lastpending->hdrsi) ) // n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); - if ( 0 && n > 2 ) + //if ( 0 && n > 2 ) printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n); //if ( bp->queued == 0 ) // iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500)); @@ -1382,7 +1382,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc prevhash2 = zblocks[i].RO.hash2; } char str[65]; - //if ( 0 && bp == coin->current ) + if ( 0 && bp == coin->current ) printf("i.%d n.%d match.%d blockhdrs.%s hdrsi.%d\n",i,n,match,bits256_str(str,zblocks[0].RO.hash2),firstbp!=0?firstbp->hdrsi:-1); /*if ( firstbp != 0 && match >= coin->chain->bundlesize-1 ) { From 4accef2ff3497231e4cec595f9a2e90b79d0678b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 18:11:49 -0300 Subject: [PATCH 10/11] test --- iguana/iguana_recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index ccc4aa542..b2dc8f46b 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -984,6 +984,7 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin if ( bits256_nonz(bp->allhash) > 0 && num >= coin->chain->bundlesize && bp->emitfinish == 0 ) { vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes)); + char str[65]; printf("allhashes.(%s)\n",bits256_str(str,allhash)); if ( memcmp(allhash.bytes,bp->allhash.bytes,sizeof(allhash)) == 0 ) { if ( bp->bundleheight > 0 ) @@ -1400,7 +1401,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc iguana_serialize_block(myinfo,coin->chain,&addr->RThashes[i],serialized,(struct iguana_block *)&zblocks[i]); } addr->numRThashes = coin->chain->bundlesize; - printf("firstbp.[%d] call allhashes\n",firstbp->hdrsi); + printf("firstbp.[%d] call allhashes %s\n",firstbp->hdrsi,bits256_str(str,addr->RThashes[0])); if ( iguana_allhashcmp(myinfo,coin,firstbp,addr->RThashes,coin->chain->bundlesize) > 0 ) return(req); } From c5d5b576b089a3ddbe9ede3206a5b7d4fb6186f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 16 Sep 2016 18:19:50 -0300 Subject: [PATCH 11/11] test --- iguana/iguana_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index b2dc8f46b..026a7e98a 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -984,7 +984,7 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin if ( bits256_nonz(bp->allhash) > 0 && num >= coin->chain->bundlesize && bp->emitfinish == 0 ) { vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes)); - char str[65]; printf("allhashes.(%s)\n",bits256_str(str,allhash)); + //char str[65]; printf("allhashes.(%s)\n",bits256_str(str,allhash)); if ( memcmp(allhash.bytes,bp->allhash.bytes,sizeof(allhash)) == 0 ) { if ( bp->bundleheight > 0 ) @@ -1401,7 +1401,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc iguana_serialize_block(myinfo,coin->chain,&addr->RThashes[i],serialized,(struct iguana_block *)&zblocks[i]); } addr->numRThashes = coin->chain->bundlesize; - printf("firstbp.[%d] call allhashes %s\n",firstbp->hdrsi,bits256_str(str,addr->RThashes[0])); + //printf("firstbp.[%d] call allhashes %s\n",firstbp->hdrsi,bits256_str(str,addr->RThashes[0])); if ( iguana_allhashcmp(myinfo,coin,firstbp,addr->RThashes,coin->chain->bundlesize) > 0 ) return(req); }