diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index a48dba97d..4fdbc0bb8 100755 --- a/gecko/gecko_blocks.c +++ b/gecko/gecko_blocks.c @@ -58,7 +58,7 @@ struct iguana_bundle *gecko_bundleset(struct iguana_info *virt,struct iguana_blo else { bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; + bp->hash2[bundlei] = block->RO.hash2; //char str[65]; printf("[%d:%d] <- %s %p\n",hdrsi,bundlei,bits256_str(str,block->RO.hash2),block); iguana_hash2set(virt,"ensure",bp,bundlei,block->RO.hash2); } diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 20bb3e815..cce14b1ae 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -1090,7 +1090,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers, if ( coin->MAXMEM == 0 ) coin->MAXMEM = IGUANA_DEFAULTRAM; coin->MAXMEM *= (1024L * 1024 * 1024); - coin->enableCACHE = (strcmp("BTCD",coin->symbol) == 0); + coin->enableCACHE = 0;//(strcmp("BTC",coin->symbol) != 0); if ( jobj(json,"cache") != 0 ) coin->enableCACHE = juint(json,"cache"); if ( (coin->polltimeout= juint(json,"poll")) <= 0 ) diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index 0b49b61e9..90fa504c5 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -258,7 +258,7 @@ bits256 *iguana_blockhashptr(struct iguana_info *coin,int32_t height) if ( hdrsi >= 0 && hdrsi < coin->bundlescount && bundlei >= 0 && bundlei < bundlesize ) { if ( (bp= coin->bundles[hdrsi]) != 0 ) - return(&bp->hashes[bundlei]); + return(&bp->hash2[bundlei]); else return(0); } } @@ -448,9 +448,9 @@ int32_t iguana_walkchain(struct iguana_info *coin,int32_t skipflag) printf("%s walk error blockhash error at %d %s\n",coin->symbol,height,bits256_str(str,iguana_blockhash(coin,height))); break; } - else if ( bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) + else if ( bits256_cmp(bp->hash2[bundlei],block->RO.hash2) != 0 ) { - printf("%s walk error [%d:%d] %s vs %s\n",coin->symbol,hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str,block->RO.hash2)); + printf("%s walk error [%d:%d] %s vs %s\n",coin->symbol,hdrsi,bundlei,bits256_str(str,bp->hash2[bundlei]),bits256_str(str,block->RO.hash2)); break; } else if ( block->hdrsi != hdrsi || block->bundlei != bundlei ) @@ -491,7 +491,7 @@ struct iguana_block *iguana_fastlink(struct iguana_info *coin,int32_t hwmheight) printf("iguana_fastlink null bundle.[%d]\n",hdrsi); break; } - block = iguana_blockhashset("fastlink",coin,height,bp->hashes[bundlei],1); + block = iguana_blockhashset("fastlink",coin,height,bp->hash2[bundlei],1); if ( bp->blocks[bundlei] != 0 && block != bp->blocks[bundlei] ) { printf("iguana_fastlink null block.[%d:%d]\n",hdrsi,bundlei); @@ -650,9 +650,9 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan { if ( (bp= coin->bundles[hdrsi]) != 0 ) { - if ( memcmp(bp->hashes[bundlei].bytes,block->RO.hash2.bytes,sizeof(bits256)) != 0 || block != bp->blocks[bundlei] ) + if ( memcmp(bp->hash2[bundlei].bytes,block->RO.hash2.bytes,sizeof(bits256)) != 0 || block != bp->blocks[bundlei] ) { - if ( bits256_nonz(bp->hashes[bundlei]) != 0 ) + if ( bits256_nonz(bp->hash2[bundlei]) != 0 ) { if ( bp->blocks[bundlei] == 0 && block != 0 ) bp->blocks[bundlei] = block; @@ -661,7 +661,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan //char str[65],str2[65]; //printf("ERROR: need to fix up bundle for height.%d (%p %p) (%s %s)\n",block->height,block,bp->blocks[bundlei],bits256_str(str,block->RO.hash2),bits256_str(str2,bp->hashes[bundlei])); bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; + bp->hash2[bundlei] = block->RO.hash2; //if ( bp == coin->current && coin->RTheight > 0 ) // coin->RTdatabad = 1; @@ -673,10 +673,10 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan iguana_blockunmark(coin,block,bp,bundlei,0); iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); } - else + else if ( bits256_nonz(block->RO.hash2) != 0 ) { bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; + bp->hash2[bundlei] = block->RO.hash2; iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); } if ( coin->started != 0 && bundlei == coin->minconfirms && (block->height > coin->longestchain-coin->chain->bundlesize*2 || ((block->height / coin->chain->bundlesize) % 100) == 9) ) @@ -701,7 +701,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan block->hdrsi = hdrsi; block->bundlei = bundlei; bp = coin->bundles[hdrsi]; - if ( bp->blocks[bundlei] != block || bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) + if ( bp->blocks[bundlei] != block || bits256_cmp(bp->hash2[bundlei],block->RO.hash2) != 0 ) printf("new hwm [%d:%d] mismatched bundle block\n",hdrsi,bundlei); return(block); } diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 498fa28ee..34af01f4f 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -59,7 +59,7 @@ int32_t iguana_bundlescan(struct iguana_info *coin,struct iguana_bundle *bp,bits int32_t bundlei; for (bundlei=0; bundlein; bundlei++) { - if ( memcmp(hash2.bytes,bp->hashes[bundlei].bytes,sizeof(hash2)) == 0 ) + if ( memcmp(hash2.bytes,bp->hash2[bundlei].bytes,sizeof(hash2)) == 0 ) { //char str[65]; printf("hdrsi.%d scan.%s found %d of %d\n",bp->hdrsi,bits256_str(str,hash2),bundlei,bp->n); return(bundlei); @@ -126,7 +126,7 @@ bits256 *iguana_bundleihash2p(struct iguana_info *coin,int32_t *isinsidep,struct if ( bundlei >= 0 && bundlei < coin->chain->bundlesize ) { *isinsidep = 1; - return(&bp->hashes[bundlei]); + return(&bp->hash2[bundlei]); } else if ( bundlei == -1 ) return(&bp->prevbundlehash2); @@ -226,6 +226,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo } if ( bits256_nonz(hash2) != 0 && (block= iguana_blockhashset("bundlehash2add",coin,-1,hash2,1)) != 0 ) { + block->RO.hash2 = hash2; if ( bp->blocks[bundlei] != 0 && bp->blocks[bundlei] != block ) { if ( block->mainchain != 0 && (block->height % coin->chain->bundlesize) == bundlei && (block->height / coin->chain->bundlesize) == bp->hdrsi ) @@ -233,7 +234,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo char str[65],str2[65]; printf("bundle block override [%d:%d] %s <- %s\n",bp->hdrsi,bundlei,bits256_str(str,bp->blocks[bundlei]->RO.hash2),bits256_str(str2,block->RO.hash2)); bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; + bp->hash2[bundlei] = block->RO.hash2; } else if ( block->mainchain == 0 ) { @@ -258,7 +259,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo return(-1); } } - if ( 0 && bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) + if ( 0 && bits256_nonz(bp->hash2[bundlei]) != 0 && bits256_cmp(bp->hash2[bundlei],block->RO.hash2) != 0 ) { //char str[65],str2[65]; //printf("B bp.[%d]->hashes[%d] mismatch %s != %s%s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str2,block->RO.hash2),block->mainchain?".main":""); @@ -295,9 +296,9 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo char str[65]; block->hdrsi = bp->hdrsi; block->bundlei = bundlei; - bp->hashes[bundlei] = block->RO.hash2; + bp->hash2[bundlei] = block->RO.hash2; if ( bp->speculative != 0 && bundlei < bp->numspec ) - bp->speculative[bundlei] = bp->hashes[bundlei]; + bp->speculative[bundlei] = bp->hash2[bundlei]; if ( bp->blocks[bundlei] == 0 ) bp->blocks[bundlei] = block; else if ( bp->blocks[bundlei] != block ) @@ -350,8 +351,8 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo if ( bits256_cmp(bp->bundlehash2,bp->bundlehash2) != 0 ) { char str[65]; - printf("hdrs.%d %p bundlehash2? %s\n",bp->hdrsi,bp,bits256_str(str,bp->hashes[0])); - bp->hashes[0] = bp->bundlehash2; + printf("hdrs.%d %p bundlehash2? %s\n",bp->hdrsi,bp,bits256_str(str,bp->hash2[0])); + bp->hash2[0] = bp->bundlehash2; } return(-err); } @@ -411,7 +412,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund } if ( bp->hdrsi >= coin->bundlescount ) coin->bundlescount = (bp->hdrsi + 1); - printf("bp.%p hashes[0] %s\n",bp,bits256_str(str,bp->hashes[0])); + printf("bp.%p hashes[0] %s\n",bp,bits256_str(str,bp->hash2[0])); } else { @@ -516,9 +517,9 @@ void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp) { portable_mutex_lock(&coin->RTmutex); recvlen = -1; - iguana_RTrawdata(coin,bp->hashes[j],0,&recvlen,&numtx,0); // delete file + iguana_RTrawdata(coin,bp->hash2[j],0,&recvlen,&numtx,0); // delete file portable_mutex_unlock(&coin->RTmutex); - if ( iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,ipbits,bp->hashes[j],zero,1,1) >= 0 ) + if ( iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,ipbits,bp->hash2[j],zero,1,1) >= 0 ) { if ( (fp= fopen(fname,"rb")) != 0 ) { @@ -806,7 +807,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin char str[65]; printf("[%d:%d] %s\n",bp->hdrsi,i,bits256_str(str,prevhash2)); if ( bp->blocks[i] == 0 && bits256_nonz(prevhash2) != 0 ) { - bp->hashes[i] = prevhash2; + bp->hash2[i] = prevhash2; bp->blocks[i] = iguana_blockhashset("ready",coin,bp->bundleheight+i,prevhash2,1); iguana_hash2set(coin,"ready",bp,i,prevhash2); prevhash2 = zero; @@ -972,14 +973,15 @@ int64_t iguana_bundlecalcs(struct supernet_info *myinfo,struct iguana_info *coin datasize = numhashes = numsaved = numrecv = numcached = minrequests = 0; for (bundlei=0; bundlein; bundlei++) { - if ( bits256_nonz(bp->hashes[bundlei]) != 0 ) + if ( bits256_nonz(bp->hash2[bundlei]) != 0 ) { numhashes++; if ( bp->speculativecache[bundlei] != 0 ) numcached++; if ( (block= bp->blocks[bundlei]) != 0 ) { - if ( bits256_cmp(block->RO.hash2,bp->hashes[bundlei]) == 0 ) + char str[65],str2[65]; + if ( bits256_cmp(block->RO.hash2,bp->hash2[bundlei]) == 0 ) { //if ( bp->minrequests == 0 || (block->numrequests > 0 && block->numrequests < bp->minrequests) ) // bp->minrequests = block->numrequests; @@ -987,29 +989,30 @@ int64_t iguana_bundlecalcs(struct supernet_info *myinfo,struct iguana_info *coin { SETBIT(bp->haveblock,bundlei); numsaved++; - } + } //else printf("[%d:%d %d %d %d] ",bp->hdrsi,bundlei,block->fpipbits,block->txvalid,block->fpos); if ( block->RO.recvlen != 0 ) { numrecv++; datasize += block->RO.recvlen; } } - else if ( 0 && bits256_nonz(block->RO.hash2) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 ) + else if ( 0 && bits256_nonz(block->RO.hash2) != 0 && bits256_nonz(bp->hash2[bundlei]) != 0 ) { printf("hash mismatch [%d:%d]\n",bp->hdrsi,bundlei); iguana_blockunmark(coin,block,bp,bundlei,1); if ( bundlei < coin->chain->bundlesize-1 ) { - if ( (block= iguana_blockfind("mismatch",coin,bp->hashes[bundlei+1])) != 0 ) + if ( (block= iguana_blockfind("mismatch",coin,bp->hash2[bundlei+1])) != 0 ) { if ( block->mainchain != 0 ) { - bp->hashes[bundlei] = block->RO.prev_block; + bp->hash2[bundlei] = block->RO.prev_block; printf("patch [%d:%d] from next block\n",bp->hdrsi,bundlei); } } } } + else printf("[%d:%d] %s v %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2),bits256_str(str2,bp->hash2[bundlei])); } //else printf("[null %d:%d] ",bp->hdrsi,bundlei); } } @@ -1085,7 +1088,7 @@ int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *c iguana_bundletweak(coin,bp); coin->numemitted++; for (i=0; in; i++) - iguana_hash2set(coin,"bundlefinalize",bp,i,bp->hashes[i]); + iguana_hash2set(coin,"bundlefinalize",bp,i,bp->hash2[i]); /*if ( bp->hdrsi == 0 && iguana_peerblockrequest(coin,coin->blockspace,coin->blockspacesize,0,bp->bundlehash2,1) > 0 ) printf("GENESIS block validated\n"); else printf("GENESIS didnt validate bp.%p\n",bp);*/ @@ -1303,7 +1306,7 @@ int32_t iguana_bundlehash2_check(struct iguana_info *coin,bits256 hash2) } break; } - if ( bits256_cmp(bp->hashes[j],hash2) == 0 ) + if ( bits256_cmp(bp->hash2[j],hash2) == 0 ) { flag = 1; if ( (block= iguana_blockfind("hashspec",coin,hash2)) != 0 ) @@ -1311,7 +1314,7 @@ int32_t iguana_bundlehash2_check(struct iguana_info *coin,bits256 hash2) if ( block->mainchain != 0 && block->txvalid != 0 && block->hdrsi != bp->hdrsi ) { printf("found [%d:%d] in [%d:%d]'s place\n",block->hdrsi,block->bundlei,bp->hdrsi,j); - memset(&bp->hashes[j],0,sizeof(bp->hashes[j])); + memset(&bp->hash2[j],0,sizeof(bp->hash2[j])); bp->blocks[j] = 0; } } @@ -1360,8 +1363,8 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch { for (j=0; jn; j++) { - if ( bp->blocks[j] == 0 && bits256_nonz(bp->hashes[j]) != 0 ) - bp->blocks[j] = iguana_blockfind("bundlestats2",coin,bp->hashes[j]); + if ( bp->blocks[j] == 0 && bits256_nonz(bp->hash2[j]) != 0 ) + bp->blocks[j] = iguana_blockfind("bundlestats2",coin,bp->hash2[j]); } } else @@ -1574,7 +1577,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch { for (i=coin->RTheight-bp->bundleheight; in; i++) { - iguana_bundlehash2_check(coin,bp->hashes[i]); + iguana_bundlehash2_check(coin,bp->hash2[i]); if ( bp->speculative != 0 ) iguana_bundlehash2_check(coin,bp->speculative[i]); } diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 0126e2300..ce30c92af 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -170,7 +170,7 @@ int32_t iguana_savehdrs(struct iguana_info *coin) shastr[0] = 0; if ( bits256_nonz(bp->allhash) == 0 ) { - vcalc_sha256(shastr,sha256all.bytes,bp->hashes[0].bytes,sizeof(*bp->hashes) * coin->chain->bundlesize); + vcalc_sha256(shastr,sha256all.bytes,bp->hash2[0].bytes,sizeof(*bp->hash2) * coin->chain->bundlesize); bp->allhash = sha256all; } else @@ -178,9 +178,9 @@ int32_t iguana_savehdrs(struct iguana_info *coin) sha256all = bp->allhash; bits256_str(shastr,bp->allhash); } - fprintf(fp,"%d %s %s %s\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),shastr,bits256_str(str2,bp->hashes[1])); + fprintf(fp,"%d %s %s %s\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),shastr,bits256_str(str2,bp->hash2[1])); if ( fp2 != 0 ) - fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),shastr,bits256_str(str2,bp->hashes[1])); + fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->bundlehash2),shastr,bits256_str(str2,bp->hash2[1])); } else { @@ -439,7 +439,8 @@ void iguana_bundlepurge(struct iguana_info *coin,struct iguana_bundle *bp) } bp->numspec = 0; bp->speculative = 0; - memset(bp->hashes,0,sizeof(bp->hashes)); + printf("purge bundle\n"); + memset(bp->hash2,0,sizeof(bp->hash2)); memset(bp->issued,0,sizeof(bp->issued)); bp->prevbundlehash2 = bp->nextbundlehash2 = bp->allhash = zero; } diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 7b5a778a5..d06f30c4c 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -115,16 +115,16 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname, return(-2); } else bundlei++; } - if ( bits256_cmp(bp->hashes[0],bp->bundlehash2) != 0 ) - bp->hashes[0] = bp->bundlehash2; + if ( bits256_cmp(bp->hash2[0],bp->bundlehash2) != 0 ) + bp->hash2[0] = bp->bundlehash2; hash2 = bp->bundlehash2, *hdrsip = bp->hdrsi; subdir = bp->bundleheight / IGUANA_SUBDIRDIVISOR; if ( numblocks == 1 ) { sprintf(fname,"%s/%s/%d",dirname,coin->symbol,subdir), OS_ensure_directory(fname); sprintf(fname,"%s/%s/%d/%d",dirname,coin->symbol,subdir,bp->bundleheight), OS_ensure_directory(fname); - if ( bits256_nonz(bp->hashes[bundlei]) != 0 ) - sprintf(fname,"%s/%s/%d/%d/%s_%u.%d",dirname,coin->symbol,subdir,bp->bundleheight,bits256_str(str,bp->hashes[bundlei]),ipbits>1?ipbits:*hdrsip,bundlei); + if ( bits256_nonz(bp->hash2[bundlei]) != 0 ) + sprintf(fname,"%s/%s/%d/%d/%s_%u.%d",dirname,coin->symbol,subdir,bp->bundleheight,bits256_str(str,bp->hash2[bundlei]),ipbits>1?ipbits:*hdrsip,bundlei); else { printf("no hash for [%d:%d]\n",bp->hdrsi,bundlei); @@ -1425,9 +1425,9 @@ struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct { if ( (block= bp->blocks[i]) != 0 ) { - if ( memcmp(block->RO.hash2.bytes,bp->hashes[i].bytes,sizeof(block->RO.hash2)) == 0 ) + if ( memcmp(block->RO.hash2.bytes,bp->hash2[i].bytes,sizeof(block->RO.hash2)) == 0 ) { - if ( i == 0 || memcmp(block->RO.prev_block.bytes,bp->hashes[i-1].bytes,sizeof(block->RO.prev_block)) == 0 ) + if ( i == 0 || memcmp(block->RO.prev_block.bytes,bp->hash2[i-1].bytes,sizeof(block->RO.prev_block)) == 0 ) valid++; } } @@ -1477,7 +1477,7 @@ struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct } else { - bp->hashes[i] = zRO.RO.hash2; + bp->hash2[i] = zRO.RO.hash2; //bp->blocks[i]->RO = zRO.RO; iguana_blockzcopyRO(0*zcash,&bp->blocks[i]->RO,0,(void *)&zRO,0); } @@ -1822,10 +1822,10 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,int32_t txn_count,uint8_t *data,int32_t recvlen,struct iguana_bundle *bp,struct iguana_block *block) { int32_t verifyflag = 0; - RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; + RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei=-1; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; if ( block == 0 || bp == 0 || addr == 0 || (block != 0 && (bundlei= block->bundlei) < 0) ) { - //printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr); + //printf("iguana_ramchain_data: illegal %p %p %p bundlei.%d\n",block,bp,addr,bundlei); return(-1); } #ifdef __PNACL__ @@ -1872,7 +1872,7 @@ long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin, return(-1); } if ( block != 0 ) - block->fpipbits = 1; + block->txvalid = block->fpipbits = 1; for (i=0; iH.txidind++) { tx = &txarray[i]; @@ -2029,7 +2029,7 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru height = bp->bundleheight+i; bp->issued[i] = 0; bp->blocks[i] = 0; - memset(&bp->hashes[i],0,sizeof(bp->hashes[i])); + //memset(&bp->hash2[i],0,sizeof(bp->hash2[i])); if ( (ptr= bp->speculativecache[i]) != 0 ) { memcpy(&recvlen,ptr,sizeof(recvlen)); @@ -2069,7 +2069,7 @@ int32_t iguana_oldbundlefiles(struct iguana_info *coin,uint32_t *ipbits,void **p if ( j == num ) { ipbits[num] = fpipbits; - if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,fpipbits,bp->hashes[bundlei],zero,1,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) + if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,fpipbits,bp->hash2[bundlei],zero,1,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) { printf("B iguana_ramchain_map.(%s) illegal hdrsi.%d bundlei.%d checki.%d\n",fname,hdrsi,bundlei,checki); return(0); @@ -2092,7 +2092,7 @@ void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,str int32_t checki,hdrsi; long checksize; void *ptr = 0; FILE *fp; static const bits256 zero; //char renamed[1024]; *filesizep = 0; fname[0] = 0; - if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,0,bp->hashes[bundlei],zero,1,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) + if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,0,bp->hash2[bundlei],zero,1,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) { printf("B iguana_ramchain_map.(%s) illegal hdrsi.%d bundlei.%d checki.%d\n",fname,hdrsi,bundlei,checki); return(0); @@ -2298,7 +2298,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig prev = prev2 = 0; for (i=0; in; i++) { - if ( (block= bp->blocks[i]) != 0 || (block= iguana_blockhashset("bundleload",coin,bp->bundleheight+i,bp->hashes[i],1)) != 0 ) + if ( (block= bp->blocks[i]) != 0 || (block= iguana_blockhashset("bundleload",coin,bp->bundleheight+i,bp->hash2[i],1)) != 0 ) { if ( bits256_to_compact(bits256_from_compact(block->RO.bits)) != block->RO.bits ) { @@ -2315,7 +2315,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig iguana_blockzcopyRO(0*coin->chain->zcash,&block->RO,0,B,i); //printf("%x ",(int32_t)B[i].hash2.ulongs[3]); bp->blocks[i] = block; - bp->hashes[i] = block->RO.hash2; + bp->hash2[i] = block->RO.hash2; block->RO.firsttxidind = firsttxidind; bp->firsttxidinds[i] = firsttxidind; iguana_hash2set(coin,"bundleload",bp,i,block->RO.hash2); @@ -2437,12 +2437,12 @@ int32_t iguana_mapchaininit(char *fname,struct iguana_info *coin,struct iguana_r //getchar(); return(-1); } - else if ( memcmp(bp->hashes[bundlei].bytes,mapchain->H.data->firsthash2.bytes,sizeof(bits256)) != 0 ) + else if ( memcmp(bp->hash2[bundlei].bytes,mapchain->H.data->firsthash2.bytes,sizeof(bits256)) != 0 ) { - char str[65],str2[65]; printf("iguana_bundlesaveHT.[%d:%d] hash2 mismatch %s vs %s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str2,mapchain->H.data->firsthash2)); + char str[65],str2[65]; printf("iguana_bundlesaveHT.[%d:%d] hash2 mismatch %s vs %s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hash2[bundlei]),bits256_str(str2,mapchain->H.data->firsthash2)); return(-1); } - iguana_ramchain_link(mapchain,bp->hashes[bundlei],bp->hdrsi,bp->bundleheight+bundlei,bundlei,1,firsti,1); + iguana_ramchain_link(mapchain,bp->hash2[bundlei],bp->hdrsi,bp->bundleheight+bundlei,bundlei,1,firsti,1); if ( bp->blocks[bundlei]->RO.txn_count == 0 ) bp->blocks[bundlei]->RO.txn_count = mapchain->H.data->numtxids - 1; return(0); @@ -2485,7 +2485,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi iguana_bundlemapfree(coin,mem,&HASHMEM,ipbits,ptrs,filesizes,num,R,starti,endi); return(-1); } - if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(block->RO.hash2) == 0 || memcmp(block->RO.hash2.bytes,bp->hashes[bundlei].bytes,sizeof(bits256)) != 0 || bits256_cmp(block->RO.prev_block,prevhash2) != 0 ) // block != iguana_blockfind("bundlesave",coin,block->RO.hash2) + if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(block->RO.hash2) == 0 || memcmp(block->RO.hash2.bytes,bp->hash2[bundlei].bytes,sizeof(bits256)) != 0 || bits256_cmp(block->RO.prev_block,prevhash2) != 0 ) // block != iguana_blockfind("bundlesave",coin,block->RO.hash2) { break; } @@ -2540,7 +2540,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi iguana_bundlemapfree(coin,mem,&HASHMEM,ipbits,ptrs,filesizes,num,R,starti,endi); return(-1); } - iguana_ramchain_link(dest,bp->hashes[starti],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,0); + iguana_ramchain_link(dest,bp->hash2[starti],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,0); dest->expanded = 1; dest->H.scriptoffset = 1; _iguana_ramchain_setptrs(RAMCHAIN_DESTPTRS,dest->H.data); @@ -2555,10 +2555,10 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi if ( (block= bp->blocks[i]) != 0 )//&& block == iguana_blockfind("saveHT",coin,bp->hashes[i]) ) { if ( bits256_nonz(block->RO.prev_block) == 0 && i > 0 ) - block->RO.prev_block = bp->hashes[i-1]; + block->RO.prev_block = bp->hash2[i-1]; if ( (bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0) || iguana_blockvalidate(myinfo,coin,&valid,block,1) < 0 ) { - char str[65]; printf("null prevblock error at ht.%d patch.(%s)\n",bp->bundleheight+i,bits256_str(str,bp->hashes[i-1])); + char str[65]; printf("null prevblock error at ht.%d patch.(%s)\n",bp->bundleheight+i,bits256_str(str,bp->hash2[i-1])); iguana_bundlemapfree(coin,mem,&HASHMEM,ipbits,ptrs,filesizes,num,R,starti,endi); iguana_blockunmark(coin,block,bp,i,1); return(-1); @@ -2623,7 +2623,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi else //if ( bp_n == bp->n && bp->n == coin->chain->bundlesize && bp->hdrsi < coin->bundlescount-3 ) { for (j=starti; j<=endi; j++) - iguana_blockdelete(coin,bp->hashes[j],j); + iguana_blockdelete(coin,bp->hash2[j],j); /*{ if ( iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,0,bp->hashes[j],zero,1,1) >= 0 && coin->peers != 0 ) coin->peers->numfiles -= OS_removefile(fname,0); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index cc97c39c6..828a4c4c2 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -650,8 +650,8 @@ void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight) height = 0; hdrsi = (height / coin->chain->bundlesize); bundlei = (height % coin->chain->bundlesize); - if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 ) - iguana_RTrawdata(coin,bp->hashes[bundlei],0,&recvlen,&numtx,0); // delete file + if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_nonz(bp->hash2[bundlei]) != 0 ) + iguana_RTrawdata(coin,bp->hash2[bundlei],0,&recvlen,&numtx,0); // delete file } printf("end %s RTpurge.%d\n",coin->symbol,lastheight); } @@ -674,7 +674,7 @@ int32_t iguana_RTiterate(struct supernet_info *myinfo,struct iguana_info *coin,i { bp->issued[block->bundlei] = 0; bp->blocks[block->bundlei] = block; - bp->hashes[block->bundlei] = block->RO.hash2; + bp->hash2[block->bundlei] = block->RO.hash2; block->height = coin->firstRTheight+offset; if ( coin->peers != 0 ) { diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 491e1fb42..58dc7be31 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -795,24 +795,24 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru //printf("negative speculative return %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); return; } - if ( bp == coin->current ) + //if ( bp == coin->current ) { if ( block == 0 ) block = iguana_blockhashset("noblock",coin,bp->bundleheight+bundlei,origtxdata->zblock.RO.hash2,1); - if ( block->hdrsi != bp->hdrsi || block->bundlei != bundlei ) + if ( block != 0 && (block->hdrsi != bp->hdrsi || block->bundlei != bundlei) ) { block->hdrsi = bp->hdrsi; block->bundlei = bundlei; } - //printf("getblockM update [%d:%d] %s %p\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),block); } - if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(bp->hashes[bundlei]) == 0 ) + //printf("getblockM update %p [%d:%d] %s %p\n",block,block->hdrsi,block->bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),block); + if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(bp->hash2[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; + bp->hash2[bundlei] = origtxdata->zblock.RO.hash2; if ( bp->speculative != 0 ) - bp->speculative[bundlei] = bp->hashes[bundlei]; + bp->speculative[bundlei] = bp->hash2[bundlei]; //bp->blocks[bundlei] = block; } numtx = origtxdata->zblock.RO.txn_count; @@ -820,7 +820,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru if ( block != 0 ) { if ( block->height < 0 ) - block->bundlei = -1; + block->height = bp->hdrsi * coin->chain->bundlesize + bundlei; block->txvalid = 1; block->RO.txn_count = origtxdata->zblock.RO.txn_count; if ( block->fpipbits != 0 && block->fpos >= 0 ) @@ -837,8 +837,8 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru { // printf("DUP s.%d [%d:%d].(%s) %s n%d\n",numsaved,bp!=0?bp->hdrsi:-1,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks); } - req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL); + //req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); + //queue_enqueue("recvQ",&coin->recvQ,&req->DL); return; } } @@ -851,8 +851,13 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0); req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata); queue_enqueue("recvQ",&coin->recvQ,&req->DL); + if ( block != 0 ) + { + block->bundlei = bundlei; + block->hdrsi = bp->hdrsi; + } if ( 0 && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 ) - printf("[%d:%d].s%d %s Q.(%s) %s\n",bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr); + printf("[%d:%d] [%d:%d].s%d %s Q.(%s) %s\n",block->hdrsi,block->bundlei,bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr); if ( numsaved < coin->chain->bundlesize ) { for (i=numsaved=0; ichain->bundlesize; i++) @@ -867,10 +872,10 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru i = addr->addrind % incr; for (; ichain->bundlesize; i+=incr) { - if ( (bp->issued[i] == 0 && bits256_nonz(bp->hashes[i]) != 0) && ((block= bp->blocks[i]) == 0 || bits256_cmp(bp->hashes[i],block->RO.hash2) != 0 || block->fpipbits == 0 || block->fpos < 0 || block->txvalid == 0) ) + if ( (bp->issued[i] == 0 && bits256_nonz(bp->hash2[i]) != 0) && ((block= bp->blocks[i]) == 0 || bits256_cmp(bp->hash2[i],block->RO.hash2) != 0 || block->fpipbits == 0 || block->fpos < 0 || block->txvalid == 0) ) { bp->issued[i] = 1; - iguana_sendblockreqPT(coin,addr,0,-1,bp->hashes[i],0); + iguana_sendblockreqPT(coin,addr,0,-1,bp->hash2[i],0); //printf("numsaved.%d auto issue.[%d:%d] %s\n",numsaved,bp->hdrsi,i,addr->ipaddr); break; } //else printf("numsaved.%d SKIP auto issue.[%d:%d] %s\n",numsaved,bp->hdrsi,i,addr->ipaddr); @@ -934,7 +939,7 @@ int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,str { for (i=0; ibundlescount; i++) { - if ( (bp= coin->bundles[i]) != 0 && bits256_cmp(zblocks[1].RO.hash2,bp->hashes[1]) == 0 && bp->numhashes >= coin->chain->bundlesize ) + if ( (bp= coin->bundles[i]) != 0 && bits256_cmp(zblocks[1].RO.hash2,bp->hash2[1]) == 0 && bp->numhashes >= coin->chain->bundlesize ) return(-1); } } @@ -1058,7 +1063,7 @@ void iguana_bundlespeculate(struct iguana_info *coin,struct iguana_bundle *bp,in return; if ( time(NULL) > bp->hdrtime+3 && strcmp("BTC",coin->symbol) != 0 && bp->numhashes < bp->n && bundlei == 0 && bp->speculative == 0 && bp->bundleheight < coin->longestchain-coin->chain->bundlesize ) { - char str[65]; bits256_str(str,bp->bundlehash2); + char str[65]; bits256_str(str,bp->hash2[0]); //fprintf(stderr,"Afound block -> %d %d hdr.%s\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,str); bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str)); @@ -1071,9 +1076,9 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i struct iguana_ramchain blockR; int32_t hdrsi,firstflag=0,checki,retval=-1; long size = 0; FILE *fp; char fname[1024]; block->bundlei = bundlei; block->hdrsi = bp->hdrsi; - if ( bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) + if ( bits256_nonz(bp->hash2[bundlei]) != 0 && bits256_cmp(bp->hash2[bundlei],block->RO.hash2) != 0 ) { - char str[65],str2[65]; printf("mismatched.[%d:%d] %s <-? %s%s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str2,block->RO.hash2),block->mainchain?".main":""); + char str[65],str2[65]; printf("mismatched.[%d:%d] %s <-? %s%s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hash2[bundlei]),bits256_str(str2,block->RO.hash2),block->mainchain?".main":""); if ( block == bp->blocks[bundlei] ) { if ( block->mainchain == 0 ) @@ -1132,10 +1137,10 @@ void iguana_bundle_set(struct iguana_info *coin,struct iguana_block *block,int32 { hdrsi = (height / coin->chain->bundlesize); bundlei = (height % coin->chain->bundlesize); - if ( hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 ) + if ( hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 && bits256_nonz(block->RO.hash2) != 0 ) { bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; + bp->hash2[bundlei] = block->RO.hash2; iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); if ( bp->speculative != 0 ) bp->speculative[bundlei] = block->RO.hash2; @@ -1358,9 +1363,10 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc memset(prevhash2.bytes,0,sizeof(prevhash2)); for (i=match=0; ichain->bundlesize; i++) { - bp = 0, bundlei = -2; + //fprintf(stderr,"i.%d of %d bundleset\n",i,n); if ( bits256_cmp(zblocks[i].RO.prev_block,coin->blocks.hwmchain.RO.hash2) == 0 ) { + bp = 0, bundlei = -2; if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) != 0 ) { if ( firstbp == 0 ) @@ -1369,22 +1375,14 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc coin->longestchain = block->height+1; _iguana_chainlink(myinfo,coin,block); } - //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(zblocks[i].RO.prev_block,prevhash2) == 0 ) - { - bp = 0; bundlei = -2; - if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i])) != 0 ) - { - //printf("found bp.%p i.%d of %d\n",bp,i,n); - } //else printf("didnt find in i.%d of %d\n",i,n); + //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]):"()"); } - iguana_blockQ("recvhdr",coin,bp,bundlei,zblocks[i].RO.hash2,0); - /*bp = 0, bundlei = -2; + 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].RO.prev_block)) != 0 ) + if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,zblocks[i].RO.prev_block)) != 0 ) + //if ( (bp= iguana_bundlefind(myinfo,coin,&block,&bundlei,(struct iguana_block *)&zblocks[i].RO.prev_block)) != 0 ) { if ( bundlei < coin->chain->bundlesize-1 ) bundlei++; @@ -1395,7 +1393,6 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc } } } - printf("i.%d of %d [%d]: %s\n",i,n,bundlei,bits256_str(str,zblocks[i].RO.prev_block));*/ if ( bp != 0 ) { if ( firstbp == 0 ) @@ -1403,10 +1400,10 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc else if ( bp == firstbp ) match++; bp->dirty++; - if ( bundlei >= 0 && bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 ) + if ( bp->issued[bundlei] == 0 )//&& coin->RTheight > 0 ) { bp->issued[bundlei] = 1; - iguana_blockQ("recvhdr",coin,bp,bundlei,zblocks[i].RO.hash2,0); + iguana_blockQ("recvhdr",coin,bp,bundlei,block->RO.hash2,0); } } prevhash2 = zblocks[i].RO.hash2; @@ -1424,7 +1421,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc }*/ if ( firstbp != 0 && (addr= req->addr) != 0 && n >= coin->chain->bundlesize ) { - addr->RThashes[0] = firstbp->bundlehash2; + addr->RThashes[0] = firstbp->hash2[0]; for (i=1; ichain->bundlesize; i++) { iguana_serialize_block(myinfo,coin->chain,&addr->RThashes[i],serialized,(struct iguana_block *)&zblocks[i]); @@ -1462,7 +1459,7 @@ void iguana_autoextend(struct supernet_info *myinfo,struct iguana_info *coin,str bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); } - //char str[65],str2[65]; printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->bundlehash2),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight); + //char str[65],str2[65]; printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight); if ( newbp->queued == 0 ) iguana_bundleQ(myinfo,coin,newbp,1000); } @@ -1496,7 +1493,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str { bp->dirty++; bp->hdrtime = (uint32_t)time(NULL); - blockhashes[0] = bp->bundlehash2; + blockhashes[0] = bp->hash2[0]; //iguana_blockQ("recvhash0",coin,bp,0,blockhashes[0],1); if ( num >= coin->chain->bundlesize ) { @@ -1544,7 +1541,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str bp->blocks[i] = iguana_blockhashset("recvhashes3",coin,bp->bundleheight+i,blockhashes[i],1); //printf("speculate new issue [%d:%d]\n",bp->hdrsi,i); } - bp->speculative[0] = bp->bundlehash2; + bp->speculative[0] = bp->hash2[0]; bp->numspec = (num <= bp->n+1) ? num : bp->n+1; if ( bp == coin->current && (addr= req->addr) != 0 ) { @@ -1561,10 +1558,10 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str { if ( (bp= coin->bundles[i]) != 0 )//&& bp->emitfinish > 1 ) { - blockhashes[0] = bp->bundlehash2; + blockhashes[0] = bp->hash2[0]; vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes)); if ( 0 && i == starti ) - printf("vcalc.(%s) [%d].(%s)\n",bits256_str(str,allhash),bp->hdrsi,bits256_str(str2,bp->bundlehash2)); + printf("vcalc.(%s) [%d].(%s)\n",bits256_str(str,allhash),bp->hdrsi,bits256_str(str2,bp->hash2[0])); if ( bits256_cmp(allhash,bp->allhash) == 0 ) { if ( 0 && bp->speculative == 0 ) @@ -1728,7 +1725,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig { printf("reissue hdrs request for [%d]\n",bp->hdrsi); bp->hdrtime = (uint32_t)time(NULL); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->bundlehash2))); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hash2[0]))); } if ( (block= iguana_blockhashset("recvblock",coin,-1,origblock->RO.hash2,1)) != 0 ) { @@ -1771,9 +1768,9 @@ int32_t iguana_blockreq(struct iguana_info *coin,int32_t height,int32_t priority int32_t hdrsi,bundlei; struct iguana_bundle *bp; hdrsi = height / coin->chain->bundlesize; bundlei = height % coin->chain->bundlesize; - if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 ) + if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_nonz(bp->hash2[bundlei]) != 0 ) { - iguana_blockQ("blockreq",coin,bp,bundlei,bp->hashes[bundlei],priority); + iguana_blockQ("blockreq",coin,bp,bundlei,bp->hash2[bundlei],priority); return(height); } return(-1); @@ -1808,7 +1805,7 @@ int32_t iguana_reqblocks(struct supernet_info *myinfo,struct iguana_info *coin) bp->blocks[bundlei] = iguana_blockfind("fixit",coin,bp->hashes[bundlei]); }*/ bundlei = (coin->blocks.hwmchain.height+1) % coin->chain->bundlesize; - if ( (next= bp->blocks[bundlei]) != 0 || (next= iguana_blockfind("reqblocks",coin,bp->hashes[bundlei])) != 0 ) + if ( (next= bp->blocks[bundlei]) != 0 || (next= iguana_blockfind("reqblocks",coin,bp->hash2[bundlei])) != 0 ) { if ( bits256_nonz(next->RO.prev_block) > 0 ) _iguana_chainlink(myinfo,coin,next); @@ -1886,7 +1883,7 @@ int32_t iguana_reqblocks(struct supernet_info *myinfo,struct iguana_info *coin) bundlei = (coin->blocks.hwmchain.height+1) % coin->chain->bundlesize; if ( bp != 0 && bits256_nonz(hash2) == 0 ) { - hash2 = bp->hashes[bundlei]; + hash2 = bp->hash2[bundlei]; if ( bits256_nonz(hash2) == 0 && bp->speculative != 0 ) { hash2 = bp->speculative[bundlei]; @@ -1910,7 +1907,7 @@ int32_t iguana_reqblocks(struct supernet_info *myinfo,struct iguana_info *coin) if ( 1 && (rand() % 100000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) printf("%s %s MAIN.%d t %.3f lag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,lag); } - if ( 0 && bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) + if ( 0 && bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hash2[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) { int32_t j; //memset(bp->hashes[bundlei].bytes,0,sizeof(bp->hashes[bundlei])); @@ -1921,8 +1918,8 @@ int32_t iguana_reqblocks(struct supernet_info *myinfo,struct iguana_info *coin) { bp->issued[bundlei+1+j] = 1;//(uint32_t)time(NULL); printf("MAINCHAIN skip issue %d\n",bp->bundleheight+bundlei+1+j); - if ( bits256_nonz(bp->hashes[bundlei+1+j]) != 0 ) - iguana_blockQ("mainskip",coin,bp,bundlei+1+j,bp->hashes[bundlei+1+j],1); + if ( bits256_nonz(bp->hash2[bundlei+1+j]) != 0 ) + iguana_blockQ("mainskip",coin,bp,bundlei+1+j,bp->hash2[bundlei+1+j],1); else if ( bp->speculative != 0 && bundlei+1+j < bp->numspec ) iguana_blockQ("mainskip",coin,bp,bundlei+1+j,bp->speculative[bundlei+1+j],1); } @@ -2008,17 +2005,15 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) if ( now > bp->issuetime+lag && now > bp->hdrtime+3 ) { bp->hdrtime = now; + if ( 0 && bp == coin->current ) + printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount); if ( bp->issuetime == 0 ) coin->numpendings++; - init_hexbytes_noT(hashstr,bp->bundlehash2.bytes,sizeof(bits256)); - if ( bits256_nonz(bp->bundlehash2) == 0 ) - printf("null hdrsi.%d hash0?\n",bp->hdrsi); + init_hexbytes_noT(hashstr,bp->hash2[0].bytes,sizeof(bits256)); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); - if ( 0 && bp == coin->current ) - printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d %s\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount,hashstr); if ( bp == coin->current ) { - init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); + init_hexbytes_noT(hashstr,bp->hash2[0].bytes,sizeof(bits256)); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); //printf("%s issue HWM HDRS [%d] %s\n",coin->symbol,bp->hdrsi,hashstr); if ( coin->blocks.hwmchain.height > 10 ) @@ -2032,9 +2027,9 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) //printf("hdrsi.%d reqHDR.(%s) numhashes.%d\n",bp->hdrsi,hashstr,bp->numhashes); if ( 1 ) { - iguana_blockQ("reqhdrs0",coin,bp,0,bp->bundlehash2,1); - if ( bits256_nonz(bp->hashes[1]) > 0 ) - iguana_blockQ("reqhdrs1",coin,bp,1,bp->hashes[1],1); + iguana_blockQ("reqhdrs0",coin,bp,0,bp->hash2[0],1); + if ( bits256_nonz(bp->hash2[1]) > 0 ) + iguana_blockQ("reqhdrs1",coin,bp,1,bp->hash2[1],1); } n++; bp->hdrtime = bp->issuetime = (uint32_t)time(NULL); @@ -2194,7 +2189,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) iguana_send(coin,addr,serialized,datalen); addr->pendhdrs++; flag++; - } else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued); + } //else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued); } //free_queueitem(hashstr); //return(flag); diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 6f8d53a24..b10d52b2b 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -699,11 +699,11 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co //fprintf(stderr,"balancehash add [%d]\n",bp->hdrsi); vupdate_sha256(balancehash.bytes,&vstate,(void *)Aptr,sizeof(*Aptr) * numpkinds); vupdate_sha256(balancehash.bytes,&vstate,(void *)Uptr,sizeof(*Uptr) * numunspents); - vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hashes,sizeof(bp->bundlehash2) * bp->n); + vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hash2,sizeof(bp->bundlehash2) * bp->n); } crc = calc_crc32(crc,(void *)Aptr,(int32_t)(sizeof(*Aptr) * numpkinds)); crc = calc_crc32(crc,(void *)Uptr,(int32_t)(sizeof(*Uptr) * numunspents)); - crc = calc_crc32(crc,(void *)bp->hashes,(int32_t)(sizeof(bp->bundlehash2) * bp->n)); + crc = calc_crc32(crc,(void *)bp->hash2,(int32_t)(sizeof(bp->bundlehash2) * bp->n)); } //else printf("missing hdrs.[%d] data.%p num.(%u %d) %p %p\n",i,bp->ramchain.H.data,numpkinds,numunspents,Aptr,Uptr); } } else crc = filecrc; @@ -756,7 +756,7 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co if ( block->height > coin->blocks.hwmchain.height ) { char str[65]; - printf("set hwmchain.%d <- %s %p\n",block->height,bits256_str(str,bp->hashes[bp->n-1]),block); + printf("set hwmchain.%d <- %s %p\n",block->height,bits256_str(str,bp->hash2[bp->n-1]),block); iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); } } @@ -878,7 +878,7 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi { vupdate_sha256(balancehash.bytes,&vstate,(void *)Aptr,sizeof(*Aptr)*numpkinds); vupdate_sha256(balancehash.bytes,&vstate,(void *)Uptr,sizeof(*Uptr)*numunspents); - vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hashes,sizeof(bp->bundlehash2)*bp->n); + vupdate_sha256(allbundles.bytes,&bstate,(void *)bp->hash2,sizeof(bp->bundlehash2)*bp->n); } else if ( iter == 1 ) { @@ -1169,8 +1169,8 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c { char str[65]; if ( coin->chain->fixit != 0 ) - printf("validate %s.[%d:%d] %s\n",coin->symbol,bp->hdrsi,i,bits256_str(str,bp->hashes[i])); - if ( (len= iguana_peerblockrequest(myinfo,coin,blockspace,max,0,bp->hashes[i],1)) < 0 ) + printf("validate %s.[%d:%d] %s\n",coin->symbol,bp->hdrsi,i,bits256_str(str,bp->hash2[i])); + if ( (len= iguana_peerblockrequest(myinfo,coin,blockspace,max,0,bp->hash2[i],1)) < 0 ) { errs++; //fprintf(stderr,"-%s.[%d:%d] ",coin->symbol,bp->hdrsi,i); @@ -1180,7 +1180,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c } else { - vupdate_sha256(validatehash.bytes,&vstate,bp->hashes[i].bytes,sizeof(bp->hashes[i])); + vupdate_sha256(validatehash.bytes,&vstate,bp->hash2[i].bytes,sizeof(bp->hash2[i])); total += len, totalvalidated++; } } diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index d8addae0f..ae2ac1738 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -381,7 +381,7 @@ struct iguana_bundle struct iguana_block *blocks[IGUANA_MAXBUNDLESIZE]; uint8_t *speculativecache[IGUANA_MAXBUNDLESIZE],haveblock[IGUANA_MAXBUNDLESIZE/3+1]; uint32_t issued[IGUANA_MAXBUNDLESIZE],firsttxidinds[IGUANA_MAXBUNDLESIZE]; - bits256 prevbundlehash2,bundlehash2,hashes[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash; + bits256 prevbundlehash2,bundlehash2,hash2[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash; struct iguana_ramchain ramchain; uint8_t red,green,blue; struct iguana_spendvector *tmpspends; int32_t numtmpspends; uint64_t *weights,supply; int32_t numweights;