From 2d4bdac755588d8878c540432d4935245a9d5554 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 10:17:11 -0300 Subject: [PATCH 01/41] test --- iguana/iguana_bundles.c | 4 ++- iguana/iguana_realtime.c | 38 +++++++++++---------- iguana/iguana_recv.c | 5 +-- iguana/iguana_unspents.c | 70 ++++++++++++++++++++++----------------- includes/iguana_funcs.h | 2 +- includes/iguana_structs.h | 2 +- 6 files changed, 68 insertions(+), 53 deletions(-) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index e45e9eefa..7da6a2191 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -221,10 +221,12 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo printf("bp.[%d]->blocks[%d] mismatch %p != %p\n",bp->hdrsi,bundlei,bp->blocks[bundlei],block); if ( coin->RTheight > 0 && bp->bundleheight+bundlei > coin->firstRTheight ) { + if ( bundlei > 0 ) + bundlei--; if ( (block= iguana_blockfind("reset",coin,bp->hashes[0])) != 0 ) { - printf("RESET HWM to %d\n",coin->firstRTheight); iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); + printf("RESET HWM to %d ht.%d\n",bp->bundleheight+bundlei,block->height); return(-1); } } diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index af6ce89d5..06e9f016c 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -501,37 +501,41 @@ void iguana_RTreset(struct iguana_info *coin) void iguana_RTunmap(uint8_t *ptr,uint32_t len) { - munmap(&ptr[-sizeof(len)],len+sizeof(len)); + OS_releasemap(&ptr[-sizeof(len)],len+sizeof(len)); } -void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp) +void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp) { - FILE *fp; char fname[1024],str[65]; long filesize; uint8_t *ptr; uint32_t i,nonz,checklen; + FILE *fp; char fname[1024],str[65]; long filesize; uint8_t *ptr; uint32_t i,nonz,checknumtx,checklen; sprintf(fname,"%s/%s/RT/%s.raw",GLOBAL_TMPDIR,coin->symbol,bits256_str(str,hash2)); OS_compatible_path(fname); if ( *recvlenp > 0 ) { if ( (fp= fopen(fname,"wb")) != 0 ) { - if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) - printf("error writing %s len.%d\n",bits256_str(str,hash2),*recvlenp); + if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) + printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); fclose(fp); //printf("created %s\n",fname); } else printf("couldnt create %s\n",fname); } else if ( *recvlenp == 0 ) { + if ( numtxp != 0 ) + *numtxp = 0; if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 ) { memcpy(&checklen,ptr,sizeof(checklen)); - if ( checklen == (int32_t)(filesize - sizeof(checklen)) ) + memcpy(&checknumtx,&ptr[sizeof(checklen)],sizeof(checknumtx)); + if ( checklen == (int32_t)(filesize - sizeof(checklen)) && checknumtx == *numtxp ) { for (i=nonz=0; ichain->bundlesize*10); for (height=lastheight-coin->chain->bundlesize*10; heightchain->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); + iguana_RTrawdata(coin,bp->hashes[bundlei],0,&recvlen,&numtx); // delete file } printf("end RTpurge.%d\n",lastheight); } void iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_block *block,int64_t polarity) { - struct iguana_txblock txdata; uint8_t *serialized; int32_t n,len; uint32_t recvlen = 0; - if ( (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) + struct iguana_txblock txdata; uint8_t *serialized; int32_t n,numtx,len; uint32_t recvlen = 0; + if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { - printf("cant load from tmpdir ht.%d polarity.%lld\n",block->height,(long long)polarity); + printf("cant load from tmpdir ht.%d polarity.%lld numtx.%d\n",block->height,(long long)polarity,coin->RTnumtx[offset]); return; } memset(&txdata,0,sizeof(txdata)); @@ -573,8 +577,8 @@ void iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_bloc iguana_memreset(&coin->RTrawmem), iguana_memreset(&coin->RTmem), iguana_memreset(&coin->RThashmem); if ( (n= iguana_gentxarray(coin,&coin->RTrawmem,&txdata,&len,serialized,recvlen)) > 0 ) { - iguana_RTramchaindata(coin,&coin->RTmem,&coin->RThashmem,polarity,block,coin->RTrawmem.ptr,block->RO.txn_count); - } else printf("gentxarray n.%d RO.txn_count.%d recvlen.%d\n",n,block->RO.txn_count,recvlen); + iguana_RTramchaindata(coin,&coin->RTmem,&coin->RThashmem,polarity,block,coin->RTrawmem.ptr,numtx); + } else printf("gentxarray n.%d RO.txn_count.%d recvlen.%d\n",n,numtx,recvlen); } struct iguana_block *iguana_RTblock(struct iguana_info *coin,int32_t height) @@ -596,7 +600,7 @@ void iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) offset = block->height - coin->firstRTheight; printf("%s RTblockadd.%d offset.%d\n",coin->symbol,block->height,offset); if ( coin->RTrawdata[offset] == 0 ) - coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset]); + coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset]); coin->RTblocks[offset] = block; iguana_RTiterate(coin,offset,block,1); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 0fea12557..de059258c 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -310,7 +310,7 @@ void iguana_bundletime(struct iguana_info *coin,struct iguana_bundle *bp,int32_t void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen) { - struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65]; + struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag,numtx; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65]; if ( recvlen < 0 || recvlen > IGUANA_MAXPACKETSIZE ) { printf("iguana_getblockM: illegal recvlen.%d\n",recvlen); @@ -495,7 +495,8 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i }*/ } //else printf("cant save block\n"); } - iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen); + numtx = origtxdata->zblock.RO.txn_count; + iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx); req->zblock = txdata->zblock; if ( coin->virtualchain != 0 ) printf("%s recvlen.%d ipbits.%x prev.(%s)\n",coin->symbol,req->zblock.RO.recvlen,req->zblock.fpipbits,bits256_str(str,txdata->zblock.RO.prev_block)); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 3c4bc5147..460a601db 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -939,7 +939,7 @@ struct iguana_utxoaddr *iguana_utxoaddrfind(int32_t createflag,struct iguana_inf return(utxoaddr); } -int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp,int32_t maketable,struct iguana_utxoaddr **prevp) +int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_utxoaddr **prevp) { struct iguana_utxoaddr *utxoaddr; uint32_t unspentind,pkind; struct iguana_ramchaindata *rdata=0; struct iguana_pkhash *P; struct iguana_unspent *U; struct iguana_utxo *U2=0; int64_t value,balance = 0; if ( bp == 0 || (rdata= bp->ramchain.H.data) == 0 || (U2= bp->ramchain.Uextras) == 0 ) @@ -960,21 +960,18 @@ int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp else { balance += value; - if ( maketable != 0 ) + if ( (pkind= U[unspentind].pkind) < rdata->numpkinds && pkind > 0 ) { - if ( (pkind= U[unspentind].pkind) < rdata->numpkinds && pkind > 0 ) + if ( (utxoaddr= iguana_utxoaddrfind(1,coin,bp->hdrsi,pkind,P[pkind].rmd160,prevp)) != 0 ) { - if ( (utxoaddr= iguana_utxoaddrfind(1,coin,bp->hdrsi,pkind,P[pkind].rmd160,prevp)) != 0 ) - { - //printf("%.8f ",dstr(value)); - utxoaddr->histbalance += value; - } - else printf("cant find pkind.%u for unspentind.%u hdrsi.%d\n",pkind,unspentind,bp->hdrsi); - } else printf("illegal pkind.%u for unspentind.%u hdrsi.%d\n",pkind,unspentind,bp->hdrsi); - } + //printf("%.8f ",dstr(value)); + utxoaddr->histbalance += value; + } else printf("cant find pkind.%u for unspentind.%u hdrsi.%d\n",pkind,unspentind,bp->hdrsi); + } else printf("illegal pkind.%u for unspentind.%u hdrsi.%d\n",pkind,unspentind,bp->hdrsi); } } // else printf("[%d] u%u spent %.8f\n",bp->hdrsi,unspentind,dstr(value)); } + printf("[%d %.8f] ",bp->hdrsi,dstr(balance)); return(balance); } @@ -1003,25 +1000,6 @@ static int _utxoaddr_cmp(const void *a,const void *b) #undef item_b } -void iguana_utxoaddr_purge(struct iguana_info *coin) -{ - struct iguana_utxoaddr *utxoaddr,*tmp; - if ( coin->utxoaddrs != 0 ) - { - printf("free %s utxoaddrs\n",coin->symbol); - HASH_ITER(hh,coin->utxoaddrs,utxoaddr,tmp) - { - if ( utxoaddr != 0 ) - { - HASH_DELETE(hh,coin->utxoaddrs,utxoaddr); - free(utxoaddr); - } - } - coin->utxoaddrs = 0; - } - memset(coin->utxoaddrhash.bytes,0,sizeof(coin->utxoaddrhash)); -} - int32_t iguana_utxoaddr_save(struct iguana_info *coin,char *fname,int64_t balance,uint32_t *counts,uint32_t *offsets,uint8_t *table) { FILE *fp; bits256 hash; int32_t retval = -1; @@ -1084,6 +1062,36 @@ int32_t iguana_utxoaddr_map(struct iguana_info *coin,char *fname) return(0); } +void iguana_utxoaddr_purge(struct iguana_info *coin) +{ + struct iguana_utxoaddr *utxoaddr,*tmp; + if ( coin->utxoaddrs != 0 ) + { + printf("free %s utxoaddrs\n",coin->symbol); + HASH_ITER(hh,coin->utxoaddrs,utxoaddr,tmp) + { + if ( utxoaddr != 0 ) + { + HASH_DELETE(hh,coin->utxoaddrs,utxoaddr); + free(utxoaddr); + } + } + coin->utxoaddrs = 0; + } + if ( coin->utxoaddrfileptr != 0 ) + { + OS_releasemap(coin->utxoaddrfileptr,coin->utxoaddrfilesize); + coin->utxoaddrfileptr = 0; + coin->utxoaddrtable = 0; + coin->utxoaddroffsets = 0; + } + memset(coin->utxoaddrhash.bytes,0,sizeof(coin->utxoaddrhash)); + coin->histbalance = 0; + coin->utxoaddrlastcount = 0; + coin->utxoaddrind = 0; + coin->utxoaddrfilesize = 0; +} + int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *coin,int32_t lastheight,int64_t *unspents,int32_t max,struct iguana_utxoaddr *utxoaddr) { static int32_t good,bad; @@ -1203,7 +1211,7 @@ int64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coi { if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight ) { - balance += iguana_bundle_unspents(coin,bp,1,&last); + balance += iguana_bundle_unspents(coin,bp,&last); fprintf(stderr,"(%d %.8f) ",hdrsi,dstr(balance)); height = bp->bundleheight + bp->n; } diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index de588505d..b2ae6ac81 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -544,7 +544,7 @@ void iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t p void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout); void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,bits256 txid,int32_t vout,int64_t value); void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block); -void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp); +void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp); void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp); void iguana_update_balances(struct iguana_info *coin); void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp); diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index a01ce1413..d9f90988a 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -428,7 +428,7 @@ struct iguana_info int64_t histbalance,RTcredits,RTdebits; void *utxoaddrfileptr; long utxoaddrfilesize; uint32_t utxoaddrlastcount,*utxoaddroffsets; uint8_t *utxoaddrtable; bits256 utxoaddrhash; - struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536]; + struct iguana_block *RTblocks[65536]; uint8_t *RTrawdata[65536]; int32_t RTrecvlens[65536],RTnumtx[65536]; }; struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; }; From 4e20638582befe37dc04b3d1d6fe0a7ead8507f0 Mon Sep 17 00:00:00 2001 From: Shailesh Date: Wed, 17 Aug 2016 15:26:09 +0200 Subject: [PATCH 02/41] Update commands for android build --- crypto777/m_android | 11 +++++++++-- iguana/m_android | 22 ++++++++++++++++------ iguana/secp256k1/m_android | 4 +++- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/crypto777/m_android b/crypto777/m_android index b84f37742..d58e90d65 100755 --- a/crypto777/m_android +++ b/crypto777/m_android @@ -1,2 +1,9 @@ -git pull -cd iguana; ./m_android; cd .. +#!/bin/bash + +if [[ $# -eq 0 ]]; then + git pull + #cd iguana; ./m_android; cd .. +fi +echo "Compiling crypto777..." +$CC2 -c -O2 *.c jpeg/*.c jpeg/unix/*.c +rm -f ../agents/libcrypto777.a; $AR rcu ../agents/libcrypto777.a *.o diff --git a/iguana/m_android b/iguana/m_android index e723b2921..83945b909 100755 --- a/iguana/m_android +++ b/iguana/m_android @@ -1,8 +1,18 @@ +#!/bin/bash + rm ../agents/iguana *.o -git pull -cd secp256k1; ./m_unix; cd .. -$CC2 -g -Wno-deprecated -c -O2 *.c databases/iguana_DB.c -$CC2 -g -Wno-deprecated -c main.c iguana777.c iguana_bundles.c -#$CC2 -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lcurl -lssl -lcrypto -lpthread -lm #../includes/libsecp256k1.a -lgmp -$CC2 -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lpthread -lm +if [[ $# -eq 0 ]]; then + git pull +fi + +echo "Compiling libsecp256k1.a ..." +cd secp256k1; ./m_android; cd .. + +#$CC2 -o ../agents/iguana -O2 *.c ../basilisk/*.c -I $NDK/platforms/android-19/arch-arm/usr/include ../agents/libcrypto777.a ../agents/libsecp256k1.a ../OSlibs/android/lib/libcurl.a -lssl -lcrypto -lm -lc -lz + +echo "Compiling iguana ... " +#$CC2 -o ../agents/iguana -O2 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c -I ./secp256k1/include -I $NDK/platforms/android-21/arch-arm/usr/include ../agents/libcrypto777.a ../agents/libsecp256k1.a ../OSlibs/android/lib/libcurl.a -L../OSlibs/android/lib/ -lssl -lcrypto -L$NDK/platforms/android-21/arch-arm/usr/lib -lm -lc -lz -nostdlib -lgcc +$CC2 -g -Wno-deprecated -O2 -c *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c +$CC2 -g -Wno-deprecated -c main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c +$CC2 -g -o ../agents/iguana -O2 *.o ../agents/libcrypto777.a -lm diff --git a/iguana/secp256k1/m_android b/iguana/secp256k1/m_android index 2409bd7f4..c9c3fc441 100755 --- a/iguana/secp256k1/m_android +++ b/iguana/secp256k1/m_android @@ -1 +1,3 @@ -$CC2 -c -o ../secp256k1.o -I. -I./src -I./include -I./src -O3 -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -fvisibility=hidden -DHAVE_CONFIG_H src/secp256k1.c +#$CC -c -o ../secp256k1.o -I. -I./src -I /Newpub/android-ndk-r9b/platforms/android-19/arch-arm/usr/include -I./include -I./src -O3 -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -fvisibility=hidden -DHAVE_CONFIG_H src/secp256k1.c + +$CC2 -c -o ../sec256k1.o -I. -I./src -I./include -I./src -O3 -W -std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings -fvisibility=hidden -DHAVE_CONFIG_H src/secp256k1.c From 35c368af7cbcba1c8f0cf8a662f44696a605c086 Mon Sep 17 00:00:00 2001 From: Shailesh Date: Wed, 17 Aug 2016 15:27:33 +0200 Subject: [PATCH 03/41] Add missing header file for crypto777 and iguana777 --- crypto777/inet.c | 1 + iguana/iguana777.h | 1 + 2 files changed, 2 insertions(+) diff --git a/crypto777/inet.c b/crypto777/inet.c index 87113f392..850ee6dee 100755 --- a/crypto777/inet.c +++ b/crypto777/inet.c @@ -19,6 +19,7 @@ #ifndef crypto777_inet_h #define crypto777_inet_h #include "OS_portable.h" +#include #ifdef _WIN32 #define in6_addr sockaddr diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 9e844484c..18e594bd3 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -31,6 +31,7 @@ struct supernet_info; struct exchange_info; +#include #include "../crypto777/OS_portable.h" #include "../datachain/datachain.h" From adf4ef7cfda2212298da5e2402cde21a08c03bf4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 10:28:57 -0300 Subject: [PATCH 04/41] test --- iguana/iguana_bundles.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 7da6a2191..c5dba3c7c 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -228,7 +228,11 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); printf("RESET HWM to %d ht.%d\n",bp->bundleheight+bundlei,block->height); return(-1); - } + } else printf("couldnt find block at %d\n",bp->bundleheight+bundlei); + } + else if ( bundlei > 0 ) + { + bp->blocks[bundlei] = 0; } iguana_blockunmark(coin,block,bp,bundlei,1); return(-1); From f1aef9c63c2c7b41d3f18466a9b3fdff05c4dd1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 10:38:17 -0300 Subject: [PATCH 05/41] test --- iguana/iguana777.c | 3 ++- iguana/iguana_unspents.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 99cb7e32c..dcad66a03 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -536,7 +536,8 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int coin->spendvectorsaved = (uint32_t)time(NULL); coin->spendvalidated = 0; printf("%s UTXOGEN spendvectorsaved <- %u\n",coin->symbol,coin->spendvectorsaved); - iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); + if ( iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize) < 0 ) + iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); } else { diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 460a601db..e3b005c68 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1311,14 +1311,17 @@ continue; OS_removefile(fname,0); OS_removefile(fname2,0); } - coin->RTheight = height; - if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) - iguana_RTnewblock(coin,block); - return(coin->histbalance); + else + { + coin->RTheight = height; + if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) + iguana_RTnewblock(coin,block); + return(coin->histbalance); + } } } free(counts); - return(0.); + return(-1.); } void iguana_utxoaddrs_purge(struct iguana_info *coin) From 724ef308b7c6eb3099f9c4a10c2ebb816bc3fbd8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 10:43:33 -0300 Subject: [PATCH 06/41] test --- iguana/iguana_unspents.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index e3b005c68..6fccbf56a 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1321,7 +1321,10 @@ continue; } } free(counts); - return(-1.); + sprintf(fname,"%s/%s/balancecrc.%d",GLOBAL_DBDIR,coin->symbol,height/coin->chain->bundlesize - 1); + OS_removefile(fname,0); + printf("return neg one remove %s\n",fname); + return(-1); } void iguana_utxoaddrs_purge(struct iguana_info *coin) From 45bb23b05a7205a66716e095bce99fa7dd70a388 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 10:50:32 -0300 Subject: [PATCH 07/41] test --- iguana/iguana_realtime.c | 4 ++-- iguana/iguana_unspents.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 06e9f016c..69f37ad24 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -527,14 +527,14 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 { memcpy(&checklen,ptr,sizeof(checklen)); memcpy(&checknumtx,&ptr[sizeof(checklen)],sizeof(checknumtx)); - if ( checklen == (int32_t)(filesize - sizeof(checklen)) && checknumtx == *numtxp ) + if ( checklen == (int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)) && checknumtx == *numtxp ) { for (i=nonz=0; isymbol,height), OS_portable_path(fname2); if ( iguana_utxoaddr_map(coin,fname2) != 0 ) { - if ( strcmp("BTCD",coin->symbol) == 0 ) + if ( strcmp("BTC",coin->symbol) != 0 ) errs = iguana_utxoaddr_validate(myinfo,coin,height); printf("nogen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); - if ( coin->histbalance > 0 ) + if ( errs == 0 && coin->histbalance > 0 ) { coin->RTheight = height; if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) From 63d367a72484ce92b16bb98ed87d3255bdd29705 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 11:34:13 -0300 Subject: [PATCH 08/41] test --- iguana/iguana_realtime.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 69f37ad24..02e1dfce3 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -516,26 +516,24 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); fclose(fp); - //printf("created %s\n",fname); + printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); } else printf("couldnt create %s\n",fname); } else if ( *recvlenp == 0 ) { - if ( numtxp != 0 ) - *numtxp = 0; if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 ) { memcpy(&checklen,ptr,sizeof(checklen)); memcpy(&checknumtx,&ptr[sizeof(checklen)],sizeof(checknumtx)); - if ( checklen == (int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)) && checknumtx == *numtxp ) + *numtxp = checknumtx; + if ( checklen == (int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)) )//&& checknumtx == *numtxp ) { for (i=nonz=0; iRTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { - printf("cant load from tmpdir ht.%d polarity.%lld numtx.%d\n",block->height,(long long)polarity,coin->RTnumtx[offset]); + printf("cant load from tmpdir ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); return; } memset(&txdata,0,sizeof(txdata)); @@ -598,9 +596,9 @@ void iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) if ( block != 0 ) { offset = block->height - coin->firstRTheight; - printf("%s RTblockadd.%d offset.%d\n",coin->symbol,block->height,offset); if ( coin->RTrawdata[offset] == 0 ) coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset]); + printf("%s RTblockadd.%d offset.%d numtx.%d len.%d\n",coin->symbol,block->height,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); coin->RTblocks[offset] = block; iguana_RTiterate(coin,offset,block,1); } From 35b43c2906fef74554333482ddfce3845e6eecf0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 11:36:04 -0300 Subject: [PATCH 09/41] test --- iguana/iguana_unspents.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index d4dd25fe2..7e092264b 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1167,6 +1167,7 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info } } free(unspents); + printf("validate errs.%d\n",errs); return(errs); } From 8f5ab91861768d00d7a2f5cc2336fb1bf6a9070b Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 11:42:45 -0300 Subject: [PATCH 10/41] test --- iguana/iguana_realtime.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 02e1dfce3..014a7ed53 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -468,7 +468,7 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_ { int32_t i; // fill in array element and update counters - if ( strcmp("BTC",coin->symbol) != 0 ) + if ( 0 && strcmp("BTC",coin->symbol) != 0 ) { for (i=0; i<20; i++) printf("%02x",rmd160[i]); @@ -480,7 +480,7 @@ void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t { char str[65],str2[65]; // fill in array element and update counters - if ( strcmp("BTC",coin->symbol) != 0 ) + if ( 0 && strcmp("BTC",coin->symbol) != 0 ) printf("%s vini.%d spend.(%s/v%d) %lld\n",bits256_str(str,txid),vini,bits256_str(str2,prev_hash),prev_vout,(long long)polarity); } @@ -488,7 +488,7 @@ void iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t p { char str[65]; // add to hashtable block <-> txids[] - if ( strcmp("BTC",coin->symbol) != 0 ) + if ( 0 && strcmp("BTC",coin->symbol) != 0 ) printf("%s txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",coin->symbol,bits256_str(str,txid),numvouts,numvins,version,locktime,timestamp,(long long)polarity); } @@ -516,7 +516,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); fclose(fp); - printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); + //printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); } else printf("couldnt create %s\n",fname); } else if ( *recvlenp == 0 ) @@ -565,6 +565,7 @@ void iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_bloc printf("cant load from tmpdir ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); return; } + printf("%s RTiterate.%lld offset.%d numtx.%d len.%d\n",coin->symbol,(long long)polarity,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); memset(&txdata,0,sizeof(txdata)); if ( coin->RTrawmem.ptr == 0 ) iguana_meminit(&coin->RTrawmem,"RTrawmem",0,IGUANA_MAXPACKETSIZE * 2,0); From ceca071e2920916419beecba95f48a90853d0383 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 11:50:24 -0300 Subject: [PATCH 11/41] test --- iguana/iguana_realtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 014a7ed53..32a668882 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -599,7 +599,7 @@ void iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) offset = block->height - coin->firstRTheight; if ( coin->RTrawdata[offset] == 0 ) coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset]); - printf("%s RTblockadd.%d offset.%d numtx.%d len.%d\n",coin->symbol,block->height,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); + //printf("%s RTblockadd.%d offset.%d numtx.%d len.%d\n",coin->symbol,block->height,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); coin->RTblocks[offset] = block; iguana_RTiterate(coin,offset,block,1); } @@ -611,7 +611,7 @@ void iguana_RTblocksub(struct iguana_info *coin,struct iguana_block *block) if ( block != 0 ) { offset = block->height - coin->firstRTheight; - printf("%s RTblocksub.%d offset.%d\n",coin->symbol,block->height,offset); + //printf("%s RTblocksub.%d offset.%d\n",coin->symbol,block->height,offset); iguana_RTiterate(coin,offset,block,-1); if ( coin->RTrawdata[offset] != 0 && coin->RTrecvlens[offset] != 0 ) iguana_RTunmap(coin->RTrawdata[offset],coin->RTrecvlens[offset]); From 8f8551f140fc3a9df29ebf5949fdee28713c814a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 14:18:38 -0300 Subject: [PATCH 12/41] test --- iguana/iguana_realtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 32a668882..5e4a47c2a 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -501,7 +501,7 @@ void iguana_RTreset(struct iguana_info *coin) void iguana_RTunmap(uint8_t *ptr,uint32_t len) { - OS_releasemap(&ptr[-sizeof(len)],len+sizeof(len)); + OS_releasemap(&ptr[-2*sizeof(len)],len+2*sizeof(len)); } void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp) From 6f77f429b148116e7608188abd4eb9edb8eec1e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 21:16:54 -0300 Subject: [PATCH 13/41] test --- iguana/iguana777.c | 3 +++ iguana/iguana777.h | 3 ++- iguana/iguana_unspents.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index dcad66a03..27bdfd82c 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -537,7 +537,10 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int coin->spendvalidated = 0; printf("%s UTXOGEN spendvectorsaved <- %u\n",coin->symbol,coin->spendvectorsaved); if ( iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize) < 0 ) + { + printf("call again \n"); iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); + } } else { diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 18e594bd3..959537910 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -19,6 +19,8 @@ #if (defined(_WIN32) || defined(__WIN32__)) && \ !defined(WIN32) && !defined(__SYMBIAN32__) #define WIN32 +#else +#include #endif //#define BTC2_VERSION @@ -31,7 +33,6 @@ struct supernet_info; struct exchange_info; -#include #include "../crypto777/OS_portable.h" #include "../datachain/datachain.h" diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 7e092264b..ffafcaf42 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1324,6 +1324,8 @@ continue; free(counts); sprintf(fname,"%s/%s/balancecrc.%d",GLOBAL_DBDIR,coin->symbol,height/coin->chain->bundlesize - 1); OS_removefile(fname,0); + sprintf(fname,"%s/%s/balancecrc.%d",GLOBAL_DBDIR,coin->symbol,height/coin->chain->bundlesize - 2); + OS_removefile(fname,0); printf("return neg one remove %s\n",fname); return(-1); } From 35698b1869361c2266f572dd0e50a29c9e4723d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 21:49:46 -0300 Subject: [PATCH 14/41] test --- iguana/coins/genbtc | 2 +- iguana/iguana777.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/iguana/coins/genbtc b/iguana/coins/genbtc index 22b9218d4..1d533725f 100755 --- a/iguana/coins/genbtc +++ b/iguana/coins/genbtc @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":8,\"endpend\":6,\"services\":129,\"maxpeers\":64,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":8,\"endpend\":6,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 27bdfd82c..d38be0020 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -686,6 +686,8 @@ void iguana_coinloop(void *arg) flag = 0; for (i=0; i 1 && (rand() % (n*100)) > 100 ) + continue; if ( (coin= coins[i]) != 0 ) { if ( coin->peers == 0 ) @@ -772,11 +774,13 @@ void iguana_coinloop(void *arg) } } //printf("%s flag.%d isRT.%d polltimeout.%d numranked.%d\n",coin->symbol,flag,coin->isRT,coin->polltimeout,coin->peers->numranked); - if ( flag == 0 && coin->isRT == 0 && coin->peers != 0 ) + /*if ( flag == 0 && coin->isRT == 0 && coin->peers != 0 ) usleep(coin->polltimeout*1000 + (coin->peers->numranked == 0)*1000000); else if ( coin->current != 0 && coin->current->hdrsi == coin->longestchain/coin->chain->bundlesize ) usleep(coin->polltimeout*5000 + 90000 + (coin->peers->numranked == 0)*1000000); - else usleep(coin->polltimeout*1000); + else usleep(coin->polltimeout*1000);*/ + if ( flag == 0 ) + usleep(10000); } } From 5320740b4130bff0a16fa4dbb25bee5aedd7201f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:07:59 -0300 Subject: [PATCH 15/41] test --- iguana/iguana777.c | 6 ++++++ iguana/iguana_bundles.c | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index d38be0020..6a81a657b 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -416,6 +416,12 @@ int32_t iguana_helperB(struct iguana_info *coin,int32_t helperid,struct iguana_b void iguana_update_balances(struct iguana_info *coin) { int32_t i,hdrsi,max; struct iguana_bundle *bp; char fname[1024]; + if ( coin->RTheight > 0 ) + { + printf("Need to restart iguana to generate new balances files\n"); + printf("RT dataset can expand past bundle boundary, so no need to update balance files now\n"); + return; + } max = coin->bundlescount; if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 && coin->RTheight == 0 ) max--; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index c5dba3c7c..7a24e2d5f 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -218,20 +218,20 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo } else { - printf("bp.[%d]->blocks[%d] mismatch %p != %p\n",bp->hdrsi,bundlei,bp->blocks[bundlei],block); if ( coin->RTheight > 0 && bp->bundleheight+bundlei > coin->firstRTheight ) { - if ( bundlei > 0 ) - bundlei--; - if ( (block= iguana_blockfind("reset",coin,bp->hashes[0])) != 0 ) + if ( bundlei > 1 ) + bundlei -= 2; + if ( bp->bundleheight+bundlei > coin->blocks.hwmchain.height && (block= iguana_blockfind("reset",coin,bp->hashes[0])) != 0 ) { iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); printf("RESET HWM to %d ht.%d\n",bp->bundleheight+bundlei,block->height); return(-1); - } else printf("couldnt find block at %d\n",bp->bundleheight+bundlei); + } //else printf("couldnt find block at %d\n",bp->bundleheight+bundlei); } else if ( bundlei > 0 ) { + printf("bp.[%d]->blocks[%d] mismatch %p != %p\n",bp->hdrsi,bundlei,bp->blocks[bundlei],block); bp->blocks[bundlei] = 0; } iguana_blockunmark(coin,block,bp,bundlei,1); From 8020c730bc96ae75b69e5b7a3416f8f229f19828 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:19:05 -0300 Subject: [PATCH 16/41] test --- iguana/iguana777.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 6a81a657b..39d89d889 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -479,7 +479,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int //if ( 1 || coin->PREFETCHLAG > 0 ) // data issues on slow systems // incr = 1; max = coin->bundlescount; - if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 ) + if ( 0 && coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 ) max--; if ( helperid < incr ) { @@ -786,7 +786,7 @@ void iguana_coinloop(void *arg) usleep(coin->polltimeout*5000 + 90000 + (coin->peers->numranked == 0)*1000000); else usleep(coin->polltimeout*1000);*/ if ( flag == 0 ) - usleep(10000); + usleep(100000); } } From 01586865be9c7acee9b8ff2368bbb77219604c89 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:22:34 -0300 Subject: [PATCH 17/41] test --- iguana/iguana777.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 39d89d889..5ef4fd66c 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -479,11 +479,11 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int //if ( 1 || coin->PREFETCHLAG > 0 ) // data issues on slow systems // incr = 1; max = coin->bundlescount; - if ( 0 && coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 ) + if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 ) max--; if ( helperid < incr ) { - for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); } while ( (n= iguana_utxofinished(coin)) < max ) From ad456a70e61b07b17100baa3f0492de84844c6a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:27:40 -0300 Subject: [PATCH 18/41] test --- iguana/iguana777.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 5ef4fd66c..6ad063de1 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -425,12 +425,12 @@ void iguana_update_balances(struct iguana_info *coin) max = coin->bundlescount; if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 && coin->RTheight == 0 ) max--; - if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) + if ( iguana_balancefinished(coin) <= max && iguana_spendvectorsaves(coin) == 0 ) { if ( coin->origbalanceswritten <= 1 ) hdrsi = 0; else hdrsi = coin->origbalanceswritten; - for (i=0; ibundles[i]) != 0 && bp != coin->current ) { iguana_volatilespurge(coin,&bp->ramchain); From 4112788d4dbe465b698a9c98a8ff97b739223e94 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:44:14 -0300 Subject: [PATCH 19/41] test --- iguana/iguana777.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 6ad063de1..65bc4f36c 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -425,12 +425,12 @@ void iguana_update_balances(struct iguana_info *coin) max = coin->bundlescount; if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 && coin->RTheight == 0 ) max--; - if ( iguana_balancefinished(coin) <= max && iguana_spendvectorsaves(coin) == 0 ) + if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) { if ( coin->origbalanceswritten <= 1 ) hdrsi = 0; else hdrsi = coin->origbalanceswritten; - for (i=0; i<=max; i++) + for (i=0; ibundles[i]) != 0 && bp != coin->current ) { iguana_volatilespurge(coin,&bp->ramchain); @@ -493,7 +493,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int } if ( helperid < incr ) { - for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); } while ( (n= iguana_convertfinished(coin)) < max ) From 8c2f2068f1e79d6e6c35d9c4b95e3340179a63b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:48:12 -0300 Subject: [PATCH 20/41] test --- iguana/iguana777.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 65bc4f36c..82ab245e7 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -399,7 +399,7 @@ int32_t iguana_helperB(struct iguana_info *coin,int32_t helperid,struct iguana_b printf("iguana_helperB unexpected null bp\n"); return(-1); } - if ( bp != coin->current ) + //if ( bp != coin->current ) { iguana_ramchain_prefetch(coin,&bp->ramchain,7); if ( convertflag == 0 ) @@ -496,7 +496,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int for (hdrsi=helperid; hdrsi<=max; hdrsi+=incr) num += iguana_helperB(coin,helperid,coin->bundles[hdrsi],convertflag); } - while ( (n= iguana_convertfinished(coin)) < max ) + while ( (n= iguana_convertfinished(coin)) <= max ) { //printf("helperid.%d convertfinished.%d vs max %d bundlescount.%d\n",helperid,n,max,coin->bundlescount); sleep(IGUANA_NUMHELPERS+3); From 9fd2aca7fb68e7e5674fef4467e08a399735dd51 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:51:41 -0300 Subject: [PATCH 21/41] test --- iguana/iguana777.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 82ab245e7..f03f114cd 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -493,10 +493,10 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int } if ( helperid < incr ) { - for (hdrsi=helperid; hdrsi<=max; hdrsi+=incr) + for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); } - while ( (n= iguana_convertfinished(coin)) <= max ) + while ( (n= iguana_convertfinished(coin)) < max ) { //printf("helperid.%d convertfinished.%d vs max %d bundlescount.%d\n",helperid,n,max,coin->bundlescount); sleep(IGUANA_NUMHELPERS+3); From 8921641dc2e79a3c08a2b2bf931760ba5435d0cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 22:59:21 -0300 Subject: [PATCH 22/41] test --- iguana/iguana777.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index f03f114cd..0a8e94b67 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -402,6 +402,7 @@ int32_t iguana_helperB(struct iguana_info *coin,int32_t helperid,struct iguana_b //if ( bp != coin->current ) { iguana_ramchain_prefetch(coin,&bp->ramchain,7); + printf("convert.%d [%d]\n",convertflag,bp->hdrsi); if ( convertflag == 0 ) { bp->converted = 1; @@ -425,7 +426,7 @@ void iguana_update_balances(struct iguana_info *coin) max = coin->bundlescount; if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 && coin->RTheight == 0 ) max--; - if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) + //if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) { if ( coin->origbalanceswritten <= 1 ) hdrsi = 0; @@ -483,7 +484,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int max--; if ( helperid < incr ) { - for (hdrsi=helperid; hdrsi<=max; hdrsi+=incr) + for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); } while ( (n= iguana_utxofinished(coin)) < max ) @@ -493,7 +494,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int } if ( helperid < incr ) { - for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); } while ( (n= iguana_convertfinished(coin)) < max ) From 968d43f9aad4d0c1c18bcb47364bc87ee05f7024 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 17 Aug 2016 23:52:28 -0300 Subject: [PATCH 23/41] test --- gecko/gecko.c | 8 ++++---- iguana/iguana777.c | 7 +------ iguana/iguana_recv.c | 24 ++++++++++++++++++++++-- iguana/iguana_unspents.c | 6 +++--- iguana/main.c | 2 +- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/gecko/gecko.c b/gecko/gecko.c index 1b6fb5754..871cd63a5 100755 --- a/gecko/gecko.c +++ b/gecko/gecko.c @@ -47,10 +47,10 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc longesthdrsi = virt->longestchain / virt->chain->bundlesize; if ( (bp= virt->bundles[hwmhdrsi]) != 0 ) { - iguana_RTspendvectors(myinfo,virt,bp); - iguana_RTramchainalloc("RTbundle",virt,bp); - iguana_update_balances(virt); - iguana_realtime_update(myinfo,virt); + //iguana_RTspendvectors(myinfo,virt,bp); + //iguana_RTramchainalloc("RTbundle",virt,bp); + //iguana_update_balances(virt); + //iguana_realtime_update(myinfo,virt); } if ( 0 && hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 ) { diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 0a8e94b67..87a0d70bf 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -402,7 +402,6 @@ int32_t iguana_helperB(struct iguana_info *coin,int32_t helperid,struct iguana_b //if ( bp != coin->current ) { iguana_ramchain_prefetch(coin,&bp->ramchain,7); - printf("convert.%d [%d]\n",convertflag,bp->hdrsi); if ( convertflag == 0 ) { bp->converted = 1; @@ -543,11 +542,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int coin->spendvectorsaved = (uint32_t)time(NULL); coin->spendvalidated = 0; printf("%s UTXOGEN spendvectorsaved <- %u\n",coin->symbol,coin->spendvectorsaved); - if ( iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize) < 0 ) - { - printf("call again \n"); - iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); - } + iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); } else { diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index de059258c..001011491 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -552,7 +552,7 @@ void iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,struct void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bits256 *blockhashes,int32_t n) { - struct iguana_bundlereq *req; int32_t i,num; + struct iguana_bundlereq *req; int32_t i,num,j,flag; struct iguana_bundle *bp; if ( addr != 0 ) { addr->recvhdrs++; @@ -576,7 +576,27 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi if ( coin->RTheight > 0 ) { for (i=1; icurrent) != 0 ) + { + for (j=0; jn; j++) + { + if ( j < bp->numspec && bp->speculative != 0 && bits256_cmp(bp->speculative[j],blockhashes[i]) == 0 ) + { + flag = 1; + break; + } + if ( bits256_cmp(bp->hashes[j],blockhashes[i]) == 0 ) + { + flag = 1; + break; + } + } + } + if ( flag == 0 ) + iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[i],0); + } } else if ( n > coin->chain->bundlesize ) iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[1],0); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index ffafcaf42..e968c3aef 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1122,7 +1122,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c } good++; if ( ((good + bad) % 1000) == 0 ) - printf("%s utxoaddr validate good.%d bad.%d\n",coin->symbol,good,bad); + printf("%s utxoaddr validate good.%d bad.%d | (if this is taking too long, just exit and restart iguana)\n",coin->symbol,good,bad); return(0); } @@ -1161,8 +1161,8 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info iguana_rwutxoaddr(0,ind,item,&UA); errs += iguana_utxoaddr_check(myinfo,coin,lastheight,unspents,max,&UA); total++; - if ( (total % 1000) == 0 ) - fprintf(stderr,"."); + //if ( (total % 1000) == 0 ) + // fprintf(stderr,"."); } } } diff --git a/iguana/main.c b/iguana/main.c index 9a938220d..c59f1c760 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -408,7 +408,7 @@ void mainloop(struct supernet_info *myinfo) //portable_mutex_lock(&myinfo->allcoins_mutex); HASH_ITER(hh,myinfo->allcoins,coin,tmp) { - if ( coin->current != 0 && coin->active != 0 && coin->started != 0 ) + if ( coin->RTheight == 0 && coin->current != 0 && coin->active != 0 && coin->started != 0 ) { isRT *= coin->isRT; if ( coin->peers != 0 ) From ba6af59033995a650a1c75c01fde6bddb3968979 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 00:03:55 -0300 Subject: [PATCH 24/41] test --- iguana/iguana777.c | 12 ++++++++++-- iguana/iguana_realtime.c | 10 +++++++--- iguana/iguana_unspents.c | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 87a0d70bf..bbda10db6 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -493,7 +493,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int } if ( helperid < incr ) { - for (hdrsi=helperid; hdrsi<=max; hdrsi+=incr) + for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); } while ( (n= iguana_convertfinished(coin)) < max ) @@ -542,7 +542,15 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int coin->spendvectorsaved = (uint32_t)time(NULL); coin->spendvalidated = 0; printf("%s UTXOGEN spendvectorsaved <- %u\n",coin->symbol,coin->spendvectorsaved); - iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize); + if ( iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize) < 0 ) + { + printf("retry utxoaddr_gen\n"); + if ( iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize) < 0 ) + { + printf("restart iguana: fatal error generating ledger file for %s\n",coin->symbol); + exit(1); + } + } } else { diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 5e4a47c2a..a4d1e2ce9 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -635,7 +635,7 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) iguana_RTpurge(coin,coin->firstRTheight); } n = (block->height - coin->RTheight) + 1; - for (i=0; iRTheight++) { height = (coin->RTheight + i); hdrsi = (height / coin->chain->bundlesize); @@ -644,9 +644,13 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) { iguana_RTblockadd(coin,addblock); coin->lastRTheight = addblock->height; - } else printf("missing RTaddblock at i.%d RTheight.%d vs %p %d\n",i,coin->RTheight,addblock,addblock!=0?addblock->height:-1); + } + else + { + printf("missing RTaddblock at i.%d RTheight.%d vs %p %d\n",i,coin->RTheight,addblock,addblock!=0?addblock->height:-1); + break; + } } - coin->RTheight += n; printf(">= RTnewblock RTheight %d prev %d\n",coin->RTheight,coin->lastRTheight); } else if ( block->height == coin->lastRTheight ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index e968c3aef..8475394a2 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1122,7 +1122,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c } good++; if ( ((good + bad) % 1000) == 0 ) - printf("%s utxoaddr validate good.%d bad.%d | (if this is taking too long, just exit and restart iguana)\n",coin->symbol,good,bad); + printf("%s utxoaddr validate good.%d bad.%d%s\n",coin->symbol,good,bad,strcmp(coin->symbol,"BTC") == 0 ? " | (if this is taking too long, just exit and restart iguana)" : ""); return(0); } From 241177cc044b3517c47343054b51f01bf31efb11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 00:09:07 -0300 Subject: [PATCH 25/41] test --- iguana/iguana_peers.c | 9 ++++++--- iguana/iguana_realtime.c | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index cc328bf9c..6c6a8967d 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -1300,9 +1300,12 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin, myfree(buf,bufsize); if ( addr->filehash2 != 0 ) myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0; - iguana_mempurge(&addr->RAWMEM); - iguana_mempurge(&addr->TXDATA); - iguana_mempurge(&addr->HASHMEM); + if ( 0 ) + { + iguana_mempurge(&addr->RAWMEM); + iguana_mempurge(&addr->TXDATA); + iguana_mempurge(&addr->HASHMEM); + } #ifdef IGUANA_PEERALLOC while ( (remaining= iguana_peerallocated(coin,addr)) > 0 ) { diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index a4d1e2ce9..d55c79f2d 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -635,7 +635,7 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) iguana_RTpurge(coin,coin->firstRTheight); } n = (block->height - coin->RTheight) + 1; - for (i=0; iRTheight++) + for (i=0; iRTheight + i); hdrsi = (height / coin->chain->bundlesize); @@ -651,6 +651,7 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) break; } } + coin->RTheight += i; printf(">= RTnewblock RTheight %d prev %d\n",coin->RTheight,coin->lastRTheight); } else if ( block->height == coin->lastRTheight ) From 7f942ee3c225ea9e4b4010d65dee310378e23969 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 00:10:57 -0300 Subject: [PATCH 26/41] test --- iguana/iguana_peers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 6c6a8967d..b905bca27 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -634,7 +634,7 @@ void _iguana_processmsg(struct iguana_info *coin,int32_t usock,struct iguana_pee printf("recv error on (%s) len.%d errno.%d (%s)\n",H.command,len,-recvlen,strerror(-recvlen)); if ( buf != _buf ) myfree(buf,len); - addr->dead = (uint32_t)time(NULL); + //addr->dead = (uint32_t)time(NULL); return; } } From 67611fd579fb193fec44055fa8131ce7db3ffb45 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 00:18:14 -0300 Subject: [PATCH 27/41] test --- iguana/iguana777.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index bbda10db6..58e7c3905 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -501,24 +501,6 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int //printf("helperid.%d convertfinished.%d vs max %d bundlescount.%d\n",helperid,n,max,coin->bundlescount); sleep(IGUANA_NUMHELPERS+3); } - if ( helperid == 0 ) - { - iguana_update_balances(coin); - if ( 1 ) - { - for (i=0; ibundles[i]) != 0 ) - { - iguana_volatilespurge(coin,&bp->ramchain); - iguana_volatilesmap(coin,&bp->ramchain); - } - } - } - while ( iguana_balancefinished(coin) < max || coin->balanceflush != 0 ) - sleep(3); - //printf("helper.%d check validates\n",helperid); - //incr = IGUANA_NUMHELPERS; - //incr = 1; if ( helperid < incr ) { for (hdrsi=helperid; hdrsibundles[i]) != 0 ) + { + iguana_volatilespurge(coin,&bp->ramchain); + iguana_volatilesmap(coin,&bp->ramchain); + } + } + } + while ( iguana_balancefinished(coin) < max || coin->balanceflush != 0 ) + sleep(3); + //printf("helper.%d check validates\n",helperid); + //incr = IGUANA_NUMHELPERS; + //incr = 1; + if ( helperid == 0 ) { coin->spendvectorsaved = (uint32_t)time(NULL); coin->spendvalidated = 0; From 77925d68e28ec3387dda864711c8fdd6dec828f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 00:28:28 -0300 Subject: [PATCH 28/41] test --- iguana/iguana777.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 58e7c3905..1f6bd0b76 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -435,11 +435,12 @@ void iguana_update_balances(struct iguana_info *coin) { iguana_volatilespurge(coin,&bp->ramchain); sprintf(fname,"%s/%s/accounts/debits.%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); + OS_removefile(fname,0); iguana_volatilesalloc(coin,&bp->ramchain,0);//i < hdrsi); } + printf("accounts files purged\n"); sleep(3); for (hdrsi=0; hdrsiramchain,3); if ( iguana_balancegen(coin,0,bp,0,coin->chain->bundlesize-1,0) == 0 ) + { + fprintf(stderr,"%d ",hdrsi); bp->balancefinish = (uint32_t)time(NULL); + } else printf("balancegen error.[%d]\n",bp->hdrsi); } } else printf("null bp.[%d]\n",hdrsi); } - if ( max != coin->origbalanceswritten ) + //if ( max != coin->origbalanceswritten ) { coin->balanceflush = max+1; while ( coin->balanceflush != 0 ) sleep(3); - } else printf("skip flush when max.%d and orig.%d\n",max,coin->origbalanceswritten); + }// else printf("skip flush when max.%d and orig.%d\n",max,coin->origbalanceswritten); } } @@ -521,7 +525,9 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int } if ( helperid == 0 ) { + printf("start iguana_update_balances\n"); iguana_update_balances(coin); + printf("iguana_update_balances completed\n"); if ( 1 ) { for (i=0; i Date: Thu, 18 Aug 2016 00:50:39 -0300 Subject: [PATCH 29/41] test --- iguana/iguana_peers.c | 2 +- iguana/iguana_realtime.c | 3 +++ iguana/iguana_recv.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index b905bca27..127b86def 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -631,7 +631,7 @@ void _iguana_processmsg(struct iguana_info *coin,int32_t usock,struct iguana_pee buf = mycalloc('p',1,len); if ( (recvlen= iguana_recv(addr->ipaddr,usock,buf,len)) < 0 ) { - printf("recv error on (%s) len.%d errno.%d (%s)\n",H.command,len,-recvlen,strerror(-recvlen)); + printf("%s recv error on (%s) len.%d errno.%d (%s)\n",addr->ipaddr,H.command,len,-recvlen,strerror(-recvlen)); if ( buf != _buf ) myfree(buf,len); //addr->dead = (uint32_t)time(NULL); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index d55c79f2d..849980a1f 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -600,6 +600,7 @@ void iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) if ( coin->RTrawdata[offset] == 0 ) coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset]); //printf("%s RTblockadd.%d offset.%d numtx.%d len.%d\n",coin->symbol,block->height,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); + block->RO.txn_count = coin->RTnumtx[offset]; coin->RTblocks[offset] = block; iguana_RTiterate(coin,offset,block,1); } @@ -611,12 +612,14 @@ void iguana_RTblocksub(struct iguana_info *coin,struct iguana_block *block) if ( block != 0 ) { offset = block->height - coin->firstRTheight; + block->RO.txn_count = coin->RTnumtx[offset]; //printf("%s RTblocksub.%d offset.%d\n",coin->symbol,block->height,offset); iguana_RTiterate(coin,offset,block,-1); if ( coin->RTrawdata[offset] != 0 && coin->RTrecvlens[offset] != 0 ) iguana_RTunmap(coin->RTrawdata[offset],coin->RTrecvlens[offset]); coin->RTrawdata[offset] = 0; coin->RTrecvlens[offset] = 0; + coin->RTnumtx[offset] = 0; coin->RTblocks[offset] = 0; } } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 001011491..fbd5479b6 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -68,7 +68,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, if ( addr == 0 || memcmp(lastreq.bytes,hash2.bytes,sizeof(hash2)) == 0 || memcmp(lastreq2.bytes,hash2.bytes,sizeof(hash2)) == 0 ) { //printf("duplicate req %s or null addr.%p\n",bits256_str(hexstr,hash2),addr); - if ( (rand() % 10 ) != 0 ) + //if ( (rand() % 10 ) != 0 ) return(0); } if ( addr->usock < 0 ) From dec70056c40ee513bc08d4dc2664ed70a91e47a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 00:59:21 -0300 Subject: [PATCH 30/41] test --- iguana/iguana_realtime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 849980a1f..746bb1a38 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -507,6 +507,8 @@ void iguana_RTunmap(uint8_t *ptr,uint32_t len) void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp) { FILE *fp; char fname[1024],str[65]; long filesize; uint8_t *ptr; uint32_t i,nonz,checknumtx,checklen; + if ( coin->RTheight == 0 ) + return(0); sprintf(fname,"%s/%s/RT/%s.raw",GLOBAL_TMPDIR,coin->symbol,bits256_str(str,hash2)); OS_compatible_path(fname); if ( *recvlenp > 0 ) From b4d317de12f18527d3b9531d3d47b75cfb7b57a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 01:32:54 -0300 Subject: [PATCH 31/41] test --- iguana/iguana_bundles.c | 2 -- iguana/iguana_ramchain.c | 4 ++-- iguana/iguana_realtime.c | 6 +++--- iguana/iguana_recv.c | 2 +- includes/iguana_funcs.h | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 7a24e2d5f..483608128 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -458,8 +458,6 @@ char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi) retjson = cJSON_CreateArray(); PKbits = RAMCHAIN_PTR(rdata,PKoffset); P = RAMCHAIN_PTR(rdata,Poffset); - //PKbits = (void *)(long)((long)rdata + rdata->PKoffset); - //P = (void *)(long)((long)rdata + rdata->Poffset); for (pkind=0; pkindrmd160,20); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 89444abf1..a656b9b7b 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2804,7 +2804,7 @@ int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDAT printf(" script type.%d\n",type); } bitcoin_address(coinaddr,coin->chain->pubtype,V.rmd160,sizeof(V.rmd160)); - iguana_RTunspent(coin,block,polarity,coinaddr,V.rmd160,tx->txid,j,tx->vouts[j].value); + iguana_RTunspent(coin,block,polarity,coinaddr,V.rmd160,type,script,scriptlen,tx->txid,j,tx->vouts[j].value); } ramchain->H.spendind += tx->tx_in; } @@ -2816,7 +2816,7 @@ int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDAT tx = &txarray[i]; for (j=0; jtx_in; j++) { - iguana_RTspend(coin,block,polarity,tx->txid,j,tx->vins[j].prev_hash,tx->vins[j].prev_vout); + iguana_RTspend(coin,block,polarity,tx->vins[i].vinscript,tx->vins[i].scriptlen,tx->txid,j,tx->vins[j].prev_hash,tx->vins[j].prev_vout); } } iguana_RTtxid(coin,block,polarity,i,txn_count,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp,unspents,spends); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 746bb1a38..1bda3df75 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -464,7 +464,7 @@ int32_t iguana_realtime_update(struct supernet_info *myinfo,struct iguana_info * return(flag); } -void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,bits256 txid,int32_t vout,int64_t value) +void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value) { int32_t i; // fill in array element and update counters @@ -476,7 +476,7 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_ } } -void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout) +void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout) { char str[65],str2[65]; // fill in array element and update counters @@ -663,7 +663,7 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) { if ( (subblock= iguana_RTblock(coin,block->height)) != 0 && subblock != block ) { - iguana_RTblocksub(coin,block); + iguana_RTblocksub(coin,subblock); iguana_RTblockadd(coin,block); printf("== RTnewblock RTheight %d prev %d\n",coin->RTheight,coin->lastRTheight); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index fbd5479b6..32fa5c98f 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -356,7 +356,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i received[addr->addrind] += recvlen; count[addr->addrind]++; now = (uint32_t)time(NULL); - if ( ((rand() % 1000) == 0 && now > last+10) || now > last+600 ) + if ( ((rand() % 10000) == 0 && now > last+60) || now > last+600 ) { int64_t sum2 = 0,sum = 0,diffr,diff; double bw = 0.; for (i=0; i Date: Thu, 18 Aug 2016 01:53:54 -0300 Subject: [PATCH 32/41] test --- iguana/coins/genbtc | 2 +- iguana/iguana_realtime.c | 54 +++++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/iguana/coins/genbtc b/iguana/coins/genbtc index 1d533725f..1b181efcc 100755 --- a/iguana/coins/genbtc +++ b/iguana/coins/genbtc @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":8,\"endpend\":6,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":64,\"endpend\":16,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 1bda3df75..5143bf512 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -496,6 +496,8 @@ void iguana_RTreset(struct iguana_info *coin) { iguana_utxoaddrs_purge(coin); iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables + coin->lastRTheight = 0; + coin->RTheight = coin->firstRTheight; printf("%s RTreset\n",coin->symbol); } @@ -559,13 +561,19 @@ void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight) printf("end RTpurge.%d\n",lastheight); } -void iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_block *block,int64_t polarity) +int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_block *block,int64_t polarity) { - struct iguana_txblock txdata; uint8_t *serialized; int32_t n,numtx,len; uint32_t recvlen = 0; - if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) + struct iguana_txblock txdata; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; + while ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { - printf("cant load from tmpdir ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); - return; + printf("errs.%d cant load from tmpdir ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); + iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); + sleep(3); + if ( errs++ > 10 ) + { + iguana_RTreset(coin); + return(-1); + } } printf("%s RTiterate.%lld offset.%d numtx.%d len.%d\n",coin->symbol,(long long)polarity,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); memset(&txdata,0,sizeof(txdata)); @@ -579,7 +587,10 @@ void iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_bloc if ( (n= iguana_gentxarray(coin,&coin->RTrawmem,&txdata,&len,serialized,recvlen)) > 0 ) { iguana_RTramchaindata(coin,&coin->RTmem,&coin->RThashmem,polarity,block,coin->RTrawmem.ptr,numtx); + return(0); } else printf("gentxarray n.%d RO.txn_count.%d recvlen.%d\n",n,numtx,recvlen); + iguana_RTreset(coin); + return(-1); } struct iguana_block *iguana_RTblock(struct iguana_info *coin,int32_t height) @@ -593,7 +604,7 @@ struct iguana_block *iguana_RTblock(struct iguana_info *coin,int32_t height) return(0); } -void iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) +int32_t iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) { int32_t offset; if ( block != 0 ) @@ -604,11 +615,13 @@ void iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) //printf("%s RTblockadd.%d offset.%d numtx.%d len.%d\n",coin->symbol,block->height,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); block->RO.txn_count = coin->RTnumtx[offset]; coin->RTblocks[offset] = block; - iguana_RTiterate(coin,offset,block,1); + if ( iguana_RTiterate(coin,offset,block,1) < 0 ) + return(-1); } + return(0); } -void iguana_RTblocksub(struct iguana_info *coin,struct iguana_block *block) +int32_t iguana_RTblocksub(struct iguana_info *coin,struct iguana_block *block) { int32_t offset; if ( block != 0 ) @@ -616,7 +629,8 @@ void iguana_RTblocksub(struct iguana_info *coin,struct iguana_block *block) offset = block->height - coin->firstRTheight; block->RO.txn_count = coin->RTnumtx[offset]; //printf("%s RTblocksub.%d offset.%d\n",coin->symbol,block->height,offset); - iguana_RTiterate(coin,offset,block,-1); + if ( iguana_RTiterate(coin,offset,block,-1) < 0 ) + return(-1); if ( coin->RTrawdata[offset] != 0 && coin->RTrecvlens[offset] != 0 ) iguana_RTunmap(coin->RTrawdata[offset],coin->RTrecvlens[offset]); coin->RTrawdata[offset] = 0; @@ -624,6 +638,7 @@ void iguana_RTblocksub(struct iguana_info *coin,struct iguana_block *block) coin->RTnumtx[offset] = 0; coin->RTblocks[offset] = 0; } + return(0); } void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) @@ -633,7 +648,7 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) { if ( block->height > coin->lastRTheight ) { - if ( coin->lastRTheight == 0 ) + if ( coin->firstRTheight == 0 ) { coin->firstRTheight = coin->RTheight; iguana_RTreset(coin); @@ -647,13 +662,15 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) bundlei = (height % coin->chain->bundlesize); if ( (bp= coin->bundles[hdrsi]) != 0 && (addblock= bp->blocks[bundlei]) != 0 && addblock->height == coin->RTheight+i ) { - iguana_RTblockadd(coin,addblock); + if ( iguana_RTblockadd(coin,addblock) < 0 ) + return; coin->lastRTheight = addblock->height; } else { printf("missing RTaddblock at i.%d RTheight.%d vs %p %d\n",i,coin->RTheight,addblock,addblock!=0?addblock->height:-1); - break; + iguana_RTreset(coin); + return; } } coin->RTheight += i; @@ -663,8 +680,8 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) { if ( (subblock= iguana_RTblock(coin,block->height)) != 0 && subblock != block ) { - iguana_RTblocksub(coin,subblock); - iguana_RTblockadd(coin,block); + if ( iguana_RTblocksub(coin,subblock) < 0 || iguana_RTblockadd(coin,block) < 0 ) + return; printf("== RTnewblock RTheight %d prev %d\n",coin->RTheight,coin->lastRTheight); } } @@ -674,14 +691,17 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) { if ( coin->lastRTheight > 0 ) printf("ht.%d reorg past firstRTheight.%d\n",block->height,coin->firstRTheight); - coin->lastRTheight = 0; iguana_RTreset(coin); } else { while ( coin->lastRTheight >= block->height ) - iguana_RTblocksub(coin,iguana_RTblock(coin,coin->lastRTheight--)); - iguana_RTblockadd(coin,block); + { + if ( iguana_RTblocksub(coin,iguana_RTblock(coin,coin->lastRTheight--)) < 0 ) + return; + } + if ( iguana_RTblockadd(coin,block) < 0 ) + return; coin->lastRTheight = block->height; } } From bfe57a51f296e3bf63ebdc582b3655f80597ac79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 02:03:19 -0300 Subject: [PATCH 33/41] test --- iguana/iguana_realtime.c | 6 ------ iguana/iguana_unspents.c | 8 ++++++-- includes/iguana_funcs.h | 2 ++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 5143bf512..daecfab47 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -648,12 +648,6 @@ void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block) { if ( block->height > coin->lastRTheight ) { - if ( coin->firstRTheight == 0 ) - { - coin->firstRTheight = coin->RTheight; - iguana_RTreset(coin); - iguana_RTpurge(coin,coin->firstRTheight); - } n = (block->height - coin->RTheight) + 1; for (i=0; iutxoaddrhash),dstr(coin->histbalance),errs); if ( errs == 0 && coin->histbalance > 0 ) { - coin->RTheight = height; + coin->firstRTheight = coin->RTheight = height; + iguana_RTreset(coin); + iguana_RTpurge(coin,coin->firstRTheight); if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) iguana_RTnewblock(coin,block); return(coin->histbalance); @@ -1314,7 +1316,9 @@ continue; } else { - coin->RTheight = height; + coin->firstRTheight = coin->RTheight = height; + iguana_RTreset(coin); + iguana_RTpurge(coin,coin->firstRTheight); if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) iguana_RTnewblock(coin,block); return(coin->histbalance); diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 68e97d4f2..ab395e200 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -543,6 +543,8 @@ int32_t iguana_RTramchaindata(struct iguana_info *coin,struct OS_memspace *TXDAT void iguana_RTtxid(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,int32_t txi,int32_t txn_count,bits256 txid,int32_t numvouts,int32_t numvins,uint32_t locktime,uint32_t version,uint32_t timestamp,void *unspents,void *spends); void iguana_RTspend(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vini,bits256 prev_hash,int32_t prev_vout); void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_t polarity,char *coinaddr,uint8_t *rmd160,int32_t type,uint8_t *script,int32_t scriptlen,bits256 txid,int32_t vout,int64_t value); +void iguana_RTreset(struct iguana_info *coin); +void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight); void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block); void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp); void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp); From 6505f7d3b570c80b4ea21c595ed4a5cca3cf4286 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 02:09:08 -0300 Subject: [PATCH 34/41] test --- iguana/iguana777.c | 2 +- iguana/iguana_realtime.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 1f6bd0b76..dfb5d7359 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -518,7 +518,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int } // else printf("%s helperid.%d validated.[%d]\n",coin->symbol,helperid,hdrsi); } } - while ( iguana_validated(coin) < max || iguana_utxofinished(coin) < max || iguana_balancefinished(coin) < max ) + while ( iguana_validated(coin) < max || iguana_utxofinished(coin) < max ) { printf("%s helperid.%d waiting for spendvectorsaved.%u v.%d u.%d b.%d vs max.%d\n",coin->symbol,helperid,coin->spendvectorsaved,iguana_validated(coin),iguana_utxofinished(coin),iguana_balancefinished(coin),max); sleep(IGUANA_NUMHELPERS+3); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index daecfab47..908777ac5 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -566,7 +566,8 @@ int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_b struct iguana_txblock txdata; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; while ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { - printf("errs.%d cant load from tmpdir ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); + char str[65]; + printf("errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); sleep(3); if ( errs++ > 10 ) From a4de2cf9448575ab1248cd541602651735a9a291 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 02:33:30 -0300 Subject: [PATCH 35/41] test --- iguana/iguana_realtime.c | 8 +++++--- iguana/iguana_recv.c | 13 +++++++++---- iguana/iguana_unspents.c | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 908777ac5..7bb47ccf5 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -509,12 +509,12 @@ void iguana_RTunmap(uint8_t *ptr,uint32_t len) void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp) { FILE *fp; char fname[1024],str[65]; long filesize; uint8_t *ptr; uint32_t i,nonz,checknumtx,checklen; - if ( coin->RTheight == 0 ) - return(0); sprintf(fname,"%s/%s/RT/%s.raw",GLOBAL_TMPDIR,coin->symbol,bits256_str(str,hash2)); OS_compatible_path(fname); if ( *recvlenp > 0 ) { + if ( coin->RTheight == 0 ) + return(0); if ( (fp= fopen(fname,"wb")) != 0 ) { if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) @@ -563,12 +563,14 @@ void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight) int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_block *block,int64_t polarity) { - struct iguana_txblock txdata; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; + struct iguana_txblock txdata; struct iguana_peer *addr; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; while ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { char str[65]; printf("errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); + if ( coin->peers != 0 && coin->peers->numranked > 0 && (addr= coin->peers->ranked[rand() % coin->peers->numranked]) != 0 ) + iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); sleep(3); if ( errs++ > 10 ) { diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 32fa5c98f..920648fb7 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -63,12 +63,12 @@ int32_t iguana_speculativesearch(struct iguana_info *coin,struct iguana_block ** int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe) { static bits256 lastreq,lastreq2; - int32_t len,j; struct iguana_bundle *checkbp; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; struct iguana_block *block=0; + int32_t len,j,recvlen,numtx; struct iguana_bundle *checkbp; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; struct iguana_block *block=0; char hexstr[65]; init_hexbytes_noT(hexstr,hash2.bytes,sizeof(hash2)); if ( addr == 0 || memcmp(lastreq.bytes,hash2.bytes,sizeof(hash2)) == 0 || memcmp(lastreq2.bytes,hash2.bytes,sizeof(hash2)) == 0 ) { //printf("duplicate req %s or null addr.%p\n",bits256_str(hexstr,hash2),addr); - //if ( (rand() % 10 ) != 0 ) + if ( iamthreadsafe == 0 && (rand() % 10 ) != 0 ) return(0); } if ( addr->usock < 0 ) @@ -78,8 +78,13 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, { if ( checkbp->emitfinish != 0 || ((block= checkbp->blocks[j]) != 0 && block->txvalid != 0 && block->mainchain != 0 && block->valid != 0) ) { - //printf("found valid [%d:%d] in blockreqPT\n",checkbp->hdrsi,j); - return(0); + char str[65]; + recvlen = numtx = 0; + if ( iguana_RTrawdata(coin,hash2,0,&recvlen,&numtx) != 0 ) + { + printf("found valid [%d:%d] in blockreqPT\n",checkbp->hdrsi,j); + return(0); + } else printf("no RTrawdata for %s\n",bits256_str(str,hash2)); } } if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index cbc3e36af..672832013 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1122,7 +1122,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c } good++; if ( ((good + bad) % 1000) == 0 ) - printf("%s utxoaddr validate good.%d bad.%d%s\n",coin->symbol,good,bad,strcmp(coin->symbol,"BTC") == 0 ? " | (if this is taking too long, just exit and restart iguana)" : ""); + printf("%s total %d utxoaddr validate good.%d bad.%d%s\n",coin->symbol,coin->utxoaddrind,good,bad,strcmp(coin->symbol,"BTC") == 0 ? " | (if this is taking too long, just exit and restart iguana)" : ""); return(0); } From 1233a5b5c56e0ab092a31b1e7dc1820b9e48e732 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 04:01:11 -0300 Subject: [PATCH 36/41] test --- basilisk/basilisk_bitcoin.c | 2 +- iguana/iguana_bundles.c | 2 +- iguana/iguana_msg.c | 4 ++-- iguana/iguana_peers.c | 8 ++++---- iguana/iguana_realtime.c | 40 +++++++++++++++++++++++++++---------- iguana/iguana_recv.c | 38 ++++++++++++++++++++--------------- includes/iguana_funcs.h | 8 ++++---- 7 files changed, 64 insertions(+), 38 deletions(-) diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index ee8670a30..d52ce2f31 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -266,7 +266,7 @@ int32_t basilisk_bitcoinscan(struct iguana_info *coin,uint8_t origblockspace[IGU if ( (n= iguana_gentxarray(coin,rawmem,&txdata,&len,blockspace,datalen)) == datalen ) { len = n; - iguana_gotblockM(coin,0,&txdata,rawmem->ptr,&H,blockspace,datalen); + iguana_gotblockM(coin,0,&txdata,rawmem->ptr,&H,blockspace,datalen,0); flag = 1; //if ( (rand() % 1000) == 0 ) printf("%s h.%-7d len.%-6d | HWM.%d\n",coin->symbol,h,datalen,coin->blocks.hwmchain.height); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 483608128..c5a91f379 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -1167,7 +1167,7 @@ int32_t iguana_cacheprocess(struct iguana_info *coin,struct iguana_bundle *bp,in iguana_meminit(&coin->internaladdr.TXDATA,"txdata",0,IGUANA_MAXPACKETSIZE*1.5,0); if ( coin->internaladdr.HASHMEM.ptr == 0 ) iguana_meminit(&coin->internaladdr.HASHMEM,"HASHPTRS",0,256,0); - if ( iguana_msgparser(coin,&coin->internaladdr,&coin->internaladdr.RAWMEM,&coin->internaladdr.TXDATA,&coin->internaladdr.HASHMEM,&H,&data[sizeof(recvlen)],recvlen) < 0 ) + if ( iguana_msgparser(coin,&coin->internaladdr,&coin->internaladdr.RAWMEM,&coin->internaladdr.TXDATA,&coin->internaladdr.HASHMEM,&H,&data[sizeof(recvlen)],recvlen,1) < 0 ) printf("error parsing speculativecache.[%d:%d]\n",bp->hdrsi,bundlei); } free(data); diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 5582cf13f..9e4e486e3 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -827,7 +827,7 @@ int32_t iguana_intvectors(struct iguana_info *coin,struct iguana_peer *addr,int3 //printf("intvectors.%c recvlen.%d\n",intvectors,recvlen); } -int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struct OS_memspace *rawmem,struct OS_memspace *txmem,struct OS_memspace *hashmem,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen) +int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struct OS_memspace *rawmem,struct OS_memspace *txmem,struct OS_memspace *hashmem,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,int32_t fromcache) { uint8_t serialized[16384]; char *ipaddr; struct supernet_info *myinfo = SuperNET_MYINFO(0); int32_t i,n=0,retval=-1,ishost,srvmsg,bloom,sendlen=0,intvectors,len= -100; uint64_t nonce,x; bits256 hash2; @@ -873,7 +873,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc if ( (n= iguana_gentxarray(coin,rawmem,&txdata,&len,data,recvlen)) == recvlen ) { len = n; - iguana_gotblockM(coin,addr,&txdata,rawmem->ptr,H,data,recvlen); + iguana_gotblockM(coin,addr,&txdata,rawmem->ptr,H,data,recvlen,fromcache); } else { diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 127b86def..f64d91bb0 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -566,7 +566,7 @@ int32_t iguana_recv(char *ipaddr,int32_t usock,uint8_t *recvbuf,int32_t len) return(len); } -void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len) +void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len,int32_t fromcache) { struct iguana_msghdr checkH; memset(&checkH,0,sizeof(checkH)); @@ -582,7 +582,7 @@ void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct ig iguana_meminit(&addr->HASHMEM,"HASHPTRS",0,256,0);//IGUANA_MAXPACKETSIZE*16,0); //printf("Init %s memory %p %p %p\n",addr->ipaddr,addr->RAWMEM.ptr,addr->TXDATA.ptr,addr->HASHMEM.ptr); } - if ( iguana_msgparser(coin,addr,&addr->RAWMEM,&addr->TXDATA,&addr->HASHMEM,H,buf,len) < 0 || addr->dead != 0 ) + if ( iguana_msgparser(coin,addr,&addr->RAWMEM,&addr->TXDATA,&addr->HASHMEM,H,buf,len,fromcache) < 0 || addr->dead != 0 ) { printf("%p addr->dead.%d or parser break at %u\n",&addr->dead,addr->dead,(uint32_t)time(NULL)); addr->dead = (uint32_t)time(NULL); @@ -638,7 +638,7 @@ void _iguana_processmsg(struct iguana_info *coin,int32_t usock,struct iguana_pee return; } } - iguana_parsebuf(coin,addr,&H,buf,len); + iguana_parsebuf(coin,addr,&H,buf,len,0); if ( buf != _buf ) myfree(buf,len); return; @@ -1200,7 +1200,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin, if ( req->datalen != 0 ) { //char str[65]; printf("CACHE.%p parse[%d] %s %s\n",req,req->recvlen,req->H.command,bits256_str(str,req->zblock.RO.hash2)); - iguana_parsebuf(coin,addr,&req->H,req->serializeddata,req->recvlen); + iguana_parsebuf(coin,addr,&req->H,req->serializeddata,req->recvlen,1); } else printf("CACHE error no datalen\n"); coin->cachefreed++; myfree(req,req->allocsize); diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 7bb47ccf5..49da9afa7 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -498,7 +498,7 @@ void iguana_RTreset(struct iguana_info *coin) iguana_utxoupdate(coin,-1,0,0,0,0,-1,0); // free hashtables coin->lastRTheight = 0; coin->RTheight = coin->firstRTheight; - printf("%s RTreset\n",coin->symbol); + printf("%s RTreset %d\n",coin->symbol,coin->RTheight); } void iguana_RTunmap(uint8_t *ptr,uint32_t len) @@ -506,21 +506,37 @@ void iguana_RTunmap(uint8_t *ptr,uint32_t len) OS_releasemap(&ptr[-2*sizeof(len)],len+2*sizeof(len)); } -void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp) +void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t fromcache) { - FILE *fp; char fname[1024],str[65]; long filesize; uint8_t *ptr; uint32_t i,nonz,checknumtx,checklen; + FILE *fp; char fname[1024],str[65]; long filesize; int32_t len; uint8_t *ptr; uint32_t i,nonz,checknumtx,checklen; sprintf(fname,"%s/%s/RT/%s.raw",GLOBAL_TMPDIR,coin->symbol,bits256_str(str,hash2)); OS_compatible_path(fname); if ( *recvlenp > 0 ) { if ( coin->RTheight == 0 ) + { + printf("skip %s\n",bits256_str(str,hash2)); return(0); + } + if ( (fp= fopen(fname,"rb")) != 0 ) + { + fseek(fp,0,SEEK_END); + filesize = ftell(fp); + rewind(fp); + if ( fread(&len,1,sizeof(len),fp) == sizeof(len) && len == filesize+sizeof(int32_t)*2 ) + { + fclose(fp); + printf("already have %s\n",bits256_str(str,hash2)); + return(0); + } + fclose(fp); + } if ( (fp= fopen(fname,"wb")) != 0 ) { if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); fclose(fp); - //printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); + printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); } else printf("couldnt create %s\n",fname); } else if ( *recvlenp == 0 ) @@ -556,22 +572,26 @@ void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight) 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); // delete file + iguana_RTrawdata(coin,bp->hashes[bundlei],0,&recvlen,&numtx,0); // delete file } printf("end RTpurge.%d\n",lastheight); } int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_block *block,int64_t polarity) { - struct iguana_txblock txdata; struct iguana_peer *addr; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; + struct iguana_txblock txdata; struct iguana_peer *addr; uint8_t *serialized; int32_t i,n,errs=0,numtx,len; uint32_t recvlen = 0; while ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { char str[65]; printf("errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); - if ( coin->peers != 0 && coin->peers->numranked > 0 && (addr= coin->peers->ranked[rand() % coin->peers->numranked]) != 0 ) - iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); - sleep(3); + if ( coin->peers != 0 && coin->peers->numranked > 0 ) + { + for (i=0; ipeers->numranked&&i<8; i++) + if ( (addr= coin->peers->ranked[i]) != 0 ) + iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); + } + return(-1); if ( errs++ > 10 ) { iguana_RTreset(coin); @@ -614,7 +634,7 @@ int32_t iguana_RTblockadd(struct iguana_info *coin,struct iguana_block *block) { offset = block->height - coin->firstRTheight; if ( coin->RTrawdata[offset] == 0 ) - coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset]); + coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset],0); //printf("%s RTblockadd.%d offset.%d numtx.%d len.%d\n",coin->symbol,block->height,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); block->RO.txn_count = coin->RTnumtx[offset]; coin->RTblocks[offset] = block; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 920648fb7..4bff2e617 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -78,13 +78,13 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, { if ( checkbp->emitfinish != 0 || ((block= checkbp->blocks[j]) != 0 && block->txvalid != 0 && block->mainchain != 0 && block->valid != 0) ) { - char str[65]; + //char str[65]; recvlen = numtx = 0; - if ( iguana_RTrawdata(coin,hash2,0,&recvlen,&numtx) != 0 ) + if ( iguana_RTrawdata(coin,hash2,0,&recvlen,&numtx,0) != 0 ) { printf("found valid [%d:%d] in blockreqPT\n",checkbp->hdrsi,j); return(0); - } else printf("no RTrawdata for %s\n",bits256_str(str,hash2)); + } //else printf("no RTrawdata for %s\n",bits256_str(str,hash2)); } } if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 ) @@ -121,8 +121,8 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, bp->issued[bundlei] = addr->pendtime; if ( block != 0 ) block->issued = addr->pendtime; - if ( 0 && coin->current == bp ) - printf("REQ.(%s) bundlei.%d hdrsi.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1); + //if ( 0 && coin->current == bp ) + printf("REQ.(%s) [%d:%d] %s\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr); } else printf("MSG_BLOCK null datalen.%d\n",len); return(len); } @@ -313,7 +313,7 @@ void iguana_bundletime(struct iguana_info *coin,struct iguana_bundle *bp,int32_t } } -void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen) +void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,int32_t fromcache) { struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag,numtx; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65]; if ( recvlen < 0 || recvlen > IGUANA_MAXPACKETSIZE ) @@ -355,7 +355,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i else if ( 0 && coin->enableCACHE != 0 ) printf("cache.%d validated.(%s)\n",coin->enableCACHE,bits256_str(str,origtxdata->zblock.RO.hash2)); origtxdata->zblock.txvalid = 1; - if ( coin->virtualchain == 0 && addr != 0 && addr != &coin->internaladdr ) + if ( fromcache == 0 && coin->virtualchain == 0 && addr != 0 && addr != &coin->internaladdr ) { static uint64_t received[IGUANA_MAXPEERS],count[IGUANA_MAXPEERS],lastcount,lastreceived,last; received[addr->addrind] += recvlen; @@ -475,11 +475,14 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i txdata = origtxdata; if ( addr != 0 ) { - if ( addr->pendblocks > 0 ) - addr->pendblocks--; - addr->lastblockrecv = (uint32_t)time(NULL); - addr->recvblocks += 1.; - addr->recvtotal += recvlen; + if ( fromcache == 0 ) + { + if ( addr->pendblocks > 0 ) + addr->pendblocks--; + addr->lastblockrecv = (uint32_t)time(NULL); + addr->recvblocks += 1.; + addr->recvtotal += recvlen; + } if ( speculative == 0 && iguana_ramchain_data(coin,addr,origtxdata,txarray,origtxdata->zblock.RO.txn_count,data,recvlen) >= 0 ) { txdata->zblock.fpipbits = (uint32_t)addr->ipbits; @@ -501,15 +504,18 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i } //else printf("cant save block\n"); } numtx = origtxdata->zblock.RO.txn_count; - iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx); + iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx,fromcache); req->zblock = txdata->zblock; if ( coin->virtualchain != 0 ) printf("%s recvlen.%d ipbits.%x prev.(%s)\n",coin->symbol,req->zblock.RO.recvlen,req->zblock.fpipbits,bits256_str(str,txdata->zblock.RO.prev_block)); req->zblock.RO.txn_count = req->numtx = txdata->zblock.RO.txn_count; - coin->recvcount++; - coin->recvtime = (uint32_t)time(NULL); + if ( fromcache == 0 ) + { + coin->recvcount++; + coin->recvtime = (uint32_t)time(NULL); + netBLOCKS++; + } req->addr = addr; - netBLOCKS++; queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); } diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index ab395e200..71d097abc 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -45,7 +45,7 @@ int32_t iguana_rwblock(char *symbol,uint8_t zcash,uint8_t auxpow,int32_t (*hasha int32_t iguana_serialize_block(struct iguana_chain *chain,bits256 *hash2p,uint8_t serialized[sizeof(struct iguana_msgblock)],struct iguana_block *block); void iguana_blockconv(uint8_t zcash,uint8_t auxpow,struct iguana_block *dest,struct iguana_msgblock *msg,bits256 hash2,int32_t height); //void iguana_freetx(struct iguana_msgtx *tx,int32_t n); -int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struct OS_memspace *rawmem,struct OS_memspace *txmem,struct OS_memspace *hashmem,struct iguana_msghdr *H,uint8_t *data,int32_t datalen); +int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struct OS_memspace *rawmem,struct OS_memspace *txmem,struct OS_memspace *hashmem,struct iguana_msghdr *H,uint8_t *data,int32_t datalen,int32_t fromcache); // send message int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H); @@ -65,7 +65,7 @@ void iguana_syncramchain(struct iguana_info *coin); //int32_t iguana_validateramchain(struct iguana_info *coin,int64_t *netp,uint64_t *creditsp,uint64_t *debitsp,int32_t height,struct iguana_block *block,int32_t hwmheight,struct iguana_prevdep *lp); int32_t iguana_calcrmd160(struct iguana_info *coin,char *asmstr,struct vin_info *vp,uint8_t *pk_script,int32_t pk_scriptlen,bits256 debugtxid,int32_t vout,uint32_t sequence); uint32_t iguana_updatescript(struct iguana_info *coin,uint32_t blocknum,uint32_t txidind,uint32_t spendind,uint32_t unspentind,uint64_t value,uint8_t *script,int32_t scriptlen,uint32_t sequence); -void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *txdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t datalen); +void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *txdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t datalen,int32_t fromcache); int32_t iguana_parseblock(struct iguana_info *coin,struct iguana_block *block,struct iguana_msgtx *tx,int32_t numtx); uint32_t iguana_txidind(struct iguana_info *coin,uint32_t *firstvoutp,uint32_t *firstvinp,bits256 txid); bits256 iguana_txidstr(struct iguana_info *coin,uint32_t *firstvoutp,uint32_t *firstvinp,char *txidstr,uint32_t txidind); @@ -323,7 +323,7 @@ uint8_t *iguana_walletrmds(struct supernet_info *myinfo,struct iguana_info *coin char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi); uint32_t iguana_sparseaddpk(uint8_t *bits,int32_t width,uint32_t tablesize,uint8_t rmd160[20],struct iguana_pkhash *P,uint32_t pkind,struct iguana_ramchain *ramchain); int32_t iguana_vinscriptparse(struct iguana_info *coin,struct vin_info *vp,uint32_t *sigsizep,uint32_t *pubkeysizep,uint32_t *p2shsizep,uint32_t *suffixp,uint8_t *vinscript,int32_t scriptlen); -void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len); +void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len,int32_t fromcache); int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp); int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate); int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct iguana_bundle *bp,int32_t startheight,int32_t endheight,int32_t startemit); @@ -546,7 +546,7 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_ void iguana_RTreset(struct iguana_info *coin); void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight); void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block); -void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp); +void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t fromcache); void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp); void iguana_update_balances(struct iguana_info *coin); void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp); From afce953d7168f76731ff3b0cc7c4bb424259d79f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 05:11:08 -0300 Subject: [PATCH 37/41] test --- iguana/iguana777.c | 2 +- iguana/iguana_realtime.c | 88 +++++++++++++++++++++++----------------- iguana/iguana_recv.c | 8 ++-- iguana/iguana_unspents.c | 10 ++--- includes/iguana_funcs.h | 2 +- 5 files changed, 62 insertions(+), 48 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index dfb5d7359..2a91251c9 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -892,7 +892,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("BTCD",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_realtime.c b/iguana/iguana_realtime.c index 49da9afa7..a6155af08 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -506,58 +506,65 @@ void iguana_RTunmap(uint8_t *ptr,uint32_t len) OS_releasemap(&ptr[-2*sizeof(len)],len+2*sizeof(len)); } -void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t fromcache) +void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t checkonly) { FILE *fp; char fname[1024],str[65]; long filesize; int32_t len; uint8_t *ptr; uint32_t i,nonz,checknumtx,checklen; sprintf(fname,"%s/%s/RT/%s.raw",GLOBAL_TMPDIR,coin->symbol,bits256_str(str,hash2)); OS_compatible_path(fname); - if ( *recvlenp > 0 ) + if ( *recvlenp == -1 ) + OS_removefile(fname,0); + else { - if ( coin->RTheight == 0 ) - { - printf("skip %s\n",bits256_str(str,hash2)); - return(0); - } - if ( (fp= fopen(fname,"rb")) != 0 ) + if ( (checkonly != 0 || *recvlenp > 0) && (fp= fopen(fname,"rb")) != 0 ) { fseek(fp,0,SEEK_END); filesize = ftell(fp); rewind(fp); - if ( fread(&len,1,sizeof(len),fp) == sizeof(len) && len == filesize+sizeof(int32_t)*2 ) + if ( fread(&len,1,sizeof(len),fp) == sizeof(len) && len == filesize-sizeof(int32_t)*2 ) { fclose(fp); - printf("already have %s\n",bits256_str(str,hash2)); + //printf("already have %s\n",bits256_str(str,hash2)); + *recvlenp = 0; + if ( checkonly != 0 ) + return((void *)"already have rawdata"); return(0); } + //printf("len.%d filesize.%ld\n",len,filesize); fclose(fp); } - if ( (fp= fopen(fname,"wb")) != 0 ) + if ( *recvlenp > 0 ) { - if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) - printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); - fclose(fp); - printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); - } else printf("couldnt create %s\n",fname); - } - else if ( *recvlenp == 0 ) - { - if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 ) + if ( coin->RTheight == 0 ) + { + //printf("skip %s\n",bits256_str(str,hash2)); + return(0); + } + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) + printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); + fclose(fp); + //printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); + } else printf("couldnt create %s\n",fname); + } + else if ( checkonly == 0 ) { - memcpy(&checklen,ptr,sizeof(checklen)); - memcpy(&checknumtx,&ptr[sizeof(checklen)],sizeof(checknumtx)); - *numtxp = checknumtx; - if ( checklen == (int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)) )//&& checknumtx == *numtxp ) + if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 ) { - for (i=nonz=0; iRTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) + struct iguana_txblock txdata; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; + if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { char str[65]; - printf("errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); - iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); + //printf("errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); + coin->RTrawdata[offset] = iguana_RTrawdata(coin,block->RO.hash2,0,&coin->RTrecvlens[offset],&coin->RTnumtx[offset],0); + if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) + { + printf("B errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); + return(0); + } + /*struct iguana_peer *addr; + iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); if ( coin->peers != 0 && coin->peers->numranked > 0 ) { for (i=0; ipeers->numranked&&i<8; i++) @@ -596,7 +610,7 @@ int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_b { iguana_RTreset(coin); return(-1); - } + }*/ } printf("%s RTiterate.%lld offset.%d numtx.%d len.%d\n",coin->symbol,(long long)polarity,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); memset(&txdata,0,sizeof(txdata)); diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 4bff2e617..123d80ffa 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -80,9 +80,9 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, { //char str[65]; recvlen = numtx = 0; - if ( iguana_RTrawdata(coin,hash2,0,&recvlen,&numtx,0) != 0 ) + if ( iguana_RTrawdata(coin,hash2,0,&recvlen,&numtx,1) != 0 ) { - printf("found valid [%d:%d] in blockreqPT\n",checkbp->hdrsi,j); + //printf("found valid [%d:%d] in blockreqPT\n",checkbp->hdrsi,j); return(0); } //else printf("no RTrawdata for %s\n",bits256_str(str,hash2)); } @@ -121,7 +121,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, bp->issued[bundlei] = addr->pendtime; if ( block != 0 ) block->issued = addr->pendtime; - //if ( 0 && coin->current == bp ) + if ( 0 && coin->current == bp ) printf("REQ.(%s) [%d:%d] %s\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr); } else printf("MSG_BLOCK null datalen.%d\n",len); return(len); @@ -504,7 +504,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i } //else printf("cant save block\n"); } numtx = origtxdata->zblock.RO.txn_count; - iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx,fromcache); + iguana_RTrawdata(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx,0); req->zblock = txdata->zblock; if ( coin->virtualchain != 0 ) printf("%s recvlen.%d ipbits.%x prev.(%s)\n",coin->symbol,req->zblock.RO.recvlen,req->zblock.fpipbits,bits256_str(str,txdata->zblock.RO.prev_block)); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 672832013..646f6d0d9 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1173,7 +1173,7 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info int64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coin,int32_t maxheight) { - char fname[1024],fname2[1024],coinaddr[64],str[65],checkaddr[64]; struct iguana_utxoaddr *utxoaddr,UA,*tmp,*last=0; uint16_t hdrsi; uint8_t *table,item[UTXOADDR_ITEMSIZE]; uint32_t *counts,*offsets,offset,n; int32_t errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0; struct iguana_block *block; + char fname[1024],fname2[1024],coinaddr[64],str[65],checkaddr[64]; struct iguana_utxoaddr *utxoaddr,UA,*tmp,*last=0; uint16_t hdrsi; uint8_t *table,item[UTXOADDR_ITEMSIZE]; uint32_t *counts,*offsets,offset,n; int32_t errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0; for (hdrsi=0; hdrsibundlescount-1; hdrsi++) { if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight ) @@ -1190,8 +1190,8 @@ int64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coi coin->firstRTheight = coin->RTheight = height; iguana_RTreset(coin); iguana_RTpurge(coin,coin->firstRTheight); - if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) - iguana_RTnewblock(coin,block); + //if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) + // iguana_RTnewblock(coin,block); return(coin->histbalance); } } @@ -1319,8 +1319,8 @@ continue; coin->firstRTheight = coin->RTheight = height; iguana_RTreset(coin); iguana_RTpurge(coin,coin->firstRTheight); - if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) - iguana_RTnewblock(coin,block); + //if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) + // iguana_RTnewblock(coin,block); return(coin->histbalance); } } diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index 71d097abc..866161b5f 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -546,7 +546,7 @@ void iguana_RTunspent(struct iguana_info *coin,struct iguana_block *block,int64_ void iguana_RTreset(struct iguana_info *coin); void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight); void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block); -void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t fromcache); +void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t checkonly); void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp); void iguana_update_balances(struct iguana_info *coin); void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp); From 095b8339156039444bc59b2c3b0fc84461c42227 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 05:44:15 -0300 Subject: [PATCH 38/41] test --- iguana/iguana777.c | 2 +- iguana/iguana_realtime.c | 19 +++++++------------ iguana/iguana_recv.c | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 2a91251c9..dfb5d7359 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -892,7 +892,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 = 0;//(strcmp("BTCD",coin->symbol) == 0); + coin->enableCACHE = (strcmp("BTCD",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_realtime.c b/iguana/iguana_realtime.c index a6155af08..bcba1722f 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -534,9 +534,9 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 } if ( *recvlenp > 0 ) { - if ( coin->RTheight == 0 ) + if ( coin->RTheight == 0 && coin->blocks.hwmchain.height < coin->longestchain-coin->chain->bundlesize && iguana_utxofinished(coin) < coin->bundlescount-3 ) { - //printf("skip %s\n",bits256_str(str,hash2)); + printf("skip %s\n",bits256_str(str,hash2)); return(0); } if ( (fp= fopen(fname,"wb")) != 0 ) @@ -544,7 +544,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); fclose(fp); - //printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); + printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); } else printf("couldnt create %s\n",fname); } else if ( checkonly == 0 ) @@ -586,7 +586,7 @@ void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight) int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_block *block,int64_t polarity) { - struct iguana_txblock txdata; uint8_t *serialized; int32_t n,errs=0,numtx,len; uint32_t recvlen = 0; + struct iguana_txblock txdata; uint8_t *serialized; int32_t i,n,errs=0,numtx,len; uint32_t recvlen = 0; if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { char str[65]; @@ -595,10 +595,10 @@ int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_b if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { printf("B errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); - return(0); + return(-1); } - /*struct iguana_peer *addr; - iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); + struct iguana_peer *addr; + iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); if ( coin->peers != 0 && coin->peers->numranked > 0 ) { for (i=0; ipeers->numranked&&i<8; i++) @@ -606,11 +606,6 @@ int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_b iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); } return(-1); - if ( errs++ > 10 ) - { - iguana_RTreset(coin); - return(-1); - }*/ } printf("%s RTiterate.%lld offset.%d numtx.%d len.%d\n",coin->symbol,(long long)polarity,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); memset(&txdata,0,sizeof(txdata)); diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 123d80ffa..79e8265e9 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -605,7 +605,7 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi } } } - if ( flag == 0 ) + // if ( flag == 0 ) iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[i],0); } } From 50fb33233784dfadccffd8b63161e2860403b9da Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 05:45:57 -0300 Subject: [PATCH 39/41] test --- iguana/iguana_realtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index bcba1722f..6beec08c8 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -536,7 +536,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 { if ( coin->RTheight == 0 && coin->blocks.hwmchain.height < coin->longestchain-coin->chain->bundlesize && iguana_utxofinished(coin) < coin->bundlescount-3 ) { - printf("skip %s\n",bits256_str(str,hash2)); + //printf("skip %s\n",bits256_str(str,hash2)); return(0); } if ( (fp= fopen(fname,"wb")) != 0 ) @@ -544,7 +544,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp ) printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp); fclose(fp); - printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); + //printf("numtx.%d len.%d %s\n",*numtxp,*recvlenp,fname); } else printf("couldnt create %s\n",fname); } else if ( checkonly == 0 ) From 3864a25eda9c018ecc99e8ca9c1c88cd72719a8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 05:56:55 -0300 Subject: [PATCH 40/41] test --- iguana/iguana_realtime.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 6beec08c8..3ecd50595 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -595,17 +595,16 @@ int32_t iguana_RTiterate(struct iguana_info *coin,int32_t offset,struct iguana_b if ( (numtx= coin->RTnumtx[offset]) == 0 || (serialized= coin->RTrawdata[offset]) == 0 || (recvlen= coin->RTrecvlens[offset]) == 0 ) { printf("B errs.%d cant load %s ht.%d polarity.%lld numtx.%d %p recvlen.%d\n",errs,bits256_str(str,block->RO.hash2),block->height,(long long)polarity,coin->RTnumtx[offset],coin->RTrawdata[offset],coin->RTrecvlens[offset]); + struct iguana_peer *addr; + iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); + if ( coin->peers != 0 && coin->peers->numranked > 0 ) + { + for (i=0; ipeers->numranked&&i<8; i++) + if ( (addr= coin->peers->ranked[i]) != 0 ) + iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); + } return(-1); } - struct iguana_peer *addr; - iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); - if ( coin->peers != 0 && coin->peers->numranked > 0 ) - { - for (i=0; ipeers->numranked&&i<8; i++) - if ( (addr= coin->peers->ranked[i]) != 0 ) - iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); - } - return(-1); } printf("%s RTiterate.%lld offset.%d numtx.%d len.%d\n",coin->symbol,(long long)polarity,offset,coin->RTnumtx[offset],coin->RTrecvlens[offset]); memset(&txdata,0,sizeof(txdata)); From c1403a322ab9950c2548f9f9d66f6aa94792afb3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 18 Aug 2016 06:20:45 -0300 Subject: [PATCH 41/41] test --- iguana/iguana_peers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index f64d91bb0..38921baa5 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -500,7 +500,7 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s remains -= numsent; serialized += numsent; if ( remains > 0 ) - printf("iguana sent.%d remains.%d of len.%d\n",numsent,remains,len); + printf("%s iguana sent.%d remains.%d of len.%d\n",addr->ipaddr,numsent,remains,len); } } addr->totalsent += len;