From 243ec805df25b012246467e5fa98eeb9c3f8858f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Sep 2016 14:50:29 -0300 Subject: [PATCH] test --- iguana/iguana_ramchain.c | 2 +- iguana/iguana_recv.c | 44 +++++++++++++++++++++++++++----------- iguana/tests/backupwallet | 2 +- iguana/tests/backupwallet2 | 1 + 4 files changed, 34 insertions(+), 15 deletions(-) create mode 100755 iguana/tests/backupwallet2 diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index a75b1377f..92d6d88c6 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -103,7 +103,7 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname, bp = 0, bundlei = -2; if ( bits256_nonz(prevhash2) == 0 || (bp= iguana_bundlefind(coin,&bp,&bundlei,prevhash2)) == 0 || bundlei >= coin->chain->bundlesize-1 ) { - if ( 0 && dispflag != 0 ) + //if ( 0 && dispflag != 0 ) printf("iguana_peerfname %s error finding.(%s) spec.%p bp.%p\n",coin->symbol,bits256_str(str,hash2),bp!=0?bp->speculative:0,bp); return(-2); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index b21a91649..bd1c5e5b1 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -761,7 +761,10 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru return; } else if ( bundlei < coin->chain->bundlesize-1 ) + { bundlei++; + iguana_hash2set(coin,"gotblockM",bp,bundlei,origtxdata->zblock.RO.hash2); + } else // new bundle case, but bad context to extend { origtxdata->zblock.issued = 0; @@ -780,10 +783,22 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru if ( (speculative= iguana_bundlestats_update(coin,&block,bp,bundlei,origtxdata,data,recvlen)) < 0 ) return; if ( block == 0 ) + block = iguana_blockhashset("noblock",coin,bp->bundleheight+bundlei,origtxdata->zblock.RO.hash2,1); + if ( block->hdrsi != bp->hdrsi || block->bundlei != bundlei ) { - printf("getblockM no block to update\n"); - return; + block->hdrsi = bp->hdrsi; + block->bundlei = bundlei; } + if ( bp->blocks[bundlei] == 0 || bits256_nonz(bp->hashes[bundlei]) == 0 ) + { + //printf("SET [%d:%d]\n",bp->hdrsi,bundlei); + //iguana_hash2set(coin,"noblock",bp,bundlei,origtxdata->zblock.RO.hash2); + bp->hashes[bundlei] = origtxdata->zblock.RO.hash2; + if ( bp->speculative != 0 ) + bp->speculative[bundlei] = bp->hashes[bundlei]; + bp->blocks[bundlei] = block; + } + //printf("getblockM update [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2)); block->txvalid = 1; if ( block->fpipbits != 0 && block->fpos >= 0 ) { @@ -1413,7 +1428,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str if ( bits256_nonz(bp->nextbundlehash2) == 0 && num > coin->chain->bundlesize ) { bp->nextbundlehash2 = blockhashes[coin->chain->bundlesize]; - //iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1); + iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1); } //printf("call allhashes\n"); if ( 0 && bp->hdrsi == coin->bundlescount-1 ) @@ -1448,8 +1463,8 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str for (i=1; in; i++) { bp->speculative[i] = blockhashes[i]; - //if ( bp->blocks[i] == 0 || bp->blocks[i]->issued == 0 ) - // iguana_blockQ("speculate",coin,bp,-i,blockhashes[i],0); + if ( bp->blocks[i] == 0 || bp->blocks[i]->issued == 0 ) + iguana_blockQ("speculate",coin,bp,-i,blockhashes[i],0); if ( bp->blocks[i] == 0 ) bp->blocks[i] = iguana_blockhashset("recvhashes3",coin,bp->bundleheight+i,blockhashes[i],1); //printf("speculate new issue [%d:%d]\n",bp->hdrsi,i); @@ -1526,14 +1541,14 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str { //iguana_blockQ("recvhash7",coin,0,-7,blockhashes[1],1); iguana_blockQ("recvhash7",coin,0,-7,blockhashes[num-1],1); - //if ( 1 && coin->RTheight > 0 ) + if ( 1 && coin->RTheight > 0 ) { for (i=1; isymbol) == 0 ) - printf("%s received.(%s) %s\n",coin->symbol,bits256_str(str,origblock->RO.hash2),addr->ipaddr); if ( (block= iguana_blockfind("recv",coin,origblock->RO.hash2)) != 0 ) iguana_blockcopy(coin->chain->zcash,coin->chain->auxpow,coin,block,(struct iguana_block *)origblock); else if ( (block= iguana_blockhashset("recvblock",coin,-1,origblock->RO.hash2,1)) == 0 ) @@ -1556,12 +1569,17 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig } if ( bits256_nonz(origblock->RO.prev_block) != 0 ) { - if ( (prevblock= iguana_blockfind("prev",coin,origblock->RO.prev_block)) != 0 && prevblock->height+1 > coin->longestchain ) - coin->longestchain = prevblock->height+1; - else iguana_blockQ("prev",coin,0,-1,origblock->RO.prev_block,1); + if ( (prevblock= iguana_blockfind("prev",coin,origblock->RO.prev_block)) != 0 ) + { + if ( prevblock->height+1 > coin->longestchain ) + coin->longestchain = prevblock->height+1; + } else iguana_blockQ("prev",coin,0,-1,origblock->RO.prev_block,1); } + //printf("%s received.(%s) %s\n",coin->symbol,bits256_str(str,origblock->RO.hash2),addr->ipaddr); if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 ) { + if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) + printf("%s received.(%s) %s\n",coin->symbol,bits256_str(str,origblock->RO.hash2),addr->ipaddr); if ( bp->speculative != 0 && bp->numspec <= bundlei ) { bp->speculative[bundlei] = block->RO.hash2; @@ -1574,7 +1592,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig block = iguana_bundleblock(coin,&hash2,bp,bundlei); } //printf("autoadd [%d:%d]\n",bp->hdrsi,bundlei); - } // else printf("couldnt find.(%s)\n",bits256_str(str,block->RO.hash2)); + } //else printf("couldnt find.(%s)\n",bits256_str(str,block->RO.hash2)); if ( bp != 0 ) { bp->dirty++; diff --git a/iguana/tests/backupwallet b/iguana/tests/backupwallet index 32645108d..8b0222eb7 100755 --- a/iguana/tests/backupwallet +++ b/iguana/tests/backupwallet @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"backupwallet\",\"params\":[\"testwallet\"]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"backupwallet\",\"params\":[\"testwallet\"]}" diff --git a/iguana/tests/backupwallet2 b/iguana/tests/backupwallet2 new file mode 100755 index 000000000..32645108d --- /dev/null +++ b/iguana/tests/backupwallet2 @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"backupwallet\",\"params\":[\"testwallet\"]}"