From 11e8283a18e9154a544cef62cb9824ad22c325f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Sep 2016 06:30:14 -0300 Subject: [PATCH] Merge branch 'master' into release/v0.1 --- crypto777/OS_nonportable.c | 4 ++-- iguana/iguana_bundles.c | 2 +- iguana/iguana_ramchain.c | 11 ++++++----- iguana/iguana_recv.c | 10 +++++----- iguana/iguana_unspents.c | 20 ++++++++++++-------- includes/iguana_structs.h | 4 ++-- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/crypto777/OS_nonportable.c b/crypto777/OS_nonportable.c index 24ca8de0d..56a7a8258 100755 --- a/crypto777/OS_nonportable.c +++ b/crypto777/OS_nonportable.c @@ -47,12 +47,12 @@ void *OS_nonportable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,l #include #include -#include +/*#include static uint32_t __inline __builtin_clzll(uint64_t x) { unsigned long r = 0; _BitScanReverse64(&r, x); return (63-r); -} +}*/ void usleep(int32_t micros) { diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 936001732..af78551e9 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -266,7 +266,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo bp->n = bundlesize;//(bundlei < bundlesize-1) ? bundlesize : (bundlei + 1); if ( (setval= iguana_hash2set(coin,"blockadd",bp,bundlei,hash2)) == 0 ) { - if ( (block->hdrsi != bp->hdrsi || block->bundlei != bundlei) && (block->hdrsi != 0 || block->bundlei != 0) ) + if ( block->bundlei >= 0 && ((block->hdrsi != bp->hdrsi || block->bundlei != bundlei) && (block->hdrsi != 0 || block->bundlei != 0)) ) { char str[65]; printf("blockadd warning: %d[%d] main.%d prevent <- %d[%d] %s\n",block->hdrsi,block->bundlei,block->mainchain,bp->hdrsi,bundlei,bits256_str(str,hash2)); //iguana_blockunmark(coin,block,bp,bundlei,block->mainchain != 0); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 35cd6ede8..a8286da54 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1024,7 +1024,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits printf("ramchainsave no data ptr\n"); return(-1); } - if ( (checki= iguana_peerfname(coin,&hdrsi,ipbits==0?GLOBAL_DBDIR:GLOBAL_TMPDIR,fname,ipbits,hash2,prevhash2,ramchain->numblocks,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) + if ( (bundlei >= 0 && (checki= iguana_peerfname(coin,&hdrsi,ipbits==0?GLOBAL_DBDIR:GLOBAL_TMPDIR,fname,ipbits,hash2,prevhash2,ramchain->numblocks,1)) != bundlei) || bundlei >= coin->chain->bundlesize ) { printf(" wont save.(%s) bundlei.%d != checki.%d\n",fname,bundlei,checki); return(-1); @@ -1280,14 +1280,15 @@ int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfi struct iguana_bundle *bp; int32_t i; char fname[1024],str[65]; if ( hdrsi >= 0 && hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 ) { + iguana_volatilespurge(coin,&bp->ramchain); printf("%s delete bundle.[%d]\n",coin->symbol,hdrsi); + if ( iguana_bundlefname(coin,bp,fname) == 0 ) + OS_removefile(fname,0); if ( tmpfiles != 0 ) { for (i=0; in; i++) iguana_blockunmark(coin,bp->blocks[i],bp,i,1); } - if ( iguana_bundlefname(coin,bp,fname) == 0 ) - OS_removefile(fname,0); sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight), OS_removefile(fname,0); sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); @@ -2031,9 +2032,9 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru } if ( deletefile != 0 && block != 0 ) iguana_blockdelete(coin,block->RO.hash2,i); - if ( coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) + if ( 0 && coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) { - printf("reduce HWM height from %d to %d\n",coin->blocks.hwmchain.height,height); + printf("reduce %s HWM height from %d to %d\n",coin->symbol,coin->blocks.hwmchain.height,height); if ( (block= iguana_blockfind("unmark",coin,iguana_blockhash(coin,height))) != 0 ) iguana_blockcopy(coin->chain->zcash,coin->chain->auxpow,coin,(struct iguana_block *)&coin->blocks.hwmchain,block); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index a6b7e0fd3..c71408997 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -810,6 +810,8 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru //printf("getblockM update [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2)); if ( block != 0 ) { + if ( block->height < 0 ) + block->bundlei = -1; block->txvalid = 1; if ( block->fpipbits != 0 && block->fpos >= 0 ) { @@ -1077,12 +1079,9 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i } } if ( bp->blocks[bundlei] == 0 ) - { firstflag = 1; - bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; - } - bp->blocks[bundlei] = block; + //bp->blocks[bundlei] = block; + //bp->hashes[bundlei] = block->RO.hash2; iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); if ( firstflag != 0 && bp->emitfinish == 0 ) { @@ -1127,6 +1126,7 @@ void iguana_bundle_set(struct iguana_info *coin,struct iguana_block *block,int32 { bp->blocks[bundlei] = block; bp->hashes[bundlei] = block->RO.hash2; + iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); if ( bp->speculative != 0 ) bp->speculative[bundlei] = block->RO.hash2; //char str[65]; printf("SET %s ht.%d in [%d:%d]\n",bits256_str(str,block->RO.hash2),height,hdrsi,bundlei); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index c49ace449..2dbf20860 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -382,7 +382,11 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout,uint8_t *rmd160,uint8_t *pubkey33) { +<<<<<<< HEAD char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; +======= + char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; +>>>>>>> master memset(outpt,0,sizeof(*outpt)); outpt->txid = txid; outpt->vout = vout; @@ -840,10 +844,10 @@ int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info * //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); //return(iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,height,minconf,coin->longestchain,U[unspentind].value)); /*if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 ) - { - char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",outpt.hdrsi,outpt.unspentind,bits256_str(str,txid)); - return(1); - } else return(0);*/ + { + char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",outpt.hdrsi,outpt.unspentind,bits256_str(str,txid)); + return(1); + } else return(0);*/ return(0); } printf("iguana_unspent_check: couldnt find (%d %d)\n",outpt.hdrsi,outpt.unspentind); @@ -1366,9 +1370,9 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info { iguana_volatilespurge(coin,&bp->ramchain); /*sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); - OS_removefile(fname,0); - sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); - OS_removefile(fname,0);*/ + OS_removefile(fname,0); + sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); + OS_removefile(fname,0);*/ iguana_volatilesmap(coin,&bp->ramchain); } total = 0; @@ -1512,7 +1516,7 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co if ( counts[ind] > 0 ) { qsort(&table[offsets[ind] * UTXOADDR_ITEMSIZE],counts[ind],UTXOADDR_ITEMSIZE,_utxoaddr_cmp); -continue; + continue; for (j=0; j