From 93296f43e6330cff2b7419a0d8e629d018a9a65e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 05:25:38 -0300 Subject: [PATCH 01/55] test --- iguana/coins/genbtc | 2 +- iguana/coins/genbtc.json | 2 +- iguana/iguana777.c | 21 ++++++++++++--------- iguana/main.c | 5 +++++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/iguana/coins/genbtc b/iguana/coins/genbtc index 9ffd8b2f1..4179c8fea 100755 --- a/iguana/coins/genbtc +++ b/iguana/coins/genbtc @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":11,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" diff --git a/iguana/coins/genbtc.json b/iguana/coins/genbtc.json index 94931216a..c2b0314d6 100755 --- a/iguana/coins/genbtc.json +++ b/iguana/coins/genbtc.json @@ -1 +1 @@ -{"numhelpers":1,"prefetchlag":11,"poll":1,"active":1,"agent":"iguana","method":"addcoin","newcoin":"BTC","startpend":16,"endpend":16,"services":129,"maxpeers":512,"RELAY":1,"VALIDATE":1,"portp2p":8333} +{"numhelpers":1,"prefetchlag":-1,"poll":1,"active":1,"agent":"iguana","method":"addcoin","newcoin":"BTC","startpend":16,"endpend":16,"services":129,"maxpeers":512,"RELAY":1,"VALIDATE":1,"portp2p":8333} diff --git a/iguana/iguana777.c b/iguana/iguana777.c index aabb1ea42..1065afc56 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -538,15 +538,18 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int 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(2*IGUANA_NUMHELPERS+3); }*/ - if ( helperid < incr ) + if ( convertflag == 0 ) { - for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); - } - 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); + if ( helperid < incr ) + { + for (hdrsi=helperid; hdrsibundles[hdrsi],convertflag); + } + 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); + } } if ( helperid == 0 ) { @@ -691,7 +694,7 @@ void iguana_helper(void *arg) if ( coin->firstRTheight == 0 ) { if ( coin->spendvectorsaved == 1 ) - iguana_utxogen(myinfo,coin,helperid,0); + iguana_utxogen(myinfo,coin,helperid,1); else if ( coin->spendvectorsaved > 1 && (coin->spendvalidated & (1 << helperid)) == 0 ) { //printf("%s spendvectorsaved.%u helperid.%d validate\n",coin->symbol,coin->spendvectorsaved,helperid); diff --git a/iguana/main.c b/iguana/main.c index c92acbce8..eafd09333 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -339,7 +339,12 @@ char *SuperNET_JSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON void iguana_exit(struct supernet_info *myinfo,struct iguana_bundle *bp) { + static int exiting; int32_t i,j,iter; struct iguana_info *coin,*tmp; + if ( exiting != 0 ) + while ( 1 ) + sleep(1); + exiting = 1; if ( myinfo == 0 ) myinfo = SuperNET_MYINFO(0); printf("start EXIT\n"); From 2af3689984f7fc2c33b133d6369c663666fa89b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 05:42:11 -0300 Subject: [PATCH 02/55] test --- iguana/coins/genbtc.json | 2 +- iguana/genbtcloop | 1 + iguana/genbtcloop8 | 1 + iguana/iguana_tx.c | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/iguana/coins/genbtc.json b/iguana/coins/genbtc.json index c2b0314d6..a374ef69d 100755 --- a/iguana/coins/genbtc.json +++ b/iguana/coins/genbtc.json @@ -1 +1 @@ -{"numhelpers":1,"prefetchlag":-1,"poll":1,"active":1,"agent":"iguana","method":"addcoin","newcoin":"BTC","startpend":16,"endpend":16,"services":129,"maxpeers":512,"RELAY":1,"VALIDATE":1,"portp2p":8333} +{"numhelpers":4,"prefetchlag":-1,"poll":1,"active":1,"agent":"iguana","method":"addcoin","newcoin":"BTC","startpend":16,"endpend":16,"services":129,"maxpeers":512,"RELAY":1,"VALIDATE":1,"portp2p":8333} diff --git a/iguana/genbtcloop b/iguana/genbtcloop index 1b8e2d987..7cdd03750 100755 --- a/iguana/genbtcloop +++ b/iguana/genbtcloop @@ -2,5 +2,6 @@ while true do ../agents/iguana coins/genbtc.json sleep 3 +rm -rf tmp done diff --git a/iguana/genbtcloop8 b/iguana/genbtcloop8 index 3fccf5b5c..64686708e 100755 --- a/iguana/genbtcloop8 +++ b/iguana/genbtcloop8 @@ -2,5 +2,6 @@ while true do ../agents/iguana coins/genbtc8.json sleep 3 +rm -rf tmp done diff --git a/iguana/iguana_tx.c b/iguana/iguana_tx.c index c19064a67..98ae3a79e 100755 --- a/iguana/iguana_tx.c +++ b/iguana/iguana_tx.c @@ -237,8 +237,8 @@ int32_t iguana_ramtxbytes(struct iguana_info *coin,uint8_t *serialized,int32_t m *txidp = bits256_doublesha256(txidstr,serialized,len); if ( memcmp(txidp,tx->txid.bytes,sizeof(*txidp)) != 0 ) { - //for (i=0; itxid)); return(-1); } From a47f4eeafb241f82ab552c2c1bbfa1c5bcdfdd71 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 05:48:26 -0300 Subject: [PATCH 03/55] test --- includes/iguana_defines.h | 2 +- includes/iguana_structs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index bd7b3a7b9..b06737dc6 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -57,7 +57,7 @@ #define IGUANA_MAXBUNDLES (50000000 / 500) #define IGUANA_MINPEERS 64 -#define IGUANA_LOG2MAXPEERS 11 +#define IGUANA_LOG2MAXPEERS 10 // affects ramchain data format! #define IGUANA_LOG2PEERFILESIZE 23 #define IGUANA_MAXPEERS (1 << IGUANA_LOG2MAXPEERS) diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index c253b6580..3f3360ed9 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -272,7 +272,7 @@ struct iguana_spend256 { bits256 prevhash2; uint64_t scriptpos:48,vinscriptlen:1 // permanent readonly structs struct iguana_txid { bits256 txid; uint64_t txidind:29,firstvout:28,firstvin:28,bundlei:11,locktime:32,version:32,timestamp:32,extraoffset:32; uint16_t numvouts,numvins; }PACKEDSTRUCT; -struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos; uint16_t scriptlen,hdrsi; uint16_t fileid:11,type:5; int16_t vout; }PACKEDSTRUCT; +struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos; uint16_t scriptlen,hdrsi; uint16_t fileid:IGUANA_LOG2MAXPEERS+1,type:5; int16_t vout; }PACKEDSTRUCT; struct iguana_spend { uint64_t scriptpos:48,scriptlen:16; uint32_t spendtxidind,sequenceid; int16_t prevout; uint16_t fileid:15,external:1; }PACKEDSTRUCT; // numsigs:4,numpubkeys:4,p2sh:1,sighash:4 From e53ed4ab2f10e6b2fbed834a7476de95082335a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 05:51:43 -0300 Subject: [PATCH 04/55] test --- includes/iguana_defines.h | 2 +- includes/iguana_structs.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index b06737dc6..f77c4fd41 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -57,7 +57,7 @@ #define IGUANA_MAXBUNDLES (50000000 / 500) #define IGUANA_MINPEERS 64 -#define IGUANA_LOG2MAXPEERS 10 // affects ramchain data format! +#define IGUANA_LOG2MAXPEERS 11 // cant exceed 13 bits as ramchain unspents has bitfield #define IGUANA_LOG2PEERFILESIZE 23 #define IGUANA_MAXPEERS (1 << IGUANA_LOG2MAXPEERS) diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index 3f3360ed9..e7943207c 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -272,9 +272,9 @@ struct iguana_spend256 { bits256 prevhash2; uint64_t scriptpos:48,vinscriptlen:1 // permanent readonly structs struct iguana_txid { bits256 txid; uint64_t txidind:29,firstvout:28,firstvin:28,bundlei:11,locktime:32,version:32,timestamp:32,extraoffset:32; uint16_t numvouts,numvins; }PACKEDSTRUCT; -struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos; uint16_t scriptlen,hdrsi; uint16_t fileid:IGUANA_LOG2MAXPEERS+1,type:5; int16_t vout; }PACKEDSTRUCT; +struct iguana_unspent { uint64_t value; uint32_t txidind,pkind,prevunspentind,scriptpos,scriptlen:13,fileid:14,type:5; uint16_t hdrsi; int16_t vout; } PACKEDSTRUCT; -struct iguana_spend { uint64_t scriptpos:48,scriptlen:16; uint32_t spendtxidind,sequenceid; int16_t prevout; uint16_t fileid:15,external:1; }PACKEDSTRUCT; // numsigs:4,numpubkeys:4,p2sh:1,sighash:4 +struct iguana_spend { uint64_t scriptpos:48,scriptlen:16; uint32_t spendtxidind,sequenceid; int16_t prevout; uint16_t fileid:14,external:1,tbd:1; }PACKEDSTRUCT; // numsigs:4,numpubkeys:4,p2sh:1,sighash:4 struct iguana_pkhash { uint8_t rmd160[20]; uint32_t pkind; }PACKEDSTRUCT; //firstunspentind,pubkeyoffset From 86a60f7bcde50260aec72bd2a0281ee3c3d512bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 06:05:50 -0300 Subject: [PATCH 05/55] test --- iguana/iguana_blocks.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index 6da36f98e..1b1723f99 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -698,6 +698,12 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan iguana_blockunmark(coin,block,bp,bundlei,0); iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); } + else + { + bp->blocks[bundlei] = block; + bp->hashes[bundlei] = block->RO.hash2; + iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); + } if ( coin->started != 0 && bundlei == coin->minconfirms && (block->height > coin->longestchain-coin->chain->bundlesize*2 || ((block->height / coin->chain->bundlesize) % 100) == 9) ) { //printf("savehdrs.[%d] ht.%d\n",bp->hdrsi,block->height); From 1896d01441c178364442b2ce2b03e2b878e71bbc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 06:31:02 -0300 Subject: [PATCH 06/55] test --- iguana/iguana_blocks.c | 13 ++++++++++--- iguana/iguana_bundles.c | 15 --------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index 1b1723f99..e6cd7a80b 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -654,9 +654,10 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan } struct iguana_bundle *bp; int32_t hdrsi; bundlei = (block->height % coin->chain->bundlesize); + hdrsi = (block->height / coin->chain->bundlesize); if ( bundlei == 0 ) { - if ( (hdrsi= block->height/coin->chain->bundlesize) < coin->bundlescount ) + if ( hdrsi < coin->bundlescount ) { if ( (bp= coin->bundles[hdrsi]) != 0 && bits256_cmp(block->RO.hash2,bp->hashes[0]) != 0 ) { @@ -673,7 +674,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan } else { - if ( (bp= coin->bundles[block->height / coin->chain->bundlesize]) != 0 ) + if ( (bp= coin->bundles[hdrsi]) != 0 ) { if ( memcmp(bp->hashes[bundlei].bytes,block->RO.hash2.bytes,sizeof(bits256)) != 0 || block != bp->blocks[bundlei] ) { @@ -721,7 +722,13 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan process_iguanablock(block->serdata,CHAINPARMS); }*/ iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); - iguana_RTnewblock(myinfo,coin,block); + if ( coin->RTheight > 0 ) + iguana_RTnewblock(myinfo,coin,block); + block->hdrsi = hdrsi; + block->bundlei = bundlei; + bp = coin->bundles[hdrsi]; + if ( bp->blocks[bundlei] != block || bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) + printf("new hwm [%d:%d] mismatched bundle block\n",hdrsi,bundlei); return(block); } } diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index a93f54c2f..936001732 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -1409,21 +1409,6 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch } } } - //printf("lastbp.[%d]\n",lastpending!=0?lastpending->hdrsi:-1); - /*if ( m > 0 ) - { - revsortds(sortbuf,m,sizeof(*sortbuf)*2); - for (i=0; ibundles[(int32_t)sortbuf[i*2 + 1]]) != 0 ) - { - bp->rank = i + 1; - if ( coin->peers.numranked > 0 && i < coin->peers.numranked && (addr= coin->peers.ranked[i]) != 0 ) - addr->bp = bp; - } - } - } - free(sortbuf);*/ coin->numremain = n; coin->blocksrecv = numrecv; uint64_t tmp; int32_t diff,p = 0; struct tai difft,t = tai_now(); From b703fd691339f3fb23cf02d8340b3cdf8ba12741 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 06:40:16 -0300 Subject: [PATCH 07/55] test --- iguana/iguana_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index b0b341207..0d13e0dd0 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -374,6 +374,8 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { if ( iguana_bundleinitmap(myinfo,coin,bp,height,hash2,hash1) == 0 ) lastbundle = hash2, lastheight = height; + else if ( strcmp("BTC",coin->symbol) == 0 ) + break; } } } From cdffdb41ff14bb1b1dbac4941b21f87c879b6c75 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 06:51:34 -0300 Subject: [PATCH 08/55] test --- iguana/iguana_init.c | 7 +++++-- iguana/iguana_recv.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 0d13e0dd0..93809b8de 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -255,7 +255,7 @@ int32_t iguana_bundleinitmap(struct supernet_info *myinfo,struct iguana_info *co void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int32_t iter,FILE *fp) { - int32_t j,k,m,c,flag,bundlei,lastheight,height = -1; char checkstr[1024],line[1024]; + int32_t j,k,m,c,flag,bundlei,lastheight,missing=0,height = -1; char checkstr[1024],line[1024]; struct iguana_peer *addr; struct iguana_bundle *bp; bits256 allhash,hash2,hash1,zero,lastbundle; if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 && iter > 0 ) return; @@ -374,8 +374,11 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { if ( iguana_bundleinitmap(myinfo,coin,bp,height,hash2,hash1) == 0 ) lastbundle = hash2, lastheight = height; - else if ( strcmp("BTC",coin->symbol) == 0 ) + else if ( missing++ > coin->MAXBUNDLES ) + { + printf("missing.%d\n",missing); break; + } } } } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 7527f7c34..9d647e07d 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -769,7 +769,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru origtxdata->zblock.RO.recvlen = 0; printf("gotblockM2: error finding block %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); return; - } else printf("getblockM autoextended.[%d]\n",bp->hdrsi); + } //else printf("getblockM autoextended.[%d]\n",bp->hdrsi); } } if ( bp == 0 ) From 49e50f063d4499cac5be0f4914adebd185648387 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 06:52:02 -0300 Subject: [PATCH 09/55] test --- iguana/coins/genbtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/coins/genbtc b/iguana/coins/genbtc index 4179c8fea..e241aaa34 100755 --- a/iguana/coins/genbtc +++ b/iguana/coins/genbtc @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":256,\"endpend\":256,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" From 28dbdbc60d5f22151ec20e59c37870d00c087d03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 07:29:52 -0300 Subject: [PATCH 10/55] set script in all paths --- iguana/iguana_payments.c | 2 +- iguana/iguana_peers.c | 6 +++--- iguana/iguana_unspents.c | 42 ++++++++++++++++++++++++++++++++------- iguana/tests/rawtx5 | 1 + includes/iguana_defines.h | 6 +----- includes/iguana_structs.h | 6 +++--- 6 files changed, 44 insertions(+), 19 deletions(-) create mode 100755 iguana/tests/rawtx5 diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 5fdbf9143..e9aee0d86 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -381,7 +381,7 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS free(unspents); return(0); } - printf("avail %.8f satoshis %.8f, txfee %.8f burnamount %.8f\n",dstr(avail),dstr(satoshis),dstr(txfee),dstr(burnamount)); + printf("avail %.8f satoshis %.8f, txfee %.8f burnamount %.8f vin0.scriptlen %d\n",dstr(avail),dstr(satoshis),dstr(txfee),dstr(burnamount),unspents[0].spendlen); if ( txobj != 0 && avail >= satoshis+txfee ) { if ( (vins= iguana_RTinputsjson(myinfo,coin,&total,satoshis + txfee,unspents,num)) != 0 ) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index b245392b0..1c11b22a4 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -1188,7 +1188,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin, ipbits = (uint32_t)addr->ipbits; vcalc_sha256(0,addr->iphash.bytes,(uint8_t *)&ipbits,sizeof(ipbits)); //char str[65]; printf("start dedicatedloop.%s addrind.%d %s\n",addr->ipaddr,addr->addrind,bits256_str(str,addr->iphash)); - addr->maxfilehash2 = IGUANA_MAXFILEITEMS; + //addr->maxfilehash2 = IGUANA_MAXFILEITEMS; bufsize = IGUANA_MAXPACKETSIZE; if ( addr->blockspace == 0 ) addr->blockspace = mycalloc('r',1,bufsize + 8192); @@ -1311,8 +1311,8 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin, } iguana_iAkill(coin,addr,addr->dead != 0); myfree(buf,bufsize); - if ( addr->filehash2 != 0 ) - myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0; + //if ( addr->filehash2 != 0 ) + // myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0; if ( 0 ) { iguana_mempurge(&addr->RAWMEM); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 4bd2a1fd9..b28147b75 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -380,6 +380,33 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua else return(bundleheight); } +int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout) +{ + char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t rmd160[20],pubkey33[33]; + memset(outpt,0,sizeof(*outpt)); + outpt->txid = txid; + outpt->vout = vout; + outpt->hdrsi = hdrsi; + outpt->isptr = 0; + outpt->unspentind = unspentind; + outpt->value = u->value; + memset(rmd160,0,sizeof(rmd160)); + memset(pubkey33,0,sizeof(pubkey33)); + if ( iguana_scriptget(coin,scriptstr,0,sizeof(scriptstr),outpt->hdrsi,outpt->unspentind,outpt->txid,outpt->vout,rmd160,u->type,pubkey33) != 0 ) + { + outpt->spendlen = (int32_t)strlen(scriptstr) >> 1; + if ( outpt->spendlen < sizeof(outpt->spendscript) ) + decode_hex(outpt->spendscript,outpt->spendlen,scriptstr); + else + { + outpt->spendlen = 0; + printf("error scriptstr.(%s) is too big for %d\n",scriptstr,(int32_t)sizeof(outpt->spendscript)); + return(-1); + } + } + return(0); +} + int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]) { int64_t deposits,crypto777_payment; struct iguana_outpoint lastpt; uint32_t unspentind; int32_t i,j,num,uheight; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; struct iguana_pkhash *P,p; struct iguana_unspent *U,*u; struct iguana_txid *T,*tx; @@ -438,6 +465,13 @@ int32_t iguana_RTscanunspents(struct supernet_info *myinfo,struct iguana_info *c outpt.vout = unspent->vout; outpt.value = unspent->value; outpt.hdrsi = unspent->height / coin->chain->bundlesize; + if ( (outpt.spendlen= unspent->scriptlen) > 0 && outpt.spendlen < sizeof(outpt.spendscript) ) + memcpy(outpt.spendscript,unspent->script,outpt.spendlen); + else + { + printf("spendscript.%d doesnt fit into %d\n",outpt.spendlen,(int32_t)sizeof(outpt.spendscript)); + outpt.spendlen = 0; + } if ( array != 0 ) jaddi(array,iguana_RTunspentjson(myinfo,coin,outpt,txid,unspent->vout,unspent->value,0,rmd160,coinaddr,pubkey33,spentheight,remoteaddr)); *depositsp += unspent->value; @@ -495,13 +529,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info * { //printf("u%u ",unspentind); deposits += U[unspentind].value; - memset(&outpt,0,sizeof(outpt)); - outpt.txid = T[U[unspentind].txidind].txid; - outpt.vout = unspentind - T[U[unspentind].txidind].firstvout; - outpt.hdrsi = lastpt.hdrsi; - outpt.isptr = 0; - outpt.unspentind = unspentind; - outpt.value = U[unspentind].value; + iguana_outpt_set(coin,&outpt,&U[unspentind],unspentind,lastpt.hdrsi,T[U[unspentind].txidind].txid,unspentind - T[U[unspentind].txidind].firstvout); RTspend = 0; if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,lastheight,minconf,maxconf,U[unspentind].value) == 0 ) { diff --git a/iguana/tests/rawtx5 b/iguana/tests/rawtx5 new file mode 100755 index 000000000..ce5f72611 --- /dev/null +++ b/iguana/tests/rawtx5 @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"agent\":\"basilisk\",\"method\":\"rawtx\",\"vals\":{\"changeaddr\":\"RD1rFucYCMhCGeEqdztivP3DFdJwVAzXn7\",\"addresses\":[\"RD1rFucYCMhCGeEqdztivP3DFdJwVAzXn7\"],\"timeout\":15000,\"satoshis\":\"130000\",\"spendscript\":\"76a9145da2ae69885741a6946e01ad8aa8b5312eed856088ac\"}}" diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index f77c4fd41..68341612e 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -58,15 +58,11 @@ #define IGUANA_MINPEERS 64 #define IGUANA_LOG2MAXPEERS 11 // cant exceed 13 bits as ramchain unspents has bitfield -#define IGUANA_LOG2PEERFILESIZE 23 #define IGUANA_MAXPEERS (1 << IGUANA_LOG2MAXPEERS) -#define IGUANA_LOG2PACKETSIZE 21 #define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE) -#define IGUANA_PEERFILESIZE (1 << IGUANA_LOG2PEERFILESIZE) -struct iguana_txdatabits { uint64_t addrind:IGUANA_LOG2MAXPEERS,filecount:10,fpos:IGUANA_LOG2PEERFILESIZE,datalen:IGUANA_LOG2PACKETSIZE,isdir:1; }; -#define IGUANA_MAXFILEITEMS 8192 +//#define IGUANA_MAXFILEITEMS 8192 #define IGUANA_RECENTPEER (3600 * 24 * 7) #define IGUANA_PERMTHREAD 0 diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index e7943207c..800701b23 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -183,7 +183,7 @@ struct iguana_packet { struct queueitem DL; struct iguana_peer *addr; struct tai struct msgcounts { uint32_t version,verack,getaddr,addr,inv,getdata,notfound,getblocks,getheaders,headers,tx,block,mempool,ping,pong,reject,filterload,filteradd,filterclear,merkleblock,alert; }; -struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; }; +//struct iguana_fileitem { bits256 hash2; struct iguana_txdatabits txdatabits; }; struct iguana_kvitem { UT_hash_handle hh; uint8_t keyvalue[]; }PACKEDSTRUCT; @@ -349,7 +349,7 @@ struct iguana_peer struct msgcounts msgcounts; struct OS_memspace RAWMEM,TXDATA,HASHMEM; struct iguana_ramchain ramchain; - struct iguana_fileitem *filehash2; int32_t numfilehash2,maxfilehash2; + //struct iguana_fileitem *filehash2; int32_t numfilehash2,maxfilehash2; FILE *voutsfp,*vinsfp; uint8_t *blockspace;//[IGUANA_MAXPACKETSIZE + 8192]; #ifdef IGUANA_PEERALLOC @@ -391,7 +391,7 @@ struct iguana_bundlereq { struct queueitem DL; struct iguana_info *coin; int32_t type; struct iguana_peer *addr; struct iguana_zblock *blocks; bits256 *hashes,txid; - struct iguana_txdatabits txdatabits; + //struct iguana_txdatabits txdatabits; struct iguana_msghdr H; int32_t allocsize,datalen,n,recvlen,numtx; uint32_t ipbits; struct iguana_zblock zblock; From 3b69c360ec729f4ec41f7c42a1453079e3426f4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 08:21:57 -0300 Subject: [PATCH 11/55] test sendtimeout --- iguana/iguana_init.c | 2 +- iguana/iguana_peers.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 93809b8de..6212ec57a 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -374,7 +374,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { if ( iguana_bundleinitmap(myinfo,coin,bp,height,hash2,hash1) == 0 ) lastbundle = hash2, lastheight = height; - else if ( missing++ > coin->MAXBUNDLES ) + else if ( missing++ > coin->MAXBUNDLES && strcmp("BTC",coin->symbol) == 0 ) { printf("missing.%d\n",missing); break; diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 1c11b22a4..0664f64bb 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -392,6 +392,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) timeout.tv_sec = 0; timeout.tv_usec = 30000; setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); } opt = 0; getsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,(void *)&opt,&slen); From 4f5562c0a5595d55f8b45da23ecedde0b69ce6ba Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 08:30:59 -0300 Subject: [PATCH 12/55] test --- iguana/iguana_peers.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 0664f64bb..640c425b8 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -500,6 +500,11 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s if ( (numsent= (int32_t)send(usock,serialized,remains,MSG_NOSIGNAL)) < 0 ) #endif { + if ( errno == EAGAIN ) + { + sleep(1); + continue; + } printf("send errno.%d %s\n",errno,strerror(errno)); if ( errno != EAGAIN && errno != EWOULDBLOCK ) { From 40a87e0da13a640decd0bc0c3f6fa012b420d9c8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 08:48:41 -0300 Subject: [PATCH 13/55] test --- iguana/coins/genbtcd | 2 +- iguana/iguana_init.c | 2 +- iguana/iguana_peers.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/iguana/coins/genbtcd b/iguana/coins/genbtcd index 718f77179..7accd6897 100755 --- a/iguana/coins/genbtcd +++ b/iguana/coins/genbtcd @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":11,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"minconfirms\":5}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":11,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":256,\"endpend\":256,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"minconfirms\":5}" diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 6212ec57a..1e9704fb3 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -302,7 +302,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 //printf("parse line.(%s) maxpeers.%d\n",line,coin->MAXPEERS); if ( iter == 0 ) { - if ( (m < 8 || (rand() % 2) == 0) && (m < 32 || m < coin->MAXPEERS/2) )//&& m < 77.7 ) + if ( (rand() % 2) == 0 && m < coin->MAXPEERS/2 ) { if ( 0 && m == 0 ) { diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 640c425b8..ad9c406a5 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -502,8 +502,9 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s { if ( errno == EAGAIN ) { - sleep(1); - continue; + addr->persistent_peer = 1; + //sleep(1); + //continue; } printf("send errno.%d %s\n",errno,strerror(errno)); if ( errno != EAGAIN && errno != EWOULDBLOCK ) From 69f7872816d3fc88e41864f3ae6a4062541ad6e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 09:08:14 -0300 Subject: [PATCH 14/55] test --- iguana/confs/BTCD_peers.txt | 157 +++++++++++++++++------------------- iguana/iguana_init.c | 13 +-- iguana/iguana_peers.c | 7 +- 3 files changed, 88 insertions(+), 89 deletions(-) diff --git a/iguana/confs/BTCD_peers.txt b/iguana/confs/BTCD_peers.txt index 5226d6ac8..f954be17e 100644 --- a/iguana/confs/BTCD_peers.txt +++ b/iguana/confs/BTCD_peers.txt @@ -7,84 +7,79 @@ 89.248.160.243 89.248.160.244 89.248.160.245 -85.25.217.233 -65.15.37.140 -62.75.145.171 -176.9.13.13 -88.198.15.19 -51.255.38.28 -121.108.241.247 -82.229.201.131 -162.13.4.69 -78.226.160.96 -115.28.42.60 -178.62.185.131 -167.114.249.196 -81.181.155.53 -76.169.236.235 -67.165.77.192 -75.130.163.51 -72.55.148.203 -96.127.136.18 -88.198.53.194 -63.247.147.166 -88.206.186.58 -217.8.62.188 -46.231.137.186 -217.215.190.134 -2.86.63.69 -59.147.43.232 -104.42.224.48 -24.168.17.50 -173.65.129.85 -84.119.62.223 -59.147.43.232 -2.239.61.146 -176.28.45.179 -73.211.90.130 -185.48.78.78 -77.21.104.176 -46.253.169.134 -163.172.156.107 -74.120.222.234 -192.99.233.217 -162.255.117.105 -188.166.91.37 -149.56.122.72 -71.1.13.122 -88.113.76.138 -81.205.30.207 -203.189.127.54 -68.190.213.46 -98.202.147.55 -89.212.19.49 -162.210.92.46 -115.70.19.28 -68.43.220.127 -79.227.171.148 -68.46.103.181 -98.207.117.83 -79.200.255.204 -82.8.59.60 -71.241.204.215 -108.247.198.39 -156.57.141.221 -92.26.168.113 -71.53.157.49 -68.45.147.145 -79.54.185.53 -110.202.11.148 -91.82.171.9 -74.14.104.167 -95.116.195.148 -90.113.82.59 -98.118.105.12 -82.241.71.230 -98.161.16.55 -89.248.160.237 -93.211.231.89 -2.26.181.156 -89.248.160.244 -89.248.160.243 -89.248.160.242 -89.248.160.241 +5.9.102.210 +78.47.196.146 +85.25.217.233:14631 +88.198.53.194:55692 +88.206.186.58:37299 +162.255.117.105:63084 +115.28.42.60:60878 +82.176.15.155:35026 +88.198.15.19:48150 +176.9.13.13:14631 +217.8.62.188:52714 +162.13.4.69:55410 +211.58.177.43:35581 +63.247.147.166:50266 +24.168.17.50:50793 +46.231.137.186:56963 +178.62.185.131:35572 +62.75.145.171:14631 +89.212.19.49:48018 +192.99.233.217:42232 +68.190.213.46:14631 +162.210.92.46:14631 +98.118.105.12:60805 +75.130.163.51:56719 +51.255.38.28:14631 +88.110.117.18:52158 +24.101.114.249:55457 +99.44.222.86:62377 +108.61.166.209:58365 +98.208.113.72:62065 +72.133.226.130:14631 +5.189.144.97:58243 +14.203.46.202:57987 +98.202.147.55:60460 +24.45.172.109:14631 +89.114.38.65:52768 +68.59.64.126:50633 +68.43.220.127:4303 +81.205.30.207:63077 +113.87.28.142:62764 +73.211.90.130:41271 +110.174.129.213:49252 +68.45.147.145:57803 +95.232.175.161:62633 +73.229.133.160:38440 +124.191.14.253:54342 +167.114.249.196:52705 +92.24.168.248:52892 +93.158.216.201:14631 +158.69.27.82:46643 +104.204.109.11:63390 +68.157.88.187:56711 +71.53.152.87:5234 +82.229.201.131:63466 +59.147.42.146:57461 +81.0.91.211:53187 +82.241.71.230:51945 +108.247.198.39:64094 +77.22.227.8:65093 +122.166.169.11:49325 +173.76.182.122:14631 +173.24.82.253:14631 +100.13.54.119:14631 +2.26.181.208:14631 +94.242.213.3:14631 +87.149.45.42:36077 +98.207.117.83:50955 +71.1.8.48:14631 +71.1.8.48:50439 +101.166.241.31:14631 +178.143.154.142:27497 +103.255.7.59:58660 +156.57.132.119:62428 +60.225.171.82:36834 +46.223.149.120:43358 +37.157.215.75:4162 diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 1e9704fb3..e15f033dc 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -302,7 +302,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 //printf("parse line.(%s) maxpeers.%d\n",line,coin->MAXPEERS); if ( iter == 0 ) { - if ( (rand() % 2) == 0 && m < coin->MAXPEERS/2 ) + if ( m < coin->MAXPEERS/2 ) { if ( 0 && m == 0 ) { @@ -312,10 +312,13 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); } #ifndef IGUANA_DISABLEPEERS - addr = &coin->peers->active[m++]; - iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line)); - //printf("call initpeer.(%s)\n",addr->ipaddr); - iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); + //if ( (rand() % 2) == 0 ) + { + addr = &coin->peers->active[m++]; + iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line)); + //printf("call initpeer.(%s)\n",addr->ipaddr); + iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); + } //else iguana_possible_peer(coin,line); #endif } } diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index ad9c406a5..976ff9f12 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -392,6 +392,8 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) timeout.tv_sec = 0; timeout.tv_usec = 30000; setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + timeout.tv_sec = 0; + timeout.tv_usec = 10000; setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); } opt = 0; @@ -506,14 +508,13 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s //sleep(1); //continue; } - printf("send errno.%d %s\n",errno,strerror(errno)); - if ( errno != EAGAIN && errno != EWOULDBLOCK ) + //if ( errno != EAGAIN && errno != EWOULDBLOCK ) { printf("%s: %s numsent.%d vs remains.%d len.%d errno.%d (%s) usock.%d\n",serialized+4,addr->ipaddr,numsent,remains,len,errno,strerror(errno),addr->usock); printf("bad errno.%d %s zombify.%p\n",errno,strerror(errno),&addr->dead); addr->dead = (uint32_t)time(NULL); return(-errno); - } //else usleep(*sleeptimep), *sleeptimep *= 1.1; + } } else if ( remains > 0 ) { From 98306f9a99c01e63c3dcd2539b76229660f8c7a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 09:15:25 -0300 Subject: [PATCH 15/55] test --- iguana/iguana_init.c | 5 +++-- iguana/iguana_peers.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index e15f033dc..302c9f5da 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -316,11 +316,12 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { addr = &coin->peers->active[m++]; iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line)); - //printf("call initpeer.(%s)\n",addr->ipaddr); + printf("call initpeer.(%s)\n",addr->ipaddr); iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); - } //else iguana_possible_peer(coin,line); + } //else #endif } + iguana_possible_peer(coin,line); } else { diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 976ff9f12..58e2f5aad 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -898,7 +898,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers->active[i].ipbits); return(0); } - //printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); + printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1); return((uint32_t)time(NULL)); } @@ -934,7 +934,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) ipaddr[i] = 0; break; } - //printf("%s check possible peer.(%s)\n",coin->symbol,ipaddr); + printf("%s check possible peer.(%s)\n",coin->symbol,ipaddr); if ( (ipbits= calc_ipbits(ipaddr)) != 0 ) { expand_ipbits(checkaddr,ipbits); From 478dce63d0987ab81bb8cea8c5119a65499b1f13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 09:28:55 -0300 Subject: [PATCH 16/55] test --- iguana/iguana_init.c | 2 +- iguana/iguana_peers.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 302c9f5da..1bd3aed74 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -316,7 +316,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { addr = &coin->peers->active[m++]; iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line)); - printf("call initpeer.(%s)\n",addr->ipaddr); + //printf("call initpeer.(%s)\n",addr->ipaddr); iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); } //else #endif diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 58e2f5aad..976ff9f12 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -898,7 +898,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) printf("%s possible peer.(%s) %x already there\n",coin->symbol,ipaddr,(uint32_t)coin->peers->active[i].ipbits); return(0); } - printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); + //printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1); return((uint32_t)time(NULL)); } @@ -934,7 +934,7 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) ipaddr[i] = 0; break; } - printf("%s check possible peer.(%s)\n",coin->symbol,ipaddr); + //printf("%s check possible peer.(%s)\n",coin->symbol,ipaddr); if ( (ipbits= calc_ipbits(ipaddr)) != 0 ) { expand_ipbits(checkaddr,ipbits); From 0cf2b4ba209448dbd03293d0525479d892898f6b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 12:28:31 -0300 Subject: [PATCH 17/55] socket options --- .gitignore | 4 ++++ iguana/iguana_peers.c | 18 ++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 5370c8638..92b11bd00 100755 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ agents/* iguana/confs/BTC_hdrs.txt + +deprecated/.DS_Store + +.DS_Store diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 976ff9f12..b7404656e 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -387,21 +387,19 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) #ifndef WIN32 if ( 1 )//&& bindflag != 0 ) { - if ( 1 ) - { - timeout.tv_sec = 0; - timeout.tv_usec = 30000; - setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); - } opt = 0; getsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,(void *)&opt,&slen); opt = 1; //printf("keepalive.%d\n",opt); - } else setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)); + } + setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)); #ifdef __APPLE__ + timeout.tv_sec = 0; + timeout.tv_usec = 30000; + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); setsockopt(sock,SOL_SOCKET,SO_NOSIGPIPE,&opt,sizeof(opt)); #endif #endif From d5975af4584fe580eae223669deae30f2f333d0c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 12:31:41 -0300 Subject: [PATCH 18/55] ifdef unistd --- crypto777/jpeg/unix/jmemname.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crypto777/jpeg/unix/jmemname.c b/crypto777/jpeg/unix/jmemname.c index 631bd8922..9db4408eb 100755 --- a/crypto777/jpeg/unix/jmemname.c +++ b/crypto777/jpeg/unix/jmemname.c @@ -11,7 +11,9 @@ * Also, the problem of determining the amount of memory available * is shoved onto the user. */ -//#include +#ifndef WIN32 +#include +#endif #define JPEG_INTERNALS #include "../jinclude.h" From 63ee0cdb398c75572a1e5c99a76e88e0d93798a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 12:59:09 -0300 Subject: [PATCH 19/55] move timeouts --- iguana/iguana_peers.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index b7404656e..cfb5218fb 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -394,12 +394,6 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) } setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)); #ifdef __APPLE__ - timeout.tv_sec = 0; - timeout.tv_usec = 30000; - setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); - timeout.tv_sec = 0; - timeout.tv_usec = 10000; - setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); setsockopt(sock,SOL_SOCKET,SO_NOSIGPIPE,&opt,sizeof(opt)); #endif #endif @@ -442,6 +436,12 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } + timeout.tv_sec = 0; + timeout.tv_usec = 30000; + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); if ( listen(sock,64) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); From 00a312abbeb23d6e060a317a33fe5fd7d09796b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 13:18:22 -0300 Subject: [PATCH 20/55] disable timeout --- iguana/iguana_peers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index cfb5218fb..465751a62 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -437,11 +437,11 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) } } timeout.tv_sec = 0; - timeout.tv_usec = 30000; - setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + timeout.tv_usec = 1000000; + //setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; - timeout.tv_usec = 10000; - setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); + timeout.tv_usec = 1000000; + //setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); if ( listen(sock,64) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); From 87d16fffcd783d7fb1b67c640b0f867a8bc3e7a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 13:24:00 -0300 Subject: [PATCH 21/55] fix missing wit crash --- iguana/iguana_wallet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index ff8bb7842..ef1eca8a2 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1411,6 +1411,8 @@ TWOSTRINGS_AND_INT(bitcoinrpc,importprivkey,wif,account,rescan) return(clonestr("{\"error\":\"no remote\"}")); if ( myinfo->expiration == 0 ) return(clonestr("{\"error\":\"need to unlock wallet\"}")); + if ( wif == 0 ) + return(clonestr("{\"error\":\"missing wif\"}")); myinfo->expiration++; if ( account == 0 || account[0] == 0 ) account = "default"; From ff10d6cbb54368c33fe2b052dd03466121903a12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 13:47:26 -0300 Subject: [PATCH 22/55] osx tweak --- iguana/iguana_peers.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 465751a62..f1918c07d 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -436,12 +436,14 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } +#ifdef __APPLE__ timeout.tv_sec = 0; timeout.tv_usec = 1000000; - //setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; timeout.tv_usec = 1000000; - //setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); + setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); +#endif if ( listen(sock,64) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); From ce4202e4ac31fc5a9affe0c6c5bcd6cb7bb60b6e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:03:39 -0300 Subject: [PATCH 23/55] timeouts --- iguana/iguana_peers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index f1918c07d..c75d1bdaf 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -436,14 +436,14 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } -#ifdef __APPLE__ +//#ifdef __APPLE__ timeout.tv_sec = 0; - timeout.tv_usec = 1000000; + timeout.tv_usec = 30000; setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; - timeout.tv_usec = 1000000; + timeout.tv_usec = 1000; setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); -#endif +//#endif if ( listen(sock,64) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); From 7949e7f8de20dedc3a1ee036a1dbc40637ffa413 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:06:03 -0300 Subject: [PATCH 24/55] timeout connect --- iguana/iguana_peers.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index c75d1bdaf..de470f158 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -399,6 +399,9 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) #endif if ( bindflag == 0 ) { + timeout.tv_sec = 10; + timeout.tv_usec = 0; + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); result = connect(sock,(struct sockaddr *)&saddr,addrlen); if ( result != 0 ) { From 87ec01958f5fae5cf15888710de232352a5b611e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:12:14 -0300 Subject: [PATCH 25/55] fix null asmstr --- iguana/iguana_scripts.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_scripts.c b/iguana/iguana_scripts.c index 6e9220a43..7997f06a2 100755 --- a/iguana/iguana_scripts.c +++ b/iguana/iguana_scripts.c @@ -562,7 +562,9 @@ char *iguana_scriptget(struct iguana_info *coin,char *scriptstr,char *asmstr,int { int32_t scriptlen; uint8_t script[IGUANA_MAXSCRIPTSIZE]; struct vin_info V,*vp = &V; memset(vp,0,sizeof(*vp)); - scriptstr[0] = asmstr[0] = 0; + scriptstr[0] = 0; + if ( asmstr != 0 ) + asmstr[0] = 0; if ( pubkey33 != 0 && bitcoin_pubkeylen(pubkey33) > 0 ) memcpy(vp->signers[0].pubkey,pubkey33,33); scriptlen = iguana_scriptgen(coin,&vp->M,&vp->N,vp->coinaddr,script,asmstr,rmd160,type,(const struct vin_info *)vp,vout); From a452fc83c1b04d0afce362d036f7f94e5ead8fe7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:18:21 -0300 Subject: [PATCH 26/55] test --- iguana/iguana_unspents.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index b28147b75..b27f12b64 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -382,7 +382,7 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout) { - char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t rmd160[20],pubkey33[33]; + char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; uint8_t rmd160[20],pubkey33[33]; memset(outpt,0,sizeof(*outpt)); outpt->txid = txid; outpt->vout = vout; @@ -392,8 +392,9 @@ int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt, outpt->value = u->value; memset(rmd160,0,sizeof(rmd160)); memset(pubkey33,0,sizeof(pubkey33)); - if ( iguana_scriptget(coin,scriptstr,0,sizeof(scriptstr),outpt->hdrsi,outpt->unspentind,outpt->txid,outpt->vout,rmd160,u->type,pubkey33) != 0 ) + if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),outpt->hdrsi,outpt->unspentind,outpt->txid,outpt->vout,rmd160,u->type,pubkey33) != 0 ) { + printf("scriptstr.(%s)\n",scriptstr); outpt->spendlen = (int32_t)strlen(scriptstr) >> 1; if ( outpt->spendlen < sizeof(outpt->spendscript) ) decode_hex(outpt->spendscript,outpt->spendlen,scriptstr); @@ -993,8 +994,8 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi jaddstr(vals,"coin",coin->symbol); jaddnum(vals,"history",1); jaddnum(vals,"firstheight",0); - jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); - jaddnum(vals,"numrequired",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); + jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); + jaddnum(vals,"numrequired",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jadd(vals,"addresses",jduplicate(argarray)); if ( (retstr= basilisk_standardservice("BAL",myinfo,0,hash,vals,"",1)) != 0 ) { From fac139728ea52052e6cf39c8f9ed7b99a7270669 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:19:50 -0300 Subject: [PATCH 27/55] voting --- basilisk/basilisk copy.c | 1160 --------------------------------- basilisk/basilisk.c | 57 +- basilisk/basilisk_CMD.c | 75 ++- basilisk/basilisk_DEX.c | 12 +- basilisk/basilisk_MSG.c | 10 +- basilisk/basilisk_bitcoin.c | 14 +- basilisk/basilisk_ping.c | 24 +- basilisk/basilisk_vote.c | 405 ++++++++++++ datachain/datachain.c | 2 +- gecko/gecko_blocks.c | 2 +- gecko/gecko_mempool.c | 16 +- iguana/iguana777.c | 4 +- iguana/iguana777.h | 9 +- iguana/iguana_chains.c | 6 +- iguana/iguana_init.c | 8 +- iguana/main.c | 26 +- includes/iguana_apideclares.h | 2 + includes/iguana_defines.h | 1 + includes/iguana_funcs.h | 4 +- includes/iguana_globals.h | 4 +- 20 files changed, 557 insertions(+), 1284 deletions(-) delete mode 100755 basilisk/basilisk copy.c create mode 100755 basilisk/basilisk_vote.c diff --git a/basilisk/basilisk copy.c b/basilisk/basilisk copy.c deleted file mode 100755 index 5b9a88c04..000000000 --- a/basilisk/basilisk copy.c +++ /dev/null @@ -1,1160 +0,0 @@ -/****************************************************************************** - * Copyright © 2014-2016 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#include "../iguana/iguana777.h" - -typedef char *basilisk_coinfunc(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen); -typedef char *basilisk_servicefunc(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk); -typedef struct basilisk_item *basilisk_requestfunc(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 hash,cJSON *valsobj,uint8_t *data,int32_t datalen); - -uint32_t basilisk_calcnonce(struct supernet_info *myinfo,uint8_t *data,int32_t datalen,uint32_t nBits) -{ - int32_t i,numiters = 0; bits256 hash,hash2,threshold; uint32_t basilisktag; - vcalc_sha256(0,hash.bytes,data,datalen); - threshold = bits256_from_compact(nBits); - for (i=0; i 0 ) - break; - } - iguana_rwnum(0,(void *)hash.uints,sizeof(basilisktag),&basilisktag); - iguana_rwnum(1,&data[-sizeof(basilisktag)],sizeof(basilisktag),&basilisktag); - char str[65],str2[65]; printf("found hash after numiters.%d %s vs %s basilisktag.%u\n",numiters,bits256_str(str,threshold),bits256_str(str2,hash2),basilisktag); - return(basilisktag); -} - -char *basilisk_addhexstr(char **ptrp,cJSON *valsobj,char *strbuf,int32_t strsize,uint8_t *data,int32_t datalen) -{ - *ptrp = 0; - if ( data != 0 && datalen > 0 ) - { - if ( valsobj != 0 && jobj(valsobj,"data") != 0 ) - { - printf("basilisk_addhexstr warning: already have data object\n"); - jdelete(valsobj,"data"); - } - if ( (datalen<<1)+1 > strsize ) - { - strbuf = calloc(1,(datalen << 1) + 1); - *ptrp = (void *)strbuf; - } - init_hexbytes_noT(strbuf,data,datalen); - if ( valsobj != 0 ) - jaddstr(valsobj,"data",strbuf); - } else return(0); - return(strbuf); -} - -uint8_t *get_dataptr(int32_t hdroffset,uint8_t **ptrp,int32_t *datalenp,uint8_t *space,int32_t spacesize,char *hexstr) -{ - *ptrp = 0; uint8_t *data = 0; - if ( hexstr != 0 && (*datalenp= is_hexstr(hexstr,0)) > 0 ) - { - *datalenp >>= 1; - if ( (*datalenp+hdroffset) <= spacesize ) - { - memset(space,0,hdroffset); - data = &space[hdroffset]; - } else *ptrp = data = calloc(1,*datalenp + hdroffset); - decode_hex(&data[hdroffset],*datalenp,hexstr); - } - if ( data != 0 ) - return(&data[hdroffset]); - else return(data); -} - -uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag) -{ - char *sendstr,*hexstr=0; uint8_t *data,hexspace[8192],*allocptr=0,*hexdata; int32_t datalen,hexlen=0; - if ( jobj(sendjson,"symbol") == 0 ) - jaddstr(sendjson,"symbol",symbol); - if ( (hexstr= jstr(sendjson,"data")) != 0 ) - { - hexdata = get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr); - //printf("delete data.%s from sendjson\n",hexstr); - jdelete(sendjson,"data"); - } - *ptrp = 0; - sendstr = jprint(sendjson,0); - datalen = (int32_t)strlen(sendstr) + 1; - if ( (datalen + extraoffset + BASILISK_HDROFFSET + hexlen) <= spacesize ) - data = space; - else - { - data = calloc(1,datalen + extraoffset + BASILISK_HDROFFSET + hexlen); - *ptrp = data; - } - data += extraoffset + BASILISK_HDROFFSET; - memcpy(data,sendstr,datalen); - //printf("jsondata.(%s) + hexlen.%d\n",sendstr,hexlen); - free(sendstr); - if ( hexlen > 0 ) - { - memcpy(&data[datalen],hexdata,hexlen); - datalen += hexlen; - } - *datalenp = datalen; - if ( allocptr != 0 ) - free(allocptr); - return(data); -} - -char *basilisk_finish(struct basilisk_item *ptr,int32_t besti,char *errstr) -{ - char *retstr = 0; struct basilisk_item *parent; - if ( ptr->retstr != 0 ) - return(ptr->retstr); - if ( besti >= 0 && besti < ptr->numresults ) - { - retstr = ptr->results[besti]; - ptr->results[besti] = 0; - } else printf("besti.%d vs numresults.%d retstr.%p\n",besti,ptr->numresults,retstr); - if ( retstr == 0 ) - retstr = clonestr(errstr); - ptr->retstr = retstr; - ptr->finished = (uint32_t)time(NULL); - if ( (parent= ptr->parent) != 0 ) - { - ptr->parent = 0; - parent->childrendone++; - } - return(retstr); -} - -struct basilisk_item *basilisk_itemcreate(struct supernet_info *myinfo,char *CMD,char *symbol,uint32_t basilisktag,int32_t minresults,cJSON *vals,int32_t timeoutmillis,void *metricfunc) -{ - struct basilisk_item *ptr; - ptr = calloc(1,sizeof(*ptr)); - ptr->basilisktag = basilisktag; - if ( (ptr->numrequired= minresults) == 0 ) - ptr->numrequired = 1; - if ( (ptr->metricfunc= metricfunc) != 0 ) - ptr->vals = jduplicate(vals); - strcpy(ptr->CMD,CMD); - safecopy(ptr->symbol,symbol,sizeof(ptr->symbol)); - ptr->expiration = OS_milliseconds() + timeoutmillis; - return(ptr); -} - -int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *type,uint32_t *basilisktagp,int32_t encryptflag,int32_t delaymillis,uint8_t *data,int32_t datalen,int32_t fanout,uint32_t nBits) // data must be offset by sizeof(iguana_msghdr)+sizeof(basilisktag) -{ - int32_t i,r,l,s,val,n=0,retval = -1; char cmd[12]; struct iguana_info *coin,*tmp; struct iguana_peer *addr; bits256 hash; uint32_t *alreadysent; - if ( fanout <= 0 ) - fanout = BASILISK_MINFANOUT; - else if ( fanout > BASILISK_MAXFANOUT ) - fanout = BASILISK_MAXFANOUT; - if ( type == 0 ) - type = "BTCD"; - if ( strlen(type) > 3 ) - { - printf("basilisk_sendcmd illegal type(%s)\n",type); - return(-1); - } - if ( destipaddr != 0 ) - { - if ( destipaddr[0] == 0 ) - destipaddr = 0; // broadcast - else if ( strcmp(destipaddr,"127.0.0.1") == 0 ) - { - printf("return after locally basilisk_msgprocess\n"); - hash = GENESIS_PUBKEY; - basilisk_msgprocess(myinfo,0,0,type,*basilisktagp,data,datalen); - return(0); - } - } - alreadysent = calloc(IGUANA_MAXPEERS * IGUANA_MAXCOINS,sizeof(*alreadysent)); - iguana_rwnum(1,&data[-sizeof(*basilisktagp)],sizeof(*basilisktagp),basilisktagp); - if ( *basilisktagp == 0 ) - { - if ( nBits != 0 ) - *basilisktagp = basilisk_calcnonce(myinfo,data,datalen,nBits); - else *basilisktagp = rand(); - iguana_rwnum(1,&data[-sizeof(*basilisktagp)],sizeof(*basilisktagp),basilisktagp); - } - data -= sizeof(*basilisktagp), datalen += sizeof(*basilisktagp); - memset(cmd,0,sizeof(cmd)); - sprintf(cmd,"SuperNET%s",type); - r = rand(); - //portable_mutex_lock(&Allcoins_mutex); - HASH_ITER(hh,myinfo->allcoins,coin,tmp) - { - if ( coin->peers == 0 ) - continue; - if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 ) - cmd[0] = 's'; - else cmd[0] = 'S'; - for (l=0; lpeers->active[i]; - if ( addr->usock >= 0 ) - { - for (s=0; sipbits ) - break; - //printf("%s s.%d vs n.%d\n",addr->ipaddr,s,n); - if ( s == n && (addr->supernet != 0 || addr->basilisk != 0) && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) ) - { - //printf("[%s].tag%d send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast"); - if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 ) - { - void *ptr; uint8_t *cipher,space[8192]; int32_t cipherlen; bits256 privkey; - cmd[6] = 'e', cmd[7] = 't'; - memset(privkey.bytes,0,sizeof(privkey)); - if ( (cipher= SuperNET_ciphercalc(&ptr,&cipherlen,&privkey,&addr->pubkey,data,datalen,space,sizeof(space))) != 0 ) - { - if ( (val= iguana_queue_send(addr,delaymillis,&cipher[-sizeof(struct iguana_msghdr)],cmd,cipherlen)) >= cipherlen ) - n++; - if ( ptr != 0 ) - free(ptr); - } - } - else - { - cmd[6] = 'E', cmd[7] = 'T'; - if ( (val= iguana_queue_send(addr,delaymillis,&data[-sizeof(struct iguana_msghdr)],cmd,datalen)) >= datalen ) - { - alreadysent[n++] = (uint32_t)addr->ipbits; - if ( n >= IGUANA_MAXPEERS*IGUANA_MAXCOINS ) - break; - } - } - if ( destipaddr != 0 || (fanout > 0 && n >= fanout) ) - { - free(alreadysent); - return(val); - } - else if ( val > retval ) - retval = val; - } - } - } - if ( n >= IGUANA_MAXPEERS*IGUANA_MAXCOINS ) - break; - } - //portable_mutex_unlock(&Allcoins_mutex); - free(alreadysent); - return(n); -} - -void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t datalen,char *type,int32_t encrypted) -{ - uint32_t ipbits,basilisktag; int32_t msglen,len=0; void *ptr = 0; uint8_t space[8192]; bits256 senderpub; struct supernet_info *myinfo = _myinfo; - if ( encrypted != 0 ) - { - printf("encrypted p2p\n"); - memset(senderpub.bytes,0,sizeof(senderpub)); - if ( (data= SuperNET_deciphercalc(&ptr,&msglen,myinfo->privkey,senderpub,data,datalen,space,sizeof(space))) == 0 ) - { - printf("basilisk_p2p decrytion error\n"); - return; - } else datalen = msglen; - } - if ( senderip != 0 && senderip[0] != 0 && strcmp(senderip,"127.0.0.1") != 0 ) - ipbits = (uint32_t)calc_ipbits(senderip); - else ipbits = 0; - len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag); - //int32_t i; for (i=0; ireceived.%d basilisk_p2p.(%s) from %s tag.%d\n",datalen,type,senderip!=0?senderip:"?",basilisktag); - basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len); - if ( ptr != 0 ) - free(ptr); -} - -void basilisk_sendback(struct supernet_info *myinfo,char *origCMD,char *symbol,char *remoteaddr,uint32_t basilisktag,char *retstr) -{ - uint8_t *data,space[4096],*allocptr; struct iguana_info *virt; cJSON *valsobj; int32_t datalen,encryptflag=0,delaymillis=0; - //printf("%s retstr.(%s) -> remote.(%s) basilisktag.%u\n",origCMD,retstr,remoteaddr,basilisktag); - if ( retstr != 0 && remoteaddr != 0 && remoteaddr[0] != 0 && strcmp(remoteaddr,"127.0.0.1") != 0 ) - { - if ( (valsobj= cJSON_Parse(retstr)) != 0 ) - { - jaddstr(valsobj,"origcmd",origCMD); - jaddstr(valsobj,"symbol",symbol); - if ( (virt= iguana_coinfind(symbol)) != 0 ) - { - jaddnum(valsobj,"hwm",virt->blocks.hwmchain.height); - jaddbits256(valsobj,"chaintip",virt->blocks.hwmchain.RO.hash2); - } - data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); - basilisk_sendcmd(myinfo,remoteaddr,"RET",&basilisktag,encryptflag,delaymillis,data,datalen,0,0); - if ( allocptr != 0 ) - free(allocptr); - free_json(valsobj); - } - } -} - -char *basilisk_waitresponse(struct supernet_info *myinfo,char *CMD,char *symbol,char *remoteaddr,struct basilisk_item *Lptr,struct basilisk_item *ptr) -{ - char *retstr = 0; - if ( ptr == Lptr ) - { - if ( (retstr= Lptr->retstr) == 0 ) - retstr = clonestr("{\"result\":\"null return from local basilisk_issuecmd\"}"); - ptr = basilisk_itemcreate(myinfo,CMD,symbol,Lptr->basilisktag,Lptr->numrequired,Lptr->vals,OS_milliseconds() - Lptr->expiration,Lptr->metricfunc); - queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); - } - else - { - queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); - while ( OS_milliseconds() < ptr->expiration ) - { - //if ( (retstr= basilisk_iscomplete(ptr)) != 0 ) - if ( (retstr= ptr->retstr) != 0 ) - break; - usleep(50000); - } - if ( retstr == 0 ) - retstr = basilisk_finish(ptr,-1,"{\"error\":\"basilisk timeout\"}"); - } - basilisk_sendback(myinfo,CMD,symbol,remoteaddr,ptr->basilisktag,retstr); - return(retstr); -} - -struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t *numsentp,char *CMD,char *symbol,int32_t blockflag,cJSON *valsobj,int32_t fanout,int32_t minresults,uint32_t basilisktag,int32_t timeoutmillis,void *_metricfunc,char *retstr,int32_t encryptflag,int32_t delaymillis,uint32_t nBits) -{ - struct basilisk_item *ptr; uint8_t *allocptr,*data,space[4096]; int32_t datalen; basilisk_metricfunc metricfunc = _metricfunc; - ptr = basilisk_itemcreate(myinfo,CMD,symbol,basilisktag,minresults,valsobj,timeoutmillis,metricfunc); - ptr->nBits = nBits; - *numsentp = 0; - if ( retstr != 0 ) - { - ptr->results[0] = ptr->retstr = retstr; - ptr->numresults = ptr->numrequired; - ptr->metrics[0] = (*metricfunc)(myinfo,ptr,retstr); - ptr->finished = (uint32_t)time(NULL); - } - else - { - data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); - *numsentp = ptr->numsent = basilisk_sendcmd(myinfo,0,CMD,&ptr->basilisktag,encryptflag,delaymillis,data,datalen,1,ptr->nBits); - if ( blockflag != 0 ) - queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); - else ptr->finished = (uint32_t)time(NULL); - if ( allocptr != 0 ) - free(allocptr); - } - return(ptr); -} - -struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char *CMD,int32_t blockflag,cJSON *valsobj,bits256 hash,uint8_t *data,int32_t datalen,uint32_t nBits) -{ - int32_t minresults,timeoutmillis,numsent,delaymillis,encryptflag,fanout; struct basilisk_item *ptr; char buf[4096],*symbol,*str = 0; struct iguana_info *virt,*btcd; - if ( (btcd= iguana_coinfind("BTCD")) != 0 && btcd->RELAYNODE != 0 ) - jaddnum(valsobj,"iamrelay",1); - basilisk_addhexstr(&str,valsobj,buf,sizeof(buf),data,datalen); - if ( bits256_cmp(hash,GENESIS_PUBKEY) != 0 && bits256_nonz(hash) != 0 ) - { - if ( jobj(valsobj,"hash") != 0 ) - jdelete(valsobj,"hash"); - jaddbits256(valsobj,"hash",hash); - } - if ( (minresults= jint(valsobj,"minresults")) <= 0 ) - minresults = 1; - if ( (timeoutmillis= jint(valsobj,"timeout")) == 0 ) - timeoutmillis = BASILISK_TIMEOUT; - if ( jobj(valsobj,"fanout") == 0 ) - fanout = 1; - else fanout = jint(valsobj,"fanout"); - if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 ) - { - if ( (virt= iguana_coinfind(symbol)) != 0 ) - { - jaddstr(valsobj,"symbol",symbol); - jaddnum(valsobj,"longest",virt->longestchain); - jaddnum(valsobj,"hwm",virt->blocks.hwmchain.height); - } - } - encryptflag = jint(valsobj,"encrypt"); - delaymillis = jint(valsobj,"delay"); - ptr = basilisk_issueremote(myinfo,&numsent,CMD,"BTCD",blockflag,valsobj,fanout,minresults,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits); - return(ptr); -} - -char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,bits256 hash,cJSON *valsobj,char *hexstr,int32_t blockflag) // client side -{ - uint32_t nBits = 0; uint8_t space[8192],*allocptr=0,*data = 0; struct basilisk_item *ptr,Lptr; int32_t datalen = 0; cJSON *retjson; - retjson = cJSON_CreateObject(); - data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); - ptr = basilisk_requestservice(myinfo,CMD,blockflag,valsobj,hash,data,datalen,nBits); - if ( allocptr != 0 ) - free(allocptr); - if ( ptr != 0 ) - { - if ( blockflag != 0 ) - { - if ( ptr->expiration <= OS_milliseconds() ) - ptr->expiration = OS_milliseconds() + BASILISK_TIMEOUT; - ptr->vals = jduplicate(valsobj); - strcpy(ptr->symbol,"BTCD"); - strcpy(ptr->CMD,CMD); - return(basilisk_waitresponse(myinfo,CMD,"BTCD",0,&Lptr,ptr)); - } - else if ( ptr->numsent > 0 ) - { - queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); - jaddstr(retjson,"result","success"); - jaddnum(retjson,"numsent",ptr->numsent); - } else jaddstr(retjson,"error","didnt find any nodes to send to"); - } else jaddstr(retjson,"error","couldnt create basilisk item"); - return(jprint(retjson,1)); -} - -#include "basilisk_bitcoin.c" -#include "basilisk_nxt.c" -#include "basilisk_ether.c" -#include "basilisk_waves.c" -#include "basilisk_lisk.c" -#include "basilisk_CMD.c" - -void basilisk_functions(struct iguana_info *coin,int32_t protocol) -{ - coin->protocol = protocol; - switch ( protocol ) - { - case IGUANA_PROTOCOL_BITCOIN: - coin->basilisk_balances = basilisk_bitcoinbalances; - coin->basilisk_rawtx = basilisk_bitcoinrawtx; - coin->basilisk_rawtxmetric = basilisk_bitcoin_rawtxmetric; - coin->basilisk_value = basilisk_bitcoinvalue; - coin->basilisk_valuemetric = basilisk_bitcoin_valuemetric; - break; - /*case IGUANA_PROTOCOL_IOTA: - coin->basilisk_balances = basilisk_iotabalances; - coin->basilisk_rawtx = basilisk_iotarawtx; - break; - case IGUANA_PROTOCOL_NXT: - coin->basilisk_balances = basilisk_nxtbalances; - coin->basilisk_rawtx = basilisk_nxtrawtx; - break; - case IGUANA_PROTOCOL_ETHER: - coin->basilisk_balances = basilisk_etherbalances; - coin->basilisk_rawtx = basilisk_etherrawtx; - break; - case IGUANA_PROTOCOL_WAVES: - coin->basilisk_balances = basilisk_wavesbalances; - coin->basilisk_rawtx = basilisk_wavesrawtx; - break; - case IGUANA_PROTOCOL_LISK: - coin->basilisk_balances = basilisk_liskbalances; - coin->basilisk_rawtx = basilisk_liskrawtx; - break;*/ - } -} - -int32_t basilisk_besti(struct basilisk_item *ptr) -{ - int32_t i,besti = -1; double metric,bestmetric=-1.; - for (i=0; inumresults; i++) - { - if ( (metric= ptr->metrics[i]) > 0. ) - { - if ( (ptr->metricdir < 0 && (bestmetric < 0. || metric < bestmetric)) || (ptr->metricdir > 0 && (bestmetric < 0. || metric > bestmetric)) || (ptr->metricdir == 0 && bestmetric < 0.) ) - { - bestmetric = metric; - besti = i; - } - } - } - if ( besti >= 0 ) - { - for (ptr->numexact=i=0; inumresults; i++) - if ( fabs(ptr->metrics[i] - bestmetric) < SMALLVAL ) - ptr->numexact++; - } - return(besti); -} - -char *basilisk_iscomplete(struct basilisk_item *ptr) -{ - int32_t i,numvalid,besti=-1; char *errstr = 0,*retstr = 0; - if ( ptr->childrendone < ptr->numchildren ) - return(0); - if ( ptr->retstr != 0 || ptr->finished != 0 ) - return(ptr->retstr); - if ( (numvalid= ptr->numresults) >= ptr->numrequired ) - { - for (i=numvalid=0; inumresults; i++) - { - if ( ptr->metrics[i] != 0. ) - numvalid++; - } - } - if ( numvalid < ptr->numrequired ) - { - //printf("%u: numvalid.%d < required.%d m %f\n",ptr->basilisktag,numvalid,ptr->numrequired,ptr->metrics[0]); - return(0); - } - if ( ptr->uniqueflag == 0 && ptr->numexact != ptr->numresults && ptr->numexact < (ptr->numresults >> 1) ) - besti = -1, errstr = "{\"error\":\"basilisk non-consensus results\"}"; - else besti = basilisk_besti(ptr), errstr = "{\"error\":\"basilisk no valid results\"}"; - //printf("%u complete besti.%d\n",ptr->basilisktag,besti); - retstr = basilisk_finish(ptr,besti,errstr); - //printf("%u besti.%d numexact.%d numresults.%d -> (%s)\n",ptr->basilisktag,besti,ptr->numexact,ptr->numresults,retstr); - return(retstr); -} - -struct basilisk_item *basilisk_issuecmd(struct basilisk_item *Lptr,basilisk_func func,basilisk_metricfunc metricfunc,struct supernet_info *myinfo,char *remoteaddr,uint32_t basilisktag,char *symbol,int32_t timeoutmillis,cJSON *vals) -{ - struct iguana_info *coin; struct basilisk_item *ptr; - memset(Lptr,0,sizeof(*Lptr)); - if ( (coin= iguana_coinfind(symbol)) != 0 ) - { - if ( func != 0 ) - { - if ( (ptr= (*func)(Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) - { - if ( (ptr->metricfunc= metricfunc) != 0 ) - ptr->vals = jduplicate(vals); - strcpy(ptr->symbol,symbol); - ptr->basilisktag = basilisktag; - ptr->expiration = OS_milliseconds() + timeoutmillis; - return(ptr); - } else Lptr->retstr = clonestr("{\"error\":\"error issuing basilisk command\"}"); - } else Lptr->retstr = clonestr("{\"error\":\"null basilisk function\"}"); - } else Lptr->retstr = clonestr("{\"error\":\"error missing coin\"}"); - return(Lptr); -} - -char *basilisk_check(int32_t *timeoutmillisp,uint32_t *basilisktagp,char *symbol,cJSON *vals) -{ - if ( symbol != 0 && symbol[0] != 0 && vals != 0 ) - { - if ( *basilisktagp == 0 ) - *basilisktagp = rand(); - if ( (*timeoutmillisp= jint(vals,"timeout")) < 0 ) - *timeoutmillisp = BASILISK_TIMEOUT; - return(0); - } else return(clonestr("{\"error\":\"missing activecoin or vals\"}")); -} - -char *basilisk_standardcmd(struct supernet_info *myinfo,char *CMD,char *activecoin,char *remoteaddr,uint32_t basilisktag,cJSON *vals,basilisk_func func,basilisk_metricfunc metric) -{ - char *retstr; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; struct iguana_info *coin; - if ( (retstr= basilisk_check(&timeoutmillis,&basilisktag,activecoin,vals)) == 0 ) - { - if ( (coin= iguana_coinfind(activecoin)) != 0 ) - { - if ( (ptr= basilisk_issuecmd(&Lptr,func,metric,myinfo,remoteaddr,basilisktag,activecoin,timeoutmillis,vals)) != 0 ) - { - return(basilisk_waitresponse(myinfo,CMD,coin->symbol,remoteaddr,&Lptr,ptr)); - } - else return(clonestr("{\"error\":\"null return from basilisk_issuecmd\"}")); - } else return(clonestr("{\"error\":\"couldnt get coin\"}")); - } else return(retstr); -} - -char *_basilisk_value(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) -{ - return(basilisk_standardcmd(myinfo,"VAL",coin->symbol,remoteaddr,basilisktag,valsobj,coin->basilisk_value,coin->basilisk_valuemetric)); -} - -char *_basilisk_balances(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) -{ - return(basilisk_standardcmd(myinfo,"BAL",coin->symbol,remoteaddr,basilisktag,valsobj,coin->basilisk_balances,coin->basilisk_balancesmetric)); -} - -char *_basilisk_rawtx(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) -{ - char *retstr,strbuf[4096],*str = 0; - printf("remote rawtx.(%s)\n",jprint(valsobj,0)); - basilisk_addhexstr(&str,valsobj,strbuf,sizeof(strbuf),data,datalen); - retstr = basilisk_rawtx(myinfo,coin,0,remoteaddr,basilisktag,valsobj,coin->symbol); - if ( str != 0 ) - free(str); - return(retstr); -} - -char *_basilisk_result(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) -{ - char strbuf[4096],*str = 0; - basilisk_addhexstr(&str,valsobj,strbuf,sizeof(strbuf),data,datalen); - return(basilisk_result(myinfo,coin,0,remoteaddr,basilisktag,valsobj)); -} - -char *basilisk_checkrawtx(int32_t *timeoutmillisp,uint32_t *basilisktagp,char *symbol,cJSON *vals) -{ - cJSON *addresses=0; char *changeaddr,*spendscriptstr; int32_t i,n; - *timeoutmillisp = -1; - changeaddr = jstr(vals,"changeaddr"); - spendscriptstr = jstr(vals,"spendscript"); - addresses = jarray(&n,vals,"addresses"); - if ( addresses == 0 || changeaddr == 0 || changeaddr[0] == 0 ) - return(clonestr("{\"error\":\"invalid addresses[] or changeaddr\"}")); - else - { - for (i=0; isymbol); - if ( (retstr= basilisk_standardservice(CMD,myinfo,hash,vals,hexstr,0)) != 0 ) - free(retstr); - free_json(vals); - if ( allocptr != 0 ) - free(allocptr); - } - return(0); - } else return(-1); -} - -#include "../includes/iguana_apidefs.h" -#include "../includes/iguana_apideclares.h" - -INT_ARRAY_STRING(basilisk,balances,basilisktag,vals,activecoin) -{ - return(basilisk_standardcmd(myinfo,"BAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_balances,coin->basilisk_balancesmetric)); -} - -INT_ARRAY_STRING(basilisk,value,basilisktag,vals,activecoin) -{ - return(basilisk_standardcmd(myinfo,"VAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_value,coin->basilisk_valuemetric)); -} - -INT_ARRAY_STRING(basilisk,rawtx,basilisktag,vals,activecoin) -{ - char *retstr; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; - if ( (retstr= basilisk_checkrawtx(&timeoutmillis,(uint32_t *)&basilisktag,activecoin,vals)) == 0 ) - { - coin = iguana_coinfind(activecoin); - if ( coin != 0 && (ptr= basilisk_issuecmd(&Lptr,coin->basilisk_rawtx,coin->basilisk_rawtxmetric,myinfo,remoteaddr,basilisktag,activecoin,timeoutmillis,vals)) != 0 ) - { - if ( (ptr->numrequired= juint(vals,"numrequired")) == 0 ) - ptr->numrequired = 1; - ptr->uniqueflag = 1; - ptr->metricdir = -1; - return(basilisk_waitresponse(myinfo,"RAW",coin->symbol,remoteaddr,&Lptr,ptr)); - } else return(clonestr("{\"error\":\"error issuing basilisk rawtx\"}")); - } else return(retstr); -} - -INT_AND_ARRAY(basilisk,result,basilisktag,vals) -{ - struct basilisk_item *ptr; - if ( vals != 0 ) - { - ptr = calloc(1,sizeof(*ptr)); - ptr->retstr = jprint(vals,0); - ptr->basilisktag = basilisktag; - strcpy(ptr->remoteaddr,remoteaddr); - safecopy(ptr->CMD,jstr(vals,"origcmd"),sizeof(ptr->CMD)); - printf("(%s) -> Q.%u results vals.(%s)\n",ptr->CMD,basilisktag,ptr->retstr); - queue_enqueue("resultsQ",&myinfo->basilisks.resultsQ,&ptr->DL,0); - return(clonestr("{\"result\":\"queued basilisk return\"}")); - } else printf("null vals.(%s) or no hexmsg.%p\n",jprint(vals,0),vals); - return(clonestr("{\"error\":\"no hexmsg to return\"}")); -} - -HASH_ARRAY_STRING(basilisk,addrelay,hash,vals,hexstr) -{ - return(basilisk_standardservice("ADD",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,relays,hash,vals,hexstr) -{ - return(basilisk_standardservice("RLY",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,dispatch,hash,vals,hexstr) -{ - return(basilisk_standardservice("RUN",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,publish,hash,vals,hexstr) -{ - return(basilisk_standardservice("PUB",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,subscribe,hash,vals,hexstr) -{ - return(basilisk_standardservice("SUB",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,forward,hash,vals,hexstr) -{ - return(basilisk_standardservice("HOP",myinfo,hash,vals,hexstr,0)); -} - -HASH_ARRAY_STRING(basilisk,mailbox,hash,vals,hexstr) -{ - return(basilisk_standardservice("BOX",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,VPNcreate,hash,vals,hexstr) -{ - return(basilisk_standardservice("VPN",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,VPNjoin,hash,vals,hexstr) -{ - return(basilisk_standardservice("ARC",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,VPNmessage,hash,vals,hexstr) -{ - return(basilisk_standardservice("GAB",myinfo,hash,vals,hexstr,0)); -} - -HASH_ARRAY_STRING(basilisk,VPNbroadcast,hash,vals,hexstr) -{ - return(basilisk_standardservice("SAY",myinfo,hash,vals,hexstr,0)); -} - -HASH_ARRAY_STRING(basilisk,VPNreceive,hash,vals,hexstr) -{ - return(basilisk_standardservice("EAR",myinfo,hash,vals,hexstr,1)); -} - -HASH_ARRAY_STRING(basilisk,VPNlogout,hash,vals,hexstr) -{ - return(basilisk_standardservice("END",myinfo,hash,vals,hexstr,0)); -} - -#include "../includes/iguana_apiundefs.h" - -// set hwm, get headers, then blocks - -void basilisk_geckoresult(struct supernet_info *myinfo,struct basilisk_item *ptr) -{ - uint8_t *data,space[16384],*allocptr = 0; struct iguana_info *virt; char *symbol,*str,*type; int32_t datalen; cJSON *retjson; bits256 hash2; - if ( (retjson= cJSON_Parse(ptr->retstr)) != 0 ) - { - if ( (symbol= jstr(retjson,"symbol")) != 0 && (virt= iguana_coinfind(symbol)) != 0 ) - { - if ( (data= get_dataptr(0,&allocptr,&datalen,space,sizeof(space),jstr(retjson,"data"))) != 0 ) - { - str = 0; - if ( (type= jstr(retjson,"type")) != 0 ) - { - hash2 = jbits256(retjson,"hash"); - if ( strcmp(type,"HDR") == 0 ) - str = gecko_headersarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2); - else if ( strcmp(type,"MEM") == 0 ) - str = gecko_mempoolarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2); - else if ( strcmp(type,"BLK") == 0 ) - str = gecko_blockarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2); - else if ( strcmp(type,"GTX") == 0 ) - str = gecko_txarrived(myinfo,virt,ptr->remoteaddr,data,datalen,hash2); - } - if ( str != 0 ) - free(str); - if ( allocptr != 0 ) - free(allocptr); - } - } - free_json(retjson); - } -} - -void basilisk_pending_result(struct supernet_info *myinfo,struct basilisk_item *ptr,struct basilisk_item *pending) -{ - int32_t n; struct basilisk_item *parent; basilisk_metricfunc metricfunc; - if ( (n= pending->numresults) < sizeof(pending->results)/sizeof(*pending->results) ) - { - pending->numresults++; - if ( (metricfunc= pending->metricfunc) == 0 ) - pending->metrics[n] = n + 1; - else if ( (pending->metrics[n]= (*metricfunc)(myinfo,pending,ptr->retstr)) != 0. ) - pending->childrendone++; - printf("%s.%u Add results[%d] <- metric %f\n",pending->CMD,pending->basilisktag,n,pending->metrics[n]); - pending->results[n] = ptr->retstr, ptr->retstr = 0; - /*if ( strcmp(ptr->CMD,"SEQ") == 0 ) - { - if ( (retjson= cJSON_Parse(ptr->retstr)) != 0 ) - { - gecko_seqresult(myinfo,ptr->retstr); - free_json(retjson); - } - } - else*/ - if ( strcmp(ptr->CMD,"RET") == 0 || strcmp(ptr->CMD,"GET") == 0 ) - { - printf("got return for tag.%d parent.%p\n",pending->basilisktag,pending->parent); - if ( (parent= pending->parent) != 0 ) - { - pending->parent = 0; - parent->childrendone++; - } - if ( strcmp(ptr->CMD,"GET") == 0 ) - basilisk_geckoresult(myinfo,ptr); - } - } -} - -int32_t basilisk_issued_iteration(struct supernet_info *myinfo,struct basilisk_item *pending) -{ - basilisk_metricfunc metricfunc; struct basilisk_item *parent; int32_t i,flag = 0; - //printf("pending.%u numresults.%d m %f func.%p\n",pending->basilisktag,pending->numresults,pending->metrics[0],pending->metricfunc); - if ( (metricfunc= pending->metricfunc) != 0 ) - { - for (i=0; inumresults; i++) - if ( pending->metrics[i] == 0. && pending->results[i] != 0 ) - { - if ( (pending->metrics[i]= (*metricfunc)(myinfo,pending,pending->results[i])) != 0 ) - pending->childrendone++; - // printf("iter.%d %p.[%d] poll metrics.%u metric %f\n",iter,pending,i,pending->basilisktag,pending->metrics[i]); - flag++; - } - } - basilisk_iscomplete(pending); - if ( OS_milliseconds() > pending->expiration ) - { - if ( pending->finished == 0 ) - { - if ( (parent= pending->parent) != 0 ) - { - pending->parent = 0; - parent->childrendone++; - } - pending->finished = (uint32_t)time(NULL); - if ( pending->retstr == 0 ) - pending->retstr = clonestr("{\"error\":\"basilisk timeout\"}"); - fprintf(stderr,"timeout.%s call metrics.%u lag %f - %f\n",pending->CMD,pending->basilisktag,OS_milliseconds(),pending->expiration); - for (i=0; inumresults; i++) - if ( (metricfunc= pending->metricfunc) != 0 && pending->metrics[i] == 0. ) - pending->metrics[i] = (*metricfunc)(myinfo,pending,pending->results[i]); - flag++; - } - } - //fprintf(stderr,"c"); - if ( pending->finished != 0 && time(NULL) > pending->finished+60 ) - { - if ( pending->dependents == 0 || pending->childrendone >= pending->numchildren ) - { - HASH_DELETE(hh,myinfo->basilisks.issued,pending); - if ( pending->dependents != 0 ) - free(pending->dependents); - fprintf(stderr,"HASH_DELETE free ptr.%u refcount.%d\n",pending->basilisktag,pending->refcount); - for (i=0; inumresults; i++) - if ( pending->results[i] != 0 ) - free(pending->results[i]), pending->results[i] = 0; - if ( pending->vals != 0 ) - free_json(pending->vals), pending->vals = 0; - free(pending); - flag++; - } - } - return(flag); -} - -void basilisks_loop(void *arg) -{ - struct iguana_info *btcd,*virt,*hhtmp; struct basilisk_item *ptr,*tmp,*pending; int32_t iter,maxmillis,flag; struct supernet_info *myinfo = arg; - iter = 0; - while ( 1 ) - { - iter++; - if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 ) - HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); - //fprintf(stderr,"A"); - else if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) - { - HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending); - if ( pending != 0 ) - basilisk_pending_result(myinfo,ptr,pending); - else printf("couldnt find issued.%u\n",ptr->basilisktag); - free(ptr); - } - else - { - flag = 0; - HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp) - { - flag += basilisk_issued_iteration(myinfo,pending); - } - if ( flag == 0 && myinfo->allcoins_numvirts > 0 && (btcd= iguana_coinfind("BTCD")) != 0 ) - { - maxmillis = (1000 / myinfo->allcoins_numvirts) + 1; - //portable_mutex_lock(&Allcoins_mutex); - HASH_ITER(hh,myinfo->allcoins,virt,hhtmp) - { - if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 ) - { - //fprintf(stderr,"h"); - gecko_iteration(myinfo,btcd,virt,maxmillis); - flag++; - } - } - //portable_mutex_unlock(&Allcoins_mutex); - } - } - //fprintf(stderr,"i "); - //for (i=0; iRELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 ) - // basilisk_bitcoinscan(coin,blockspace,&RAWMEM); - if ( flag == 0 ) - usleep(10000); - } -} - -void basilisks_init(struct supernet_info *myinfo) -{ - iguana_initQ(&myinfo->basilisks.submitQ,"submitQ"); - iguana_initQ(&myinfo->basilisks.resultsQ,"resultsQ"); - portable_mutex_init(&myinfo->allcoins_mutex); - portable_mutex_init(&myinfo->basilisk_mutex); - portable_mutex_init(&myinfo->gecko_mutex); - myinfo->basilisks.launched = iguana_launch(iguana_coinfind("BTCD"),"basilisks_loop",basilisks_loop,myinfo,IGUANA_PERMTHREAD); -} - -void basilisk_wait(struct supernet_info *myinfo,struct iguana_info *coin) -{ - if ( coin != 0 ) - { - while ( coin->basilisk_busy != 0 ) - usleep(1000); - } - else - { - while ( myinfo->basilisk_busy != 0 ) - usleep(1000); - } -} - -void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t senderipbits,char *type,uint32_t basilisktag,uint8_t *data,int32_t datalen) -{ - cJSON *valsobj; char *symbol,*retstr=0,remoteaddr[64],CMD[4],cmd[4]; int32_t height,origlen,from_basilisk,i,timeoutmillis,flag,numrequired,jsonlen; uint8_t *origdata; struct iguana_info *coin=0; bits256 hash; struct iguana_peer *addr = _addr; - static basilisk_servicefunc *basilisk_services[][2] = - { - { (void *)"RUN", &basilisk_respond_dispatch }, // higher level protocol handler, pass through - { (void *)"BYE", &basilisk_respond_goodbye }, // disconnect - - // gecko chains - { (void *)"NEW", &basilisk_respond_newgeckochain }, // creates new virtual gecko chain - { (void *)"GEN", &basilisk_respond_geckogenesis }, // returns genesis list - { (void *)"GET", &basilisk_respond_geckoget }, // requests headers, block or tx - { (void *)"HDR", &basilisk_respond_geckoheaders }, // reports headers - { (void *)"BLK", &basilisk_respond_geckoblock }, // reports block - { (void *)"MEM", &basilisk_respond_mempool }, // reports mempool - { (void *)"GTX", &basilisk_respond_geckotx }, // reports tx - //{ (void *)"SEQ", &basilisk_respond_hashstamps }, // BTCD and BTC recent hashes from timestamp - - // unencrypted low level functions, used by higher level protocols and virtual network funcs - { (void *)"ADD", &basilisk_respond_addrelay }, // relays register with each other bus - { (void *)"RLY", &basilisk_respond_relays }, - { (void *)"DEX", &basilisk_respond_instantdex }, - - // encrypted data for jumblr - { (void *)"HOP", &basilisk_respond_forward }, // message forwarding - { (void *)"BOX", &basilisk_respond_mailbox }, // create/send/check mailbox pubkey - - // small virtual private network - { (void *)"VPN", &basilisk_respond_VPNcreate }, // create virtual network's hub via privkey - { (void *)"ARC", &basilisk_respond_VPNjoin }, // join - { (void *)"GAB", &basilisk_respond_VPNmessage }, // private message - { (void *)"SAY", &basilisk_respond_VPNbroadcast }, // broadcast - { (void *)"EAR", &basilisk_respond_VPNreceive }, // network receive (via poll) - { (void *)"END", &basilisk_respond_VPNlogout }, // logout - - // coin services - { (void *)"RAW", &_basilisk_rawtx }, - { (void *)"VAL", &_basilisk_value }, - }; - /*static basilisk_coinfunc *basilisk_coinservices[][2] = - { - { (void *)"RAW", &_basilisk_rawtx }, - { (void *)"VAL", &_basilisk_value }, - { (void *)"BAL", &_basilisk_balances }, - };*/ - symbol = "BTCD"; - if ( (valsobj= cJSON_Parse((char *)data)) != 0 ) - { - //printf("MSGVALS.(%s)\n",(char *)data); - if ( jobj(valsobj,"coin") != 0 ) - coin = iguana_coinfind(jstr(valsobj,"coin")); - else if ( jobj(valsobj,"symbol") != 0 ) - coin = iguana_coinfind(jstr(valsobj,"symbol")); - if ( coin != 0 ) - { - if ( (height= juint(valsobj,"hwm")) > 0 ) - { - if ( height > addr->height ) - addr->height = height; - if ( height > coin->longestchain ) - coin->longestchain = height; - } - } - if ( strcmp(type,"RET") == 0 ) - { - if ( (retstr= _basilisk_result(myinfo,coin,addr,remoteaddr,basilisktag,valsobj,data,datalen)) != 0 ) - free(retstr); - return; - } - } else return; - for (i=flag=0; ibasilisk_busy = 1; - if ( valsobj != 0 ) - { - jsonlen = (int32_t)strlen((char *)data) + 1; - if ( datalen > jsonlen ) - data += jsonlen, datalen -= jsonlen; - else data = 0, datalen = 0; - if ( coin == 0 ) - coin = iguana_coinfind("BTCD"); - if ( coin != 0 ) - { - symbol = coin->symbol; - coin->basilisk_busy = 1; - } - hash = jbits256(valsobj,"hash"); - timeoutmillis = jint(valsobj,"timeout"); - if ( (numrequired= jint(valsobj,"numrequired")) == 0 ) - numrequired = 1; - if ( senderipbits != 0 ) - expand_ipbits(remoteaddr,senderipbits); - else remoteaddr[0] = 0; - /*if ( valsobj != 0 && remoteaddr != 0 ) - { - if ( from_basilisk == 0 ) - { - if ( strcmp(CMD,"RLY") == 0 ) - { - printf("add relay path\n"); - if ( juint(valsobj,"iamrelay") != 0 ) - { - retstr = basilisk_respond_relays(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk); - } - free_json(valsobj); - if ( coin != 0 ) - coin->basilisk_busy = 0; - myinfo->basilisk_busy = 0; - return; - } - else if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(remoteaddr),GENESIS_PUBKEY)) != 0 ) - free(retstr); - } - }*/ - for (i=0; iIAMRELAY != 0 ) // iguana node - { - if ( 0 && from_basilisk != 0 ) - { - printf("echo to other relays\n"); - basilisk_sendcmd(myinfo,0,cmd,&basilisktag,0,0,origdata,origlen,-1,0); // to other iguanas - } - if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 ) - { - //printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr); - if ( from_basilisk != 0 || strcmp(CMD,"GET") == 0 ) - basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr); - if ( retstr != 0 ) - free(retstr); - } //else printf("services null return\n"); - } else printf("non-relay got unexpected.(%s)\n",type); - /*free_json(valsobj); - if ( coin != 0 ) - coin->basilisk_busy = 0; - myinfo->basilisk_busy = 0; - return;*/ - } - } - /*if ( coin != 0 ) - { - if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) // iguana node - { - if ( 0 && from_basilisk != 0 ) - { - printf("echo to other relays\n"); - basilisk_sendcmd(myinfo,0,cmd,&basilisktag,0,0,origdata,origlen,-1,0); // to other iguanas - } - for (i=0; ibasilisk_busy = 0; - myinfo->basilisk_busy = 0; -} - - diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 8f5c8f64d..54334de3a 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -17,7 +17,7 @@ typedef char *basilisk_servicefunc(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk); -int32_t basilisk_specialcmd(char *cmd) +int32_t basilisk_notarycmd(char *cmd) { //&& strcmp(cmd,"DEX") != 0 && strcmp(cmd,"ACC") != 0 && strcmp(cmd,"RID") != 0 && if ( strcmp(cmd,"PIN") != 0 && strcmp(cmd,"OUT") != 0 && strcmp(cmd,"MSG") != 0 ) @@ -149,7 +149,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ { int32_t i,l,s,valid,val,n=0,retval = -1; char cmd[12]; struct iguana_info *coin,*tmp; struct iguana_peer *addr; bits256 hash; uint32_t *alreadysent,r,r2; if ( fanout <= 0 ) - fanout = sqrt(NUMRELAYS) + 1; + fanout = sqrt(myinfo->NOTARY.NUMRELAYS) + 1; else if ( fanout > BASILISK_MAXFANOUT ) fanout = BASILISK_MAXFANOUT; if ( type == 0 ) @@ -205,7 +205,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ } return(-1); } - if ( basilisk_specialcmd(type) != 0 && NUMRELAYS == 0 ) + if ( basilisk_notarycmd(type) != 0 && myinfo->NOTARY.NUMRELAYS == 0 ) return(-1); //portable_mutex_lock(&myinfo->allcoins_mutex); alreadysent = calloc(IGUANA_MAXPEERS * IGUANA_MAXCOINS,sizeof(*alreadysent)); @@ -228,19 +228,19 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ { s = 0; valid = (addr->supernet != 0); - if ( basilisk_specialcmd(type) != 0 ) + if ( basilisk_notarycmd(type) != 0 ) { valid = 0; OS_randombytes((void *)&r2,sizeof(r2)); - if ( (r2 % NUMRELAYS) >= sqrt(NUMRELAYS) ) + if ( (r2 % myinfo->NOTARY.NUMRELAYS) >= sqrt(myinfo->NOTARY.NUMRELAYS) ) { //printf("fanout.%d s.%d n.%d skip %s\n",fanout,s,n,addr->ipaddr); continue; } - for (s=0; sipbits != myinfo->myaddr.myipbits && RELAYS[s].ipbits == addr->ipbits ) + for (s=0; sNOTARY.NUMRELAYS; s++) + if ( addr->ipbits != myinfo->myaddr.myipbits && myinfo->NOTARY.RELAYS[s].ipbits == addr->ipbits ) break; - if ( s == NUMRELAYS ) + if ( s == myinfo->NOTARY.NUMRELAYS ) { //printf("skip non-relay.(%s)\n",addr->ipaddr); continue; @@ -394,7 +394,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc } if ( (timeoutmillis= jint(valsobj,"timeout")) == 0 ) timeoutmillis = BASILISK_TIMEOUT; - minfanout = sqrt(NUMRELAYS)+1; + minfanout = sqrt(myinfo->NOTARY.NUMRELAYS)+1; if ( minfanout < 5 ) minfanout = 5; if ( jobj(valsobj,"fanout") == 0 ) @@ -403,7 +403,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc if ( fanout < minfanout ) fanout = minfanout; if ( (numrequired= jint(valsobj,"numrequired")) <= 0 ) - numrequired = MAX(fanout,sqrt(NUMRELAYS)+1); + numrequired = MAX(fanout,sqrt(myinfo->NOTARY.NUMRELAYS)+1); if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 ) { if ( (virt= iguana_coinfind(symbol)) != 0 ) @@ -424,7 +424,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_addr,bits256 hash,cJSON *valsobj,char *hexstr,int32_t blockflag) // client side { uint32_t nBits = 0; uint8_t space[4096],*allocptr=0,*data = 0; struct basilisk_item *ptr; int32_t datalen = 0; cJSON *retjson; char *retstr=0; - if ( RELAYID >= 0 && basilisk_specialcmd(CMD) == 0 ) + if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 && basilisk_notarycmd(CMD) == 0 ) return(clonestr("{\"error\":\"unsupported special relay command\"}")); data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); //printf("request.(%s)\n",jprint(valsobj,0)); @@ -456,8 +456,8 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_add int32_t basilisk_relayid(struct supernet_info *myinfo,uint32_t ipbits) { int32_t j; - for (j=0; jNOTARY.NUMRELAYS; j++) + if ( myinfo->NOTARY.RELAYS[j].ipbits == ipbits ) return(j); return(-1); } @@ -473,6 +473,7 @@ int32_t basilisk_relayid(struct supernet_info *myinfo,uint32_t ipbits) #include "basilisk_swap.c" #include "basilisk_DEX.c" #include "basilisk_ping.c" +#include "basilisk_vote.c" #include "basilisk_CMD.c" void basilisk_functions(struct iguana_info *coin,int32_t protocol) @@ -625,7 +626,10 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende { (void *)"OUT", &basilisk_respond_OUT }, // send MSG to hash/id/num { (void *)"MSG", &basilisk_respond_MSG }, // get MSG (hash, id, num) { (void *)"ADD", &basilisk_respond_addrelay }, // relays register with each other bus + { (void *)"VOT", &basilisk_respond_VOT }, // VOTE handler for something //{ (void *)"PIN", &basilisk_respond_PIN }, + + // encrypted data for jumblr { (void *)"HOP", &basilisk_respond_forward }, // message forwarding { (void *)"BOX", &basilisk_respond_mailbox }, // create/send/check mailbox pubkey @@ -666,12 +670,11 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende CMD[i] = toupper((int32_t)CMD[i]); cmd[i] = tolower((int32_t)CMD[i]); } - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 )//RELAYID >= 0 ) { - if ( basilisk_specialcmd(CMD) == 0 ) + if ( basilisk_notarycmd(CMD) == 0 ) return; - } - else if ( basilisk_specialcmd(CMD) != 0 ) + } else if ( basilisk_notarycmd(CMD) != 0 ) return; symbol = "BTCD"; if ( senderipbits == 0 ) @@ -729,7 +732,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende hash = jbits256(valsobj,"hash"); timeoutmillis = jint(valsobj,"timeout"); if ( (numrequired= jint(valsobj,"numrequired")) == 0 ) - numrequired = sqrt(NUMRELAYS)+1; + numrequired = sqrt(myinfo->NOTARY.NUMRELAYS)+1; if ( senderipbits != 0 ) expand_ipbits(remoteaddr,senderipbits); else remoteaddr[0] = 0; @@ -737,7 +740,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende { if ( strcmp((char *)basilisk_services[i][0],type) == 0 ) { - if ( coin->FULLNODE != 0 || RELAYID >= 0 ) // iguana node + if ( coin->FULLNODE != 0 || myinfo->NOTARY.RELAYID >= 0 ) // iguana node { //printf("FULL.%d RELAYID.%d NUMRELAYS.%d services %s\n",coin->FULLNODE,RELAYID,NUMRELAYS,type); if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 ) @@ -777,7 +780,7 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t else ipbits = myinfo->myaddr.myipbits; if ( type[0] == 'P' && type[1] == 'I' && type[2] == 'N' ) { - if ( strcmp(type,"PIN") == 0 && RELAYID >= 0 ) + if ( strcmp(type,"PIN") == 0 && myinfo->NOTARY.RELAYID >= 0 ) { basilisk_ping_process(myinfo,_addr,ipbits,data,datalen); } @@ -787,8 +790,8 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag); //int32_t i; for (i=0; i= 0 ) - printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",RELAYID,datalen,type,senderip!=0?senderip:"?",basilisktag); + if ( myinfo->NOTARY.RELAYID >= 0 ) + printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,datalen,type,senderip!=0?senderip:"?",basilisktag); basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len); } if ( ptr != 0 ) @@ -865,7 +868,7 @@ void basilisks_loop(void *arg) } } //portable_mutex_unlock(&myinfo->allcoins_mutex); - if ( RELAYID >= 0 ) + if ( myinfo->NOTARY.RELAYID >= 0 ) { basilisk_ping_send(myinfo,btcd); } @@ -883,7 +886,7 @@ void basilisks_loop(void *arg) } } } - if ( RELAYID < 0 && myinfo->expiration != 0 ) + if ( myinfo->NOTARY.RELAYID < 0 && myinfo->expiration != 0 ) basilisk_requests_poll(myinfo); now = (uint32_t)time(NULL); portable_mutex_lock(&myinfo->messagemutex); @@ -898,7 +901,7 @@ void basilisks_loop(void *arg) } } portable_mutex_unlock(&myinfo->messagemutex); - if ( RELAYID >= 0 ) + if ( myinfo->NOTARY.RELAYID >= 0 ) usleep(100000); else usleep(3000000); } @@ -925,7 +928,7 @@ void basilisks_init(struct supernet_info *myinfo) HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) { char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; - if ( RELAYID >= 0 ) + if ( myinfo->NOTARY.RELAYID >= 0 ) return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); if ( vals == 0 ) return(clonestr("{\"error\":\"need vals object\"}")); @@ -934,7 +937,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) if ( jobj(vals,"history") == 0 ) jaddnum(vals,"history",3); if ( jobj(vals,"fanout") == 0 ) - jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); + jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); if ( jobj(vals,"numrequired") == 0 ) jaddnum(vals,"numrequired",juint(vals,"fanout")); if ( jobj(vals,"addresses") == 0 ) diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index 2ba7443cc..dc0873610 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -24,25 +24,25 @@ return(-1); }*/ -struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *btcd,uint32_t ipbits) +struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits) { struct iguana_peer *addr; int32_t i; - if ( btcd == 0 ) + if ( notaries == 0 ) return(0); - if ( (addr= iguana_peerfindipbits(btcd,ipbits,0)) == 0 ) + if ( (addr= iguana_peerfindipbits(notaries,ipbits,0)) == 0 ) { - if ( (addr= iguana_peerslot(btcd,ipbits,0)) != 0 ) + if ( (addr= iguana_peerslot(notaries,ipbits,0)) != 0 ) { printf("launch peer for relay\n"); addr->isrelay = 1; - RELAYID = -1; - for (i=0; imyaddr.myipbits ) + myinfo->NOTARY.RELAYID = -1; + for (i=0; iNOTARY.NUMRELAYS; i++) + if ( myinfo->NOTARY.RELAYS[i].ipbits == myinfo->myaddr.myipbits ) { - RELAYID = i; + myinfo->NOTARY.RELAYID = i; break; } - iguana_launch(btcd,"addrelay",iguana_startconnection,addr,IGUANA_CONNTHREAD); + iguana_launch(notaries,"addrelay",iguana_startconnection,addr,IGUANA_CONNTHREAD); } else printf("error getting peerslot\n"); } else addr->isrelay = 1; return(addr); @@ -65,30 +65,30 @@ void basilisk_relay_remap(struct supernet_info *myinfo,struct basilisk_relay *rp { int32_t i; struct basilisk_relaystatus tmp[BASILISK_MAXRELAYS]; // need to verify this works - for (i=0; iNOTARY.NUMRELAYS; i++) tmp[i] = rp->reported[i]; - for (i=0; ireported[RELAYS[i].relayid] = tmp[RELAYS[i].oldrelayid]; + for (i=0; iNOTARY.NUMRELAYS; i++) + rp->reported[myinfo->NOTARY.RELAYS[i].relayid] = tmp[myinfo->NOTARY.RELAYS[i].oldrelayid]; } void basilisk_setmyid(struct supernet_info *myinfo) { - int32_t i; char ipaddr[64]; struct iguana_info *btcd = iguana_coinfind("BTCD"); - for (i=0; iNOTARY.NUMRELAYS; i++) { - expand_ipbits(ipaddr,RELAYS[i].ipbits); - if ( myinfo->myaddr.myipbits == RELAYS[i].ipbits ) - RELAYID = i; - basilisk_ensurerelay(myinfo,btcd,RELAYS[i].ipbits); + expand_ipbits(ipaddr,myinfo->NOTARY.RELAYS[i].ipbits); + if ( myinfo->myaddr.myipbits == myinfo->NOTARY.RELAYS[i].ipbits ) + myinfo->NOTARY.RELAYID = i; + basilisk_ensurerelay(myinfo,notaries,myinfo->NOTARY.RELAYS[i].ipbits); } } char *basilisk_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint32_t ipbits,bits256 pubkey) { int32_t i; struct basilisk_relay *rp; - for (i=0; iNOTARY.NUMRELAYS; i++) { - rp = &RELAYS[i]; + rp = &myinfo->NOTARY.RELAYS[i]; if ( ipbits == rp->ipbits ) { if ( bits256_cmp(GENESIS_PUBKEY,pubkey) != 0 && bits256_nonz(pubkey) != 0 ) @@ -99,24 +99,24 @@ char *basilisk_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint return(clonestr("{\"error\":\"relay already there\"}")); } } - if ( i >= sizeof(RELAYS)/sizeof(*RELAYS) ) - i = (rand() % (sizeof(RELAYS)/sizeof(*RELAYS))); + if ( i >= sizeof(myinfo->NOTARY.RELAYS)/sizeof(*myinfo->NOTARY.RELAYS) ) + i = (rand() % (sizeof(myinfo->NOTARY.RELAYS)/sizeof(*myinfo->NOTARY.RELAYS))); printf("add relay[%d] <- %x\n",i,ipbits); - for (i=0; iNOTARY.NUMRELAYS; i++) + myinfo->NOTARY.RELAYS[i].oldrelayid = i; + rp = &myinfo->NOTARY.RELAYS[i]; rp->ipbits = ipbits; - rp->relayid = NUMRELAYS; - basilisk_ensurerelay(myinfo,iguana_coinfind("BTCD"),rp->ipbits); - if ( NUMRELAYS < sizeof(RELAYS)/sizeof(*RELAYS) ) - NUMRELAYS++; - qsort(RELAYS,NUMRELAYS,sizeof(RELAYS[0]),_increasing_ipbits); - for (i=0; irelayid = myinfo->NOTARY.NUMRELAYS; + basilisk_ensurerelay(myinfo,iguana_coinfind("NOTARY"),rp->ipbits); + if ( myinfo->NOTARY.NUMRELAYS < sizeof(myinfo->NOTARY.RELAYS)/sizeof(*myinfo->NOTARY.RELAYS) ) + myinfo->NOTARY.NUMRELAYS++; + qsort(myinfo->NOTARY.RELAYS,myinfo->NOTARY.NUMRELAYS,sizeof(myinfo->NOTARY.RELAYS[0]),_increasing_ipbits); + for (i=0; iNOTARY.NUMRELAYS; i++) + myinfo->NOTARY.RELAYS[i].relayid = i; basilisk_setmyid(myinfo); - printf("sorted MYRELAYID.%d\n",RELAYID); - for (i=0; iNOTARY.RELAYID); + for (i=0; iNOTARY.NUMRELAYS; i++) + basilisk_relay_remap(myinfo,&myinfo->NOTARY.RELAYS[i]); return(clonestr("{\"result\":\"relay added\"}")); } @@ -254,6 +254,11 @@ char *basilisk_respond_getinfo(struct supernet_info *myinfo,char *CMD,void *addr #include "../includes/iguana_apidefs.h" #include "../includes/iguana_apideclares.h" +HASH_ARRAY_STRING(basilisk,vote,hash,vals,hexstr) +{ + return(basilisk_standardservice("VOT",myinfo,0,hash,vals,hexstr,0)); +} + HASH_ARRAY_STRING(basilisk,addrelay,hash,vals,hexstr) { return(basilisk_standardservice("ADD",myinfo,0,hash,vals,hexstr,1)); diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index 5245c546d..e4c99be16 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -247,7 +247,7 @@ struct basilisk_relay *basilisk_request_ensure(struct supernet_info *myinfo,uint int32_t j; struct basilisk_relay *relay = 0; if ( (j= basilisk_relayid(myinfo,senderipbits)) >= 0 ) { - relay = &RELAYS[j]; + relay = &myinfo->NOTARY.RELAYS[j]; if ( numrequests > relay->maxrequests ) { relay->maxrequests = numrequests; @@ -284,14 +284,14 @@ static int _cmp_requests(const void *a,const void *b) struct basilisk_request *_basilisk_requests_uniq(struct supernet_info *myinfo,int32_t *nump,uint8_t *space,int32_t spacesize) { int32_t i,j,n,k,m; struct basilisk_relay *relay; struct basilisk_request *requests,*rp; - for (j=m=0; jNOTARY.NUMRELAYS; j++) + m += myinfo->NOTARY.RELAYS[j].numrequests; if ( m*sizeof(*requests) <= spacesize ) requests = (void *)space; else requests = calloc(m,sizeof(*requests)); - for (j=m=0; jNOTARY.NUMRELAYS; j++) { - relay = &RELAYS[j]; + relay = &myinfo->NOTARY.RELAYS[j]; if ( (n= relay->numrequests) > 0 ) { for (i=0; i= 0 ) + if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) R.relaybits = myinfo->myaddr.myipbits; if ( (reqjson= basilisk_requestjson(&R)) != 0 ) free_json(reqjson); diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index 4463761ec..7c578cd52 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -167,7 +167,7 @@ HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr) jdelete(vals,"msgid"); jaddnum(vals,"msgid",msgid); } - if ( RELAYID >= 0 ) + if ( myinfo->NOTARY.RELAYID >= 0 ) { channel = juint(vals,"channel"); width = juint(vals,"width"); @@ -178,7 +178,7 @@ HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr) HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr) { int32_t keylen,datalen; uint8_t key[BASILISK_KEYSIZE],space[16384],*data,*ptr = 0; char *retstr=0; - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 ) { keylen = basilisk_messagekey(key,juint(vals,"channel"),juint(vals,"msgid"),jbits256(vals,"sender"),hash); if ( (data= get_dataptr(BASILISK_HDROFFSET,&ptr,&datalen,space,sizeof(space),hexstr)) != 0 ) @@ -189,7 +189,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr) free(retstr); } if ( vals != 0 && juint(vals,"fanout") == 0 ) - jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+2)); + jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+2)); return(basilisk_standardservice("OUT",myinfo,0,hash,vals,hexstr,0)); } #include "../includes/iguana_apiundefs.h" @@ -203,7 +203,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t jaddnum(valsobj,"channel",channel); if ( msgid == 0 ) msgid = (uint32_t)time(NULL); - jaddnum(valsobj,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+2)); + jaddnum(valsobj,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+2)); jaddnum(valsobj,"msgid",msgid); jaddnum(valsobj,"duration",duration); jaddbits256(valsobj,"sender",myinfo->myaddr.persistent); @@ -252,7 +252,7 @@ cJSON *basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t ch jaddnum(valsobj,"msgid",msgid); jaddnum(valsobj,"width",width); jaddnum(valsobj,"timeout",2500); - jaddnum(valsobj,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); + jaddnum(valsobj,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(valsobj,"numrequired",1); if ( (retstr= basilisk_getmessage(myinfo,0,0,0,hash,valsobj,0)) != 0 ) { diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 1af51548b..903c9b9e3 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -383,7 +383,7 @@ double basilisk_bitcoin_valuemetric(struct supernet_info *myinfo,struct basilisk void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) { int32_t i,height,vout,numsent; struct basilisk_item *ptr; char coinaddr[64],str[65]; struct basilisk_value *v; uint64_t value = 0; bits256 txid; struct iguana_outpoint outpt; - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 ) return(0); txid = jbits256(valsobj,"txid"); vout = jint(valsobj,"vout"); @@ -424,7 +424,7 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi void *basilisk_getinfo(struct basilisk_item *Lptr,struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) { struct basilisk_item *ptr; cJSON *infojson; int32_t numsent,fanout,numrequired; - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) return(0); if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 ) { @@ -516,7 +516,7 @@ int32_t basilisk_vins_validate(struct supernet_info *myinfo,struct iguana_info * char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coin,char *remoteaddr,uint32_t basilisktag,int32_t timeoutmillis,cJSON *valsobj) { uint8_t buf[4096]; int32_t oplen,offset,minconf,spendlen; cJSON *vins,*addresses,*txobj = 0; uint32_t locktime; char *opreturn,*spendscriptstr,*changeaddr,*rawtx = 0; int64_t amount,txfee,burnamount; - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); vins = 0; changeaddr = jstr(valsobj,"changeaddr"); @@ -815,7 +815,7 @@ cJSON *BTC_makeclaimfunc(struct supernet_info *myinfo,struct exchange_info *exch HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) { char *retstr=0,*symbol; uint32_t basilisktag; struct basilisk_item *ptr,Lptr; int32_t timeoutmillis; - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 || myinfo->NOTARY.RELAYID >= 0 ) return(clonestr("{\"error\":\"special relays only do OUT and MSG\"}")); //if ( coin == 0 ) { @@ -823,7 +823,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr) coin = iguana_coinfind(symbol); } if ( jobj(vals,"fanout") == 0 ) - jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); + jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); if ( coin != 0 ) { if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) @@ -849,9 +849,9 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr) coin = iguana_coinfind(symbol); } if ( jobj(vals,"numrequired") == 0 ) - jaddnum(vals,"numrequired",NUMRELAYS); + jaddnum(vals,"numrequired",myinfo->NOTARY.NUMRELAYS); if ( jobj(vals,"fanout") == 0 ) - jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); + jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); if ( coin != 0 ) { //if ( juint(vals,"burn") == 0 ) diff --git a/basilisk/basilisk_ping.c b/basilisk/basilisk_ping.c index 9ec8f0e2d..4df9b4fc3 100755 --- a/basilisk/basilisk_ping.c +++ b/basilisk/basilisk_ping.c @@ -212,9 +212,9 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr int32_t diff,i,n,len = 0; struct iguana_info *btcd; char ipbuf[64]; struct basilisk_relay *rp; uint8_t numrelays; uint16_t sn; uint32_t now = (uint32_t)time(NULL); expand_ipbits(ipbuf,senderipbits); btcd = iguana_coinfind("BTCD"); - for (i=0; iNOTARY.NUMRELAYS; i++) { - rp = &RELAYS[i]; + rp = &myinfo->NOTARY.RELAYS[i]; rp->direct.pingdelay = 0; if ( rp->ipbits == senderipbits ) rp->lastping = now; @@ -231,7 +231,7 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr //len += basilisk_ping_processvirts(myinfo,btcd,addr,&data[len],datalen - len); for (i=0; iNOTARY.RELAYS[i]; if ( len > datalen ) break; if ( (n= basilisk_ping_processrelay(myinfo,&data[len],datalen-len,rp,i)) < 0 ) @@ -253,10 +253,10 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr int32_t basilisk_ping_gen(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen) { int32_t i,datalen = 0; - data[datalen++] = NUMRELAYS; + data[datalen++] = myinfo->NOTARY.NUMRELAYS; //datalen += basilisk_ping_genvirts(myinfo,&data[datalen],maxlen - datalen); - for (i=0; iNOTARY.NUMRELAYS; i++) + datalen += basilisk_ping_genrelay(myinfo,&data[datalen],maxlen - datalen,&myinfo->NOTARY.RELAYS[i]); //datalen += basilisk_ping_genDEX(myinfo,&data[datalen],maxlen - datalen); datalen += basilisk_ping_genMSG(myinfo,&data[datalen],maxlen - datalen); //for (i=0; iNOTARY.NUMRELAYS <= 0 ) return; if ( myinfo->pingbuf == 0 ) myinfo->pingbuf = malloc(IGUANA_MAXPACKETSIZE); datalen = basilisk_ping_gen(myinfo,&myinfo->pingbuf[sizeof(struct iguana_msghdr)],IGUANA_MAXPACKETSIZE-sizeof(struct iguana_msghdr)); - incr = sqrt(NUMRELAYS) + 1; + incr = sqrt(myinfo->NOTARY.NUMRELAYS) + 1; for (alreadysent=j=0; j<=incr; j++) { OS_randombytes((void *)&r,sizeof(r)); - i = (j == 0) ? RELAYID : (r % NUMRELAYS); - if ( j != 0 && i == RELAYID ) - i = (RELAYID + 1) % NUMRELAYS; + i = (j == 0) ? myinfo->NOTARY.RELAYID : (r % myinfo->NOTARY.NUMRELAYS); + if ( j != 0 && i == myinfo->NOTARY.RELAYID ) + i = (myinfo->NOTARY.RELAYID + 1) % myinfo->NOTARY.NUMRELAYS; if ( (((uint64_t)1 << i) & alreadysent) != 0 ) { j--; continue; } alreadysent |= ((uint64_t)1 << i); - rp = &RELAYS[i]; + rp = &myinfo->NOTARY.RELAYS[i]; addr = 0; expand_ipbits(ipaddr,rp->ipbits); if ( rp->ipbits == myinfo->myaddr.myipbits ) diff --git a/basilisk/basilisk_vote.c b/basilisk/basilisk_vote.c new file mode 100755 index 000000000..9646ed906 --- /dev/null +++ b/basilisk/basilisk_vote.c @@ -0,0 +1,405 @@ +/****************************************************************************** + * Copyright © 2014-2016 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#define MAX_ELECTIONS 64 + +struct vote_info +{ + bits256 commit,vote; + uint64_t stake,repstake; + int32_t repid; + uint8_t sig[74],siglen; + uint8_t pubkey[33],rmd160[20]; +}; + +struct election_info +{ + bits256 hash; + char name[64]; + uint32_t expiration,duration,numcandidates,numvotes; + cJSON *ballot; + struct vote_info *votes; +} Elections[MAX_ELECTIONS]; + +int64_t basilisk_voter_stake(struct supernet_info *myinfo,uint8_t *rmd160,struct iguana_info *coin,uint8_t *pubkey) +{ + char coinaddr[64]; int64_t stake = 1; + calc_rmd160_sha256(rmd160,pubkey,33); + bitcoin_address(coinaddr,coin->chain->pubtype,pubkey,33); + // get stake of address + return(stake); +} + +int32_t basilisk_voter_process(struct supernet_info *myinfo,uint8_t *rmd160,struct iguana_info *coin,struct election_info *ep,struct vote_info *vp) +{ + int32_t i; + if ( vp->stake == 0 ) + vp->stake = 1; + if ( bits256_nonz(vp->vote) != 0 ) + { + for (i=1; i<8; i++) + if ( vp->vote.uints[i] != 0 ) + break; + if ( i == 8 ) + return(vp->vote.uints[0]); + else + { + for (i=0; i<20; i++) + rmd160[i] = vp->vote.bytes[i + 4]; + return(ep->numcandidates); + } + } + return(-1); +} + +int32_t basilisk_election_process(struct supernet_info *myinfo,int64_t *tally,struct iguana_info *coin,struct election_info *ep) +{ + int32_t i,j,pending = 0; struct vote_info *vp; uint8_t rmd160[20]; + for (i=0; inumvotes; i++) + ep->votes[i].repstake = 0; + for (i=0; inumvotes; i++) + { + vp = &ep->votes[i]; + if ( basilisk_voter_process(myinfo,rmd160,coin,ep,vp) == ep->numcandidates && vp->repid < 0 ) + { + for (j=0; jnumvotes; j++) + { + if ( i != j && memcmp(rmd160,ep->votes[j].rmd160,20) == 0 ) + { + vp->repid = j; + ep->votes[j].repstake += vp->stake; + break; + } + } + } + } + if ( tally != 0 ) + { + memset(tally,0,ep->numcandidates*sizeof(*tally)); + for (i=0; inumvotes; i++) + { + vp = &ep->votes[i]; + if ( vp->repid < 0 && vp->vote.uints[0] > 0 && vp->vote.uints[0] <= ep->numcandidates ) + tally[vp->vote.uints[0]] += (vp->stake + vp->repstake); + else if ( vp->repid < 0 ) + pending++; + } + } + return(pending); +} + +cJSON *basilisk_voterjson(struct supernet_info *myinfo,struct iguana_info *coin,struct election_info *ep,struct vote_info *vp) +{ + char coinaddr[64],sigstr[74*2+1]; int32_t i; uint8_t rmd160[20]; cJSON *item; + item = cJSON_CreateObject(); + basilisk_voter_process(myinfo,rmd160,coin,ep,vp); + bitcoin_address(coinaddr,5,vp->pubkey,sizeof(vp->pubkey)); + jaddstr(item,"coinaddr",coinaddr); + jaddnum(item,"stake",dstr(vp->stake)); + if ( vp->repstake != 0 ) + jaddnum(item,"repstake",dstr(vp->repstake)); + if ( bits256_nonz(vp->vote) != 0 ) + { + for (i=1; i<8; i++) + if ( vp->vote.uints[i] != 0 ) + break; + if ( i == 8 ) + { + if ( vp->vote.uints[0] <= ep->numcandidates ) + jaddnum(item,"vote",vp->vote.uints[0]); + else jaddstr(item,"error","illegal vote"); + } + else + { + for (i=0; i<20; i++) + rmd160[i] = vp->vote.bytes[i + 4]; + bitcoin_address(coinaddr,5,rmd160,20); + jaddstr(item,"delegated",coinaddr); + } + } + else if ( bits256_nonz(vp->commit) != 0 ) + jaddbits256(item,"commit",vp->commit); + init_hexbytes_noT(sigstr,vp->sig,vp->siglen); + jaddstr(item,"sig",sigstr); + return(item); +} + +cJSON *basilisk_electionjson(struct supernet_info *myinfo,struct iguana_info *coin,struct election_info *ep) +{ + int32_t i; cJSON *array,*obj = cJSON_CreateObject(); + jaddstr(obj,"name",ep->name); + jaddbits256(obj,"hash",ep->hash); + jaddnum(obj,"expiration",ep->expiration); + jaddnum(obj,"numcandidates",ep->numcandidates); + jaddnum(obj,"numvotes",ep->numvotes); + jadd(obj,"ballot",jduplicate(ep->ballot)); + array = cJSON_CreateArray(); + for (i=0; inumvotes; i++) + jaddi(array,basilisk_voterjson(myinfo,coin,ep,&ep->votes[i])); + jadd(obj,"votes",array); + return(obj); +} + +int32_t basilisk_electionsave(struct election_info *ep) +{ + char fname[512],str[65],*ballotstr; int32_t n; FILE *fp; + OS_ensure_directory("elections"); + sprintf(fname,"elections/%s",bits256_str(str,ep->hash)); + OS_compatible_path(fname); + if ( (fp= fopen(fname,"wb")) != 0 ) + { + if ( fwrite(ep,1,sizeof(*ep),fp) != sizeof(*ep) ) + printf("error saving election.(%s) to %s\n",ep->name,fname); + else + { + if ( fwrite(&ep->numvotes,1,sizeof(ep->numvotes),fp) != sizeof(ep->numvotes) ) + printf("error saving numvotes.%d to %s\n",ep->numvotes,fname); + else if ( ep->numvotes > 0 ) + { + if ( fwrite(ep->votes,sizeof(*ep->votes),ep->numvotes,fp) != ep->numvotes ) + printf("error saving votes.%d for %s to %s\n",ep->numvotes,ep->name,fname); + else + { + if ( (ballotstr= jprint(ep->ballot,0)) != 0 ) + { + n = (int32_t)strlen(ballotstr) + 1; + if ( fwrite(&n,1,sizeof(n),fp) != sizeof(n) ) + printf("error saving n.%d for (%s) to %s\n",n,ballotstr,fname); + else if ( fwrite(ballotstr,1,n,fp) != n ) + printf("error saving election.(%s) to %s\n",ballotstr,fname); + free(ballotstr); + } + } + } + } + fclose(fp); + return(0); + } + return(-1); +} + +struct vote_info *basilisk_vote_find(struct election_info *ep,struct vote_info *vote) +{ + int32_t i; + for (i=0; inumvotes; i++) + { + if ( memcmp(ep->votes[i].pubkey,vote->pubkey,33) == 0 ) + return(&ep->votes[i]); + } + return(0); +} + +struct election_info *basilisk_election_find(int32_t createflag,bits256 hash) +{ + int32_t i; uint32_t now = (uint32_t)time(NULL); + for (i=0; i Elections[i].expiration ) + { + basilisk_electionsave(&Elections[i]); + memset(&Elections[i],0,sizeof(Elections[i])); + } + if ( bits256_nonz(hash) != 0 ) + { + if ( bits256_nonz(Elections[i].hash) == 0 ) + return(&Elections[i]); + else if ( bits256_cmp(Elections[i].hash,hash) == 0 ) + return(0); + } + } + return(0); +} + +int32_t basilisk_vote_extract(struct supernet_info *myinfo,char *coinaddr,struct vote_info *vote,cJSON *item) +{ + char str[65],str2[65],str3[65]; uint8_t *sig,*pubkey; int32_t action,siglen,plen; bits256 data,hash; + memset(vote,0,sizeof(*vote)); + if ( get_dataptr(0,&sig,&siglen,vote->sig,sizeof(vote->sig),jstr(item,"sig")) != 0 ) + { + vote->siglen = siglen; + action = juint(item,"action"); + if ( get_dataptr(0,&pubkey,&plen,vote->pubkey,sizeof(vote->pubkey),jstr(item,"pubkey")) != 0 ) + { + bitcoin_address(coinaddr,5,pubkey,33); + data = jbits256(item,"data"); + if ( bitcoin_verify(myinfo->ctx,vote->sig,vote->siglen,data,vote->pubkey,33) == 0 ) + { + if ( (action & 0xff) == 'c' ) + { + vote->commit = data; + printf("%s commits to %s\n",coinaddr,bits256_str(str,data)); + return(action); + } + else if ( (action & 0xff) == 'r' ) + { + if ( bits256_nonz(vote->commit) != 0 ) + { + vcalc_sha256(0,hash.bytes,data.bytes,sizeof(data)); + if ( bits256_cmp(hash,vote->commit) == 0 ) + { + printf("%s vote %s -> %s matches commit %s\n",coinaddr,bits256_str(str,data),bits256_str(str2,hash),bits256_str(str3,vote->commit)); + vote->vote = data; + // error check vote + return(action); + } + else + { + printf("%s vote %s -> %s doesnt match commit %s\n",coinaddr,bits256_str(str,data),bits256_str(str2,hash),bits256_str(str3,vote->commit)); + return(-2); + } + } + } + } else return(-1); + } + } + return(-1); +} + +char *basilisk_respond_VOT(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk) +{ + int32_t i,duration,winner,pending,action,numcandidates; char coinaddr[64],*symbol,*votemethod,*ballotstr; cJSON *item,*array,*electionobj,*ballot,*retjson; struct election_info *ep; struct vote_info vote,*vp; struct iguana_info *coin; int64_t *tally,max; + retjson = cJSON_CreateObject(); + if ( (symbol= jstr(valsobj,"coin")) == 0 ) + symbol = "BTCD"; + coin = iguana_coinfind(symbol); + if ( (votemethod= jstr(valsobj,"votemethod")) != 0 ) + { + if ( strcmp(votemethod,"create") == 0 ) + { + if ( (ballot= jarray(&numcandidates,valsobj,"ballot")) != 0 && numcandidates > 0 ) + { + if ( (duration= juint(valsobj,"duration")) == 0 ) + duration = 3600; + ballotstr = jprint(ballot,0); + vcalc_sha256(0,hash.bytes,(uint8_t *)ballotstr,(int32_t)strlen(ballotstr)); + free(ballotstr); + if ( (ep= basilisk_election_find(1,hash)) != 0 ) + { + ep->hash = hash; + ep->duration = duration; + ep->expiration = (uint32_t)time(NULL) + duration; + ep->ballot = jduplicate(ballot); + ep->numcandidates = numcandidates; + safecopy(ep->name,jstr(valsobj,"name"),sizeof(ep->name)); + if ( (electionobj= basilisk_electionjson(myinfo,coin,ep)) != 0 ) + { + jaddstr(retjson,"result","success"); + jadd(retjson,"election",electionobj); + } else jaddstr(retjson,"error","couldnt create election object"); + } else jaddstr(retjson,"error","couldnt allocate election slot"); + } + } + else if ( strcmp(votemethod,"list") == 0 ) + { + array = cJSON_CreateArray(); + for (i=0; inumcandidates+1,sizeof(*tally)); + pending = basilisk_election_process(myinfo,tally,coin,ep); + if ( pending != 0 ) + jaddnum(retjson,"pending",pending); + jadd(retjson,"election",basilisk_electionjson(myinfo,coin,ep)); + array = cJSON_CreateArray(); + max = 0; + winner = -1; + for (i=1; i<=ep->numcandidates; i++) + { + if ( tally[i] > max ) + { + max = tally[i]; + winner = i; + } + jaddinum(array,dstr(tally[i])); + } + jadd(retjson,"tally",array); + if ( winner > 0 ) + { + item = jitem(ep->ballot,winner-1); + jadd(retjson,"winner",item); + } + free(tally); + } + else if ( strcmp(votemethod,"ratify") == 0 ) + { + // record ratification of tally + } + else if ( (action= basilisk_vote_extract(myinfo,coinaddr,&vote,valsobj)) > 0 ) + { + vp = basilisk_vote_find(ep,&vote); + if ( strcmp(votemethod,"vote") == 0 ) + { + if ( vp == 0 ) + { + ep->votes = realloc(ep->votes,sizeof(*ep->votes) + (ep->numvotes + 1)); + vote.repid = -1; + vote.stake = basilisk_voter_stake(myinfo,vote.rmd160,coin,vote.pubkey); + ep->votes[ep->numvotes++] = vote; + jaddstr(retjson,"result","success"); + } + else if ( action == 'c' ) + { + *vp = vote; + jaddstr(retjson,"result","success"); + } + else if ( action == 'r' ) + { + *vp = vote; + jaddstr(retjson,"result","success"); + } else jaddstr(retjson,"error","illegal vote action"); + } + else if ( strcmp(votemethod,"verify") == 0 ) + { + if ( vp == 0 ) + jaddstr(retjson,"error","cant find voter"); + else if ( action == 'c' ) + { + if ( bits256_cmp(vote.commit,vp->commit) == 0 ) + jaddstr(retjson,"result","success"); + else jaddstr(retjson,"error","mismatched commit"); + jaddbits256(retjson,"oldcommit",vp->commit); + jaddbits256(retjson,"newcommit",vote.commit); + } + else if ( action == 'r' ) + { + if ( bits256_cmp(vote.vote,vp->vote) == 0 ) + jaddstr(retjson,"result","success"); + else jaddstr(retjson,"error","mismatched vote"); + jaddbits256(retjson,"oldvote",vp->vote); + jaddbits256(retjson,"newvote",vote.vote); + } else jaddstr(retjson,"error","illegal vote action"); + } else jaddstr(retjson,"error","illegal vote method"); + } else jaddstr(retjson,"error","couldnt extract vote info"); + } + } + return(jprint(retjson,1)); +} + + diff --git a/datachain/datachain.c b/datachain/datachain.c index 95792c520..8500d6f47 100755 --- a/datachain/datachain.c +++ b/datachain/datachain.c @@ -20,7 +20,7 @@ uint32_t datachain_checkpoint(struct supernet_info *myinfo,struct iguana_info *c { char str[65],str2[65]; struct iguana_info *btc = iguana_coinfind("BTC"); printf("datachain_checkpoint.%s for %s.%u to %u lastheight.%d %s\n",bits256_str(str,merkle),coin->symbol,lastcheckpoint,timestamp,lastheight,bits256_str(str2,lasthash2)); - if ( (lastheight % NUMRELAYS) == RELAYID ) + if ( (lastheight % myinfo->NOTARY.NUMRELAYS) == myinfo->NOTARY.RELAYID ) { // if designated relay, submit checkpoint -> add ip/relayid to opreturn // diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index 7f089ae34..db66cfb03 100755 --- a/gecko/gecko_blocks.c +++ b/gecko/gecko_blocks.c @@ -341,7 +341,7 @@ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *bt if ( jobj(retjson,"error") == 0 ) { valsobj = cJSON_CreateObject(); - jaddnum(valsobj,"numrequired",NUMRELAYS - 1); + jaddnum(valsobj,"numrequired",myinfo->NOTARY.NUMRELAYS - 1); jaddnum(valsobj,"timeout",3000); jaddnum(valsobj,"fanout",-1); jaddnum(valsobj,"height",height); diff --git a/gecko/gecko_mempool.c b/gecko/gecko_mempool.c index 7bd5fbcf8..7a546c19e 100755 --- a/gecko/gecko_mempool.c +++ b/gecko/gecko_mempool.c @@ -21,7 +21,7 @@ struct gecko_mempool *gecko_mempoolfind(struct supernet_info *myinfo,struct igua int32_t j,firstz,numother; bits256 *othertxids; struct gecko_mempool *otherpool = 0; othertxids = 0; numother = firstz = 0; - for (j=0; jNOTARY.NUMRELAYS; j++) { if ( (otherpool= virt->mempools[j]) != 0 ) { @@ -44,22 +44,22 @@ struct gecko_mempool *gecko_mempoolfind(struct supernet_info *myinfo,struct igua void gecko_mempool_sync(struct supernet_info *myinfo,struct iguana_info *virt,bits256 *reftxids,int32_t numtx) { int32_t i,j,k,n,num,numother; struct iguana_peer *addr; bits256 txid,*txids; struct gecko_mempool *pool,*otherpool; struct iguana_info *coin; - if ( (pool= virt->mempool) == 0 || NUMRELAYS <= 0 ) + if ( (pool= virt->mempool) == 0 || myinfo->NOTARY.NUMRELAYS <= 0 ) return; - n = sqrt(NUMRELAYS) + 2; - if ( n > NUMRELAYS ) - NUMRELAYS = n; + n = sqrt(myinfo->NOTARY.NUMRELAYS) + 2; + if ( n > myinfo->NOTARY.NUMRELAYS ) + myinfo->NOTARY.NUMRELAYS = n; i = (myinfo->myaddr.myipbits % n); txids = calloc(pool->numtx,sizeof(bits256)); if ( virt->peers == 0 ) coin = iguana_coinfind("BTCD"); else coin = virt; - for (; iNOTARY.NUMRELAYS; i+=n) { printf("mempool_sync.%d\n",i); - if ( (addr= iguana_peerfindipbits(coin,RELAYS[i].ipbits,1)) != 0 ) + if ( (addr= iguana_peerfindipbits(coin,myinfo->NOTARY.RELAYS[i].ipbits,1)) != 0 ) { - if ( (otherpool= gecko_mempoolfind(myinfo,virt,&numother,RELAYS[i].ipbits)) != 0 ) + if ( (otherpool= gecko_mempoolfind(myinfo,virt,&numother,myinfo->NOTARY.RELAYS[i].ipbits)) != 0 ) { for (j=num=0; jnumtx; j++) { diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 1065afc56..b1dadd4d9 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -785,7 +785,7 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin) } sprintf(dirname,"%s/%s",GLOBAL_TMPDIR,symbol), OS_ensure_directory(dirname); sprintf(dirname,"%s/%s/RT",GLOBAL_TMPDIR,coin->symbol), OS_ensure_directory(dirname); - iguana_coinstart(coin,coin->initialheight,coin->mapflags); + iguana_coinstart(myinfo,coin,coin->initialheight,coin->mapflags); coin->chain->minconfirms = coin->minconfirms; coin->started = coin; coin->startutc = (uint32_t)time(NULL); @@ -846,7 +846,7 @@ void iguana_coinloop(void *arg) if ( coin->MAXPEERS > IGUANA_MINPEERS ) coin->MAXPEERS = IGUANA_MINPEERS; } - if ( RELAYID < 0 ) + if ( myinfo->NOTARY.RELAYID < 0 ) { if ( coin->bindsock >= 0 ) { diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 5c2a324c4..24056b18b 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -63,6 +63,12 @@ struct supernet_address struct liquidity_info { char base[64],rel[64]; double profit,refprice; }; struct message_info { int32_t msgcount; bits256 refhash,msghashes[64]; uint32_t timestamps[64]; }; +struct komodo_notaries +{ + struct basilisk_relay RELAYS[BASILISK_MAXRELAYS]; + int32_t NUMRELAYS,RELAYID; +}; + struct supernet_info { struct supernet_address myaddr; @@ -70,7 +76,7 @@ struct supernet_info uint8_t persistent_pubkey33[33]; char ipaddr[64],NXTAPIURL[512],secret[4096],password[4096],rpcsymbol[64],handle[1024],permanentfile[1024]; char *decryptstr; - int32_t maxdelay,IAMRELAY,IAMLP,publicRPC,basilisk_busy,genesisresults; + int32_t maxdelay,IAMRELAY,IAMNOTARY,IAMLP,publicRPC,basilisk_busy,genesisresults; uint32_t expiration,dirty,DEXactive,DEXpoll; uint16_t argport,rpcport; struct basilisk_info basilisks; @@ -87,6 +93,7 @@ struct supernet_info struct basilisk_spend *spends; int32_t numspends; struct peggy_info *PEGS; struct liquidity_info linfos[64]; + struct komodo_notaries NOTARY; // compatibility bits256 pangea_category,instantdex_category; uint8_t logs[256],exps[510]; diff --git a/iguana/iguana_chains.c b/iguana/iguana_chains.c index eb073d680..880e7600e 100755 --- a/iguana/iguana_chains.c +++ b/iguana/iguana_chains.c @@ -321,7 +321,7 @@ void iguana_chainparms(struct supernet_info *myinfo,struct iguana_chain *chain,c if ( juint(argjson,"p2p") != 0 ) chain->portp2p = juint(argjson,"p2p"); else chain->portp2p = juint(argjson,"portp2p"); - if ( (chain->rpcport= juint(argjson,"rpc")) == 0 ) + if ( (chain->rpcport= juint(argjson,"rpc")) == 0 && strcmp(chain->symbol,"NOTARY") != 0 ) { if ( chain->portp2p != 0 ) chain->rpcport = chain->portp2p-1; @@ -504,7 +504,7 @@ void iguana_chaininit(struct supernet_info *myinfo,struct iguana_chain *chain,in if ( strcmp(chain->symbol,"BTC") == 0 ) chain->bundlesize = 100; decode_hex((uint8_t *)chain->genesis_hashdata,32,(char *)chain->genesis_hash); - if ( chain->rpcport == 0 ) + if ( chain->rpcport == 0 && strcmp(chain->symbol,"NOTARY") != 0 ) chain->rpcport = chain->portp2p + 1; } @@ -531,6 +531,8 @@ struct iguana_chain *iguana_chainfind(struct supernet_info *myinfo,char *name,cJ } } chain = calloc(1,sizeof(*chain)); + strcpy(chain->name,name); + strcpy(chain->symbol,name); iguana_chaininit(myinfo,chain,1,argjson); return(chain); } diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 1bd3aed74..9d6ec1aee 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -515,9 +515,9 @@ void iguana_coinpurge(struct iguana_info *coin) coin->active = saved; } -struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialheight,int32_t mapflags) +struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_info *coin,int32_t initialheight,int32_t mapflags) { - FILE *fp; char fname[512],*symbol; int32_t iter; long fpos; bits256 lastbundle; struct supernet_info *myinfo = SuperNET_MYINFO(0); + FILE *fp; char fname[512],*symbol; int32_t iter; long fpos; bits256 lastbundle; /*if ( coin->peers == 0 ) { printf("cant start privatechain directly\n"); @@ -540,7 +540,7 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei printf("%s MYSERVICES.%llx\n",coin->symbol,(long long)coin->myservices); if ( coin->virtualchain == 0 && coin->peers != 0 ) { - if ( (coin->myservices & NODE_NETWORK) != 0 || (coin->FULLNODE != 0 || coin->VALIDATENODE != 0) ) + if ( myinfo->IAMNOTARY != 0 || (coin->myservices & NODE_NETWORK) != 0 || (coin->FULLNODE != 0 || coin->VALIDATENODE != 0) ) { if ( coin->peers->acceptloop == 0 && coin->peers->localaddr == 0 ) { @@ -553,7 +553,7 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei } } } - if ( coin->rpcloop == 0 ) + if ( coin->rpcloop == 0 && strcmp(coin->chain->symbol,"NOTARY") != 0 ) { myinfo->argport = coin->chain->rpcport; coin->rpcloop = malloc(sizeof(pthread_t)); diff --git a/iguana/main.c b/iguana/main.c index eafd09333..ef6419a38 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -80,7 +80,7 @@ struct supernet_info *SuperNET_MYINFO(char *passphrase) OS_randombytes(MYINFO.privkey.bytes,sizeof(MYINFO.privkey)); MYINFO.myaddr.pubkey = curve25519(MYINFO.privkey,curve25519_basepoint9()); printf("SuperNET_MYINFO: generate session keypair\n"); - RELAYID = -1; + MYINFO.NOTARY.RELAYID = -1; } if ( passphrase == 0 || passphrase[0] == 0 ) return(&MYINFO); @@ -1345,7 +1345,7 @@ STRING_ARG(SuperNET,priv2wif,priv) STRING_ARG(SuperNET,myipaddr,ipaddr) { cJSON *retjson = cJSON_CreateObject(); - RELAYID = -1; + myinfo->NOTARY.RELAYID = -1; if ( myinfo->ipaddr[0] == 0 ) { if ( is_ipaddr(ipaddr) != 0 ) @@ -1356,10 +1356,10 @@ STRING_ARG(SuperNET,myipaddr,ipaddr) } } jaddstr(retjson,"result",myinfo->ipaddr); - if ( RELAYID >= 0 ) + if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 ) { - jaddnum(retjson,"relayid",RELAYID); - jaddnum(retjson,"numrelays",NUMRELAYS); + jaddnum(retjson,"relayid",myinfo->NOTARY.RELAYID); + jaddnum(retjson,"numrelays",myinfo->NOTARY.NUMRELAYS); } return(jprint(retjson,1)); } @@ -1551,7 +1551,7 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase) void iguana_relays_init(struct supernet_info *myinfo) { - static char *ipaddrs[] = { "89.248.160.237", "89.248.160.238", "89.248.160.239", "89.248.160.240", "89.248.160.241", "89.248.160.242", "89.248.160.243", "89.248.160.244" }; + static char *ipaddrs[] = { "78.47.196.146", "5.9.102.210" };//"89.248.160.237", "89.248.160.238", "89.248.160.239", "89.248.160.240", "89.248.160.241", "89.248.160.242", "89.248.160.243", "89.248.160.244" }; char *str; int32_t i; for (i=0; ilogs,myinfo->exps); - if ( arg != 0 && strcmp((char *)arg,"OStests") == 0 ) - do_OStests = 1; + myinfo->rpcport = IGUANA_RPCPORT; + if ( arg != 0 ) + { + if ( strcmp((char *)arg,"OStests") == 0 ) + do_OStests = 1; + else if ( strcmp((char *)arg,"notary") == 0 ) + { + myinfo->rpcport = IGUANA_NOTARYPORT; + myinfo->IAMNOTARY = 1; + } + } #ifdef IGUANA_OSTESTS do_OStests = 1; #endif @@ -1585,7 +1594,6 @@ void iguana_main(void *arg) printf("OStests retval %d\n",retval); return; } - myinfo->rpcport = IGUANA_RPCPORT; strcpy(myinfo->rpcsymbol,"BTCD"); iguana_urlinit(myinfo,ismainnet,usessl); #if LIQUIDITY_PROVIDER diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 43a31ce02..7325ddb1b 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -63,6 +63,8 @@ HASH_ARRAY_STRING(basilisk,VPNbroadcast,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,VPNreceive,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,VPNlogout,hash,vals,hexstr); +HASH_ARRAY_STRING(basilisk,vote,hash,vals,hexstr); + ZERO_ARGS(bitcoinrpc,getinfo); ZERO_ARGS(bitcoinrpc,getblockcount); ZERO_ARGS(bitcoinrpc,getdifficulty); diff --git a/includes/iguana_defines.h b/includes/iguana_defines.h index 68341612e..b4ed25cce 100755 --- a/includes/iguana_defines.h +++ b/includes/iguana_defines.h @@ -49,6 +49,7 @@ #define IGUANA_MINPENDBUNDLES 4 #define IGUANA_MAXPENDBUNDLES 64 #define IGUANA_RPCPORT 7778 +#define IGUANA_NOTARYPORT 7776 #define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16) #define IGUANA_MAPHASHTABLES 1 diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index c737bac8d..051732b9c 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -124,7 +124,7 @@ void iguana_coinargs(char *symbol,int64_t *maxrecvcachep,int32_t *minconfirmsp,i struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,int64_t maxrecvcache,uint64_t services,int32_t initialheight,int32_t maphash,int32_t minconfirms,int32_t maxrequests,int32_t maxbundles,cJSON *json,int32_t virtcoin); // init -struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialheight,int32_t mapflags); +struct iguana_info *iguana_coinstart(struct supernet_info *myinfo,struct iguana_info *coin,int32_t initialheight,int32_t mapflags); void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin); void iguana_initcoin(struct iguana_info *coin,cJSON *argjson); void iguana_coinloop(void *arg); @@ -558,7 +558,7 @@ struct iguana_peer *iguana_peerfindipbits(struct iguana_info *coin,uint32_t ipbi int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,char *CMD,bits256 *txids,int32_t num); int32_t iguana_opreturn(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int64_t crypto777_payment,int32_t height,uint64_t hdrsi_unspentind,int64_t payment,uint32_t fileid,uint64_t scriptpos,uint32_t scriptlen); int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen); -struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *btcd,uint32_t ipbits); +struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits); int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]); void iguana_RTreset(struct iguana_info *coin); diff --git a/includes/iguana_globals.h b/includes/iguana_globals.h index f00e640e5..fe8ad9c93 100755 --- a/includes/iguana_globals.h +++ b/includes/iguana_globals.h @@ -54,8 +54,8 @@ int32_t IGUANA_NUMHELPERS = 1; // ALL globals must be here! -CONDEXTERN struct basilisk_relay RELAYS[BASILISK_MAXRELAYS]; -CONDEXTERN int32_t NUMRELAYS,RELAYID; +//CONDEXTERN struct basilisk_relay RELAYS[BASILISK_MAXRELAYS]; +//CONDEXTERN int32_t NUMRELAYS,RELAYID; CONDEXTERN char *COMMANDLINE_ARGFILE; CONDEXTERN char *Iguana_validcommands[]; From efabcfe30e31909dc57d1ba7b7070138089b70b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:23:22 -0300 Subject: [PATCH 28/55] test --- gecko/gecko_miner.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gecko/gecko_miner.c b/gecko/gecko_miner.c index f8c1dfec7..988e2878c 100755 --- a/gecko/gecko_miner.c +++ b/gecko/gecko_miner.c @@ -360,26 +360,26 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig struct iguana_zblock newblock; uint32_t prevtimestamp,nBits; int64_t reward = 0; int32_t txn_count; char *blockstr,*space[256]; struct gecko_memtx **txptrs; void *ptr; //struct iguana_bundle *bp; #ifndef __APPLE__ int32_t i,gap; - if ( virt->virtualchain == 0 || RELAYID < 0 || NUMRELAYS < 1 ) + if ( virt->virtualchain == 0 || myinfo->NOTARY.RELAYID < 0 || myinfo->NOTARY.NUMRELAYS < 1 ) { //printf("skip non-virtual chain.%s\n",virt->symbol); return; } if ( virt->blocks.hwmchain.height < virt->longestchain-1 ) return; - if ( (virt->blocks.hwmchain.height % NUMRELAYS) != RELAYID ) + if ( (virt->blocks.hwmchain.height % myinfo->NOTARY.NUMRELAYS) != myinfo->NOTARY.RELAYID ) { //if ( NUMRELAYS < 3 ) // return; gap = (int32_t)(time(NULL) - virt->blocks.hwmchain.RO.timestamp) / 60;//virt->chain->estblocktime; for (i=0; iblocks.hwmchain.height+i) % NUMRELAYS) == RELAYID ) + if ( ((virt->blocks.hwmchain.height+i) % myinfo->NOTARY.NUMRELAYS) == myinfo->NOTARY.RELAYID ) break; } if ( i == gap ) return; - printf("backup block generator RELAYID.%d gap.%d ht.%d i.%d num.%d\n",RELAYID,gap,virt->blocks.hwmchain.height,i,NUMRELAYS); + printf("backup block generator RELAYID.%d gap.%d ht.%d i.%d num.%d\n",myinfo->NOTARY.RELAYID,gap,virt->blocks.hwmchain.height,i,myinfo->NOTARY.NUMRELAYS); } #endif /*if ( virt->newblockstr != 0 ) From d8478516a08d141517a4414d5cef73feef909f88 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:29:45 -0300 Subject: [PATCH 29/55] M.-1 err --- iguana/iguana_blocks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index e6cd7a80b..8200a8e51 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -569,6 +569,8 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan { int32_t valid,bundlei,height=-1; struct iguana_block *hwmchain,*block = 0,*prev=0; bits256 *hash2p=0; double prevPoW = 0.; + if ( coin->blocks.hwmchain.height < 0 ) + iguana_genesis(myinfo,coin,coin->chain); if ( newblock == 0 || newblock->RO.timestamp == 0 || bits256_nonz(newblock->RO.prev_block) == 0 ) return(0); iguana_blocksizecheck("chainlink new",coin->chain->zcash,newblock); From 54291e4538674b3bc12660012b727bd6a3227630 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:36:12 -0300 Subject: [PATCH 30/55] test --- iguana/iguana_unspents.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index b27f12b64..891964cd6 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -380,9 +380,9 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua else return(bundleheight); } -int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout) +int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout,uint8_t *rmd160,uint8_t *pubkey33) { - char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; uint8_t rmd160[20],pubkey33[33]; + char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; memset(outpt,0,sizeof(*outpt)); outpt->txid = txid; outpt->vout = vout; @@ -530,7 +530,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info * { //printf("u%u ",unspentind); deposits += U[unspentind].value; - iguana_outpt_set(coin,&outpt,&U[unspentind],unspentind,lastpt.hdrsi,T[U[unspentind].txidind].txid,unspentind - T[U[unspentind].txidind].firstvout); + iguana_outpt_set(coin,&outpt,&U[unspentind],unspentind,lastpt.hdrsi,T[U[unspentind].txidind].txid,unspentind - T[U[unspentind].txidind].firstvout,p->rmd160,pubkey33); RTspend = 0; if ( iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,lastheight,minconf,maxconf,U[unspentind].value) == 0 ) { From 8d47e80edac3889cd4c31fb8b7d3baf3ac93f54e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:39:53 -0300 Subject: [PATCH 31/55] test --- iguana/coins/gennotary | 1 + iguana/coins/gensxc | 1 - iguana/iguana_init.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100755 iguana/coins/gennotary delete mode 100755 iguana/coins/gensxc diff --git a/iguana/coins/gennotary b/iguana/coins/gennotary new file mode 100755 index 000000000..ba3b8a569 --- /dev/null +++ b/iguana/coins/gennotary @@ -0,0 +1 @@ +curl --url "http://127.0.0.1:7778" --data "{\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"NOTARY\",\"services\":128,\"maxpeers\":2048,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":7776,\"rpc\":0}" diff --git a/iguana/coins/gensxc b/iguana/coins/gensxc deleted file mode 100755 index 71100684d..000000000 --- a/iguana/coins/gensxc +++ /dev/null @@ -1 +0,0 @@ -curl --url "http://127.0.0.1:7778" --data "{\"protover\":60002,\"RELAY\":1,\"VALIDATE\":1,\"prefetchlag\":-1,\"poll\":10,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"maxpeers\":256,\"newcoin\":\"SXC\",\"name\":\"Sexcoin\",\"netmagic\":\"fbc0b6db\",\"p2p\":16814,\"rpc\":31812,\"pubval\":62,\"p2shval\":5,\"txfee_satoshis\":\"10000000\",\"minconfirms\":2,\"genesishash\":\"f42b9553085a1af63d659d3907a42c3a0052bbfa2693d3acf990af85755f2279\",\"genesis\":{\"version\":1,\"timestamp\":1369146359,\"nBits\":\"1e7fffff\",\"nonce\":244086,\"merkle_root\":\"661de12dc8dd26989adb169733b5a99150d52b8b6e8332976277856e246101f4\"},\"alertpubkey\":\"04a5814813115273a109cff99907ba4a05d951873dae7acb6c973d0c9e7c88911a3dbc9aa600deac241b91707e7b4ffb30ad91c8e56e695a1ddf318592988afe0a\",\"isPoS\":1}" diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 9d6ec1aee..d9d71747f 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -378,7 +378,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { if ( iguana_bundleinitmap(myinfo,coin,bp,height,hash2,hash1) == 0 ) lastbundle = hash2, lastheight = height; - else if ( missing++ > coin->MAXBUNDLES && strcmp("BTC",coin->symbol) == 0 ) + else if ( missing++ > coin->MAXBUNDLES )//&& strcmp("BTC",coin->symbol) == 0 ) { printf("missing.%d\n",missing); break; From b4c0ad4a83881964456692e96331d763cc602052 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:42:10 -0300 Subject: [PATCH 32/55] test --- iguana/iguana_unspents.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 891964cd6..95c5d2b91 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -390,8 +390,6 @@ int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt, outpt->isptr = 0; outpt->unspentind = unspentind; outpt->value = u->value; - memset(rmd160,0,sizeof(rmd160)); - memset(pubkey33,0,sizeof(pubkey33)); if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),outpt->hdrsi,outpt->unspentind,outpt->txid,outpt->vout,rmd160,u->type,pubkey33) != 0 ) { printf("scriptstr.(%s)\n",scriptstr); From 6c7b949e5f4babad24b17e5447b5f08bd204db42 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 14:52:45 -0300 Subject: [PATCH 33/55] test --- iguana/iguana_peers.c | 4 ++-- iguana/iguana_realtime.c | 2 -- iguana/iguana_sign.c | 2 +- iguana/iguana_unspents.c | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index de470f158..6ebc1b3e1 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -441,10 +441,10 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) } //#ifdef __APPLE__ timeout.tv_sec = 0; - timeout.tv_usec = 30000; + timeout.tv_usec = 300000; setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; - timeout.tv_usec = 1000; + timeout.tv_usec = 100000; setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); //#endif if ( listen(sock,64) != 0 ) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 0013dee83..8dc95fe6e 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -817,8 +817,6 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str } } coin->RTheight += i; - if ( coin->RTheight != coin->lastRTheight+1 ) - printf("ERROR: "); //printf("%s >= RTnewblock RTheight %d prev %d\n",coin->symbol,coin->RTheight,coin->lastRTheight); } else if ( block->height == coin->lastRTheight ) diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index 8204993c3..88ba5797d 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -268,7 +268,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin { if ( vin->vinscript == 0 ) { - printf("null vinscript case\n"); + //printf("null vinscript case\n"); vin->vinscript = serialized; vin->vinscript[0] = 0; vin->scriptlen = 1; diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 95c5d2b91..c49ace449 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -392,7 +392,7 @@ int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt, outpt->value = u->value; if ( iguana_scriptget(coin,scriptstr,asmstr,sizeof(scriptstr),outpt->hdrsi,outpt->unspentind,outpt->txid,outpt->vout,rmd160,u->type,pubkey33) != 0 ) { - printf("scriptstr.(%s)\n",scriptstr); + //printf("scriptstr.(%s)\n",scriptstr); outpt->spendlen = (int32_t)strlen(scriptstr) >> 1; if ( outpt->spendlen < sizeof(outpt->spendscript) ) decode_hex(outpt->spendscript,outpt->spendlen,scriptstr); From 1283491bdc4592f10bdcbc4611feff2f65a5f03d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 15:42:52 -0300 Subject: [PATCH 34/55] test --- iguana/iguana_peers.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 6ebc1b3e1..70b0a3740 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -439,14 +439,6 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } -//#ifdef __APPLE__ - timeout.tv_sec = 0; - timeout.tv_usec = 300000; - setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); - timeout.tv_sec = 0; - timeout.tv_usec = 100000; - setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); -//#endif if ( listen(sock,64) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); @@ -455,6 +447,12 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } + timeout.tv_sec = 0; + timeout.tv_usec = 300000; + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + timeout.tv_sec = 0; + timeout.tv_usec = 100000; + setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); return(sock); } From 286a5ea7806d803a9e562921dc4d79c0195321fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 15:52:10 -0300 Subject: [PATCH 35/55] % zero is bad --- basilisk/basilisk.c | 2 +- basilisk/basilisk_ping.c | 2 +- datachain/datachain.c | 2 +- gecko/gecko_miner.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 54334de3a..7086f5704 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -228,7 +228,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ { s = 0; valid = (addr->supernet != 0); - if ( basilisk_notarycmd(type) != 0 ) + if ( basilisk_notarycmd(type) != 0 && myinfo->IAMNOTARY != 0 ) { valid = 0; OS_randombytes((void *)&r2,sizeof(r2)); diff --git a/basilisk/basilisk_ping.c b/basilisk/basilisk_ping.c index 4df9b4fc3..be30563ad 100755 --- a/basilisk/basilisk_ping.c +++ b/basilisk/basilisk_ping.c @@ -271,7 +271,7 @@ int32_t basilisk_ping_gen(struct supernet_info *myinfo,uint8_t *data,int32_t max void basilisk_ping_send(struct supernet_info *myinfo,struct iguana_info *btcd) { struct iguana_peer *addr; char ipaddr[64]; struct basilisk_relay *rp; uint32_t r; int32_t i,j,incr,datalen=0; uint64_t alreadysent; - if ( btcd == 0 || myinfo->NOTARY.NUMRELAYS <= 0 ) + if ( btcd == 0 || myinfo->NOTARY.NUMRELAYS <= 0 || myinfo->IAMNOTARY == 0 ) return; if ( myinfo->pingbuf == 0 ) myinfo->pingbuf = malloc(IGUANA_MAXPACKETSIZE); diff --git a/datachain/datachain.c b/datachain/datachain.c index 8500d6f47..6f6bfeda5 100755 --- a/datachain/datachain.c +++ b/datachain/datachain.c @@ -20,7 +20,7 @@ uint32_t datachain_checkpoint(struct supernet_info *myinfo,struct iguana_info *c { char str[65],str2[65]; struct iguana_info *btc = iguana_coinfind("BTC"); printf("datachain_checkpoint.%s for %s.%u to %u lastheight.%d %s\n",bits256_str(str,merkle),coin->symbol,lastcheckpoint,timestamp,lastheight,bits256_str(str2,lasthash2)); - if ( (lastheight % myinfo->NOTARY.NUMRELAYS) == myinfo->NOTARY.RELAYID ) + if ( myinfo->IAMNOTARY != 0 && (lastheight % myinfo->NOTARY.NUMRELAYS) == myinfo->NOTARY.RELAYID ) { // if designated relay, submit checkpoint -> add ip/relayid to opreturn // diff --git a/gecko/gecko_miner.c b/gecko/gecko_miner.c index 988e2878c..114112c73 100755 --- a/gecko/gecko_miner.c +++ b/gecko/gecko_miner.c @@ -367,14 +367,14 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig } if ( virt->blocks.hwmchain.height < virt->longestchain-1 ) return; - if ( (virt->blocks.hwmchain.height % myinfo->NOTARY.NUMRELAYS) != myinfo->NOTARY.RELAYID ) + if ( myinfo->IAMNOTARY != 0 && (virt->blocks.hwmchain.height % myinfo->NOTARY.NUMRELAYS) != myinfo->NOTARY.RELAYID ) { //if ( NUMRELAYS < 3 ) // return; gap = (int32_t)(time(NULL) - virt->blocks.hwmchain.RO.timestamp) / 60;//virt->chain->estblocktime; for (i=0; iblocks.hwmchain.height+i) % myinfo->NOTARY.NUMRELAYS) == myinfo->NOTARY.RELAYID ) + if ( myinfo->IAMNOTARY != 0 && ((virt->blocks.hwmchain.height+i) % myinfo->NOTARY.NUMRELAYS) == myinfo->NOTARY.RELAYID ) break; } if ( i == gap ) From 5488af6cb8ff5102ce4da257297fb2c424da43cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:07:50 -0300 Subject: [PATCH 36/55] test --- iguana/iguana_peers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 70b0a3740..c23576f1f 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -448,10 +448,10 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) } } timeout.tv_sec = 0; - timeout.tv_usec = 300000; + timeout.tv_usec = 30000; setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; - timeout.tv_usec = 100000; + timeout.tv_usec = 10000; setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); return(sock); } @@ -505,9 +505,9 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s { if ( errno == EAGAIN ) { - addr->persistent_peer = 1; - //sleep(1); - //continue; + //addr->persistent_peer = 1; + sleep(1); + continue; } //if ( errno != EAGAIN && errno != EWOULDBLOCK ) { From bda3e2821a547dc3ae4e5dd7357dba8b859ddb57 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:09:04 -0300 Subject: [PATCH 37/55] 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 c23576f1f..b8f2af047 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -503,7 +503,7 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s if ( (numsent= (int32_t)send(usock,serialized,remains,MSG_NOSIGNAL)) < 0 ) #endif { - if ( errno == EAGAIN ) + if ( errno == EAGAIN || errno == EWOULDBLOCK ) { //addr->persistent_peer = 1; sleep(1); From 75b2f188ffb0c967379db752cf60195322a69677 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:38:46 -0300 Subject: [PATCH 38/55] test --- iguana/iguana_ramchain.c | 52 +++++++++++++++++++++++++++------------- iguana/iguana_recv.c | 41 ++++++++++++++++--------------- 2 files changed, 57 insertions(+), 36 deletions(-) diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 5f611a7a6..52bca772b 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1819,8 +1819,8 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,int32_t txn_count,uint8_t *data,int32_t recvlen,struct iguana_bundle *bp,struct iguana_block *block) { int32_t verifyflag = 0; - RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; - if ( block == 0 || bp == 0 || addr == 0 || (bundlei= block->bundlei) < 0 ) + RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; + if ( bp == 0 || addr == 0 || (bundlei= block->bundlei) < 0 ) { printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr); return(-1); @@ -1834,12 +1834,23 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru addr->dirty[i] = 0; if ( iguana_ramchain_init(fname,ramchain,&addr->TXDATA,&addr->HASHMEM,1,txn_count,origtxdata->numunspents,origtxdata->numspends,0,0,(scriptspace+sigsize+pubkeysize)*1.1,0,1,coin->chain->zcash) == 0 ) { - if ( block->fpipbits == 0 ) + if ( block != 0 && block->fpipbits == 0 ) block->issued = block->RO.recvlen = 0, block->fpos = -1; return(-1); } - block->fpos = fpos = -1; - iguana_ramchain_link(ramchain,block->RO.hash2,bp->hdrsi,bp->bundleheight+bundlei,bundlei,1,firsti,0); + if ( block != 0 ) + { + RO = block->RO; + block->fpos = -1; + } + else + { + memset(&RO,0,sizeof(RO)); + RO.hash2 = origtxdata->zblock.RO.hash2; + RO.prev_block = origtxdata->zblock.RO.prev_block; + } + fpos = -1; + iguana_ramchain_link(ramchain,origtxdata->zblock.RO.hash2,bp->hdrsi,bp->bundleheight+bundlei,bundlei,1,firsti,0); if ( (rdata= ramchain->H.data) != 0 ) { _iguana_ramchain_setptrs(RAMCHAIN_PTRS,rdata); @@ -1849,12 +1860,16 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru //printf("Kspace.%p bp.[%d:%d] <- scriptspace.%d expanded.%d\n",Kspace,bp->hdrsi,bundlei,scriptspace,ramchain->expanded); if ( T == 0 || U == 0 || S == 0 || B == 0 ) { - block->issued = 0; - block->RO.recvlen = 0; + if ( block != 0 ) + { + block->issued = 0; + block->RO.recvlen = 0; + } printf("fatal error getting txdataptrs %p %p %p %p\n",T,U,S,B); return(-1); } - block->fpipbits = 1; + if ( block != 0 ) + block->fpipbits = 1; for (i=0; iH.txidind++) { tx = &txarray[i]; @@ -1877,7 +1892,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru iguana_ramchain_addspend256(coin,addr,RAMCHAIN_ARG,tx->vins[j].prev_hash,tx->vins[j].prev_vout,tx->vins[j].vinscript,tx->vins[j].scriptlen,tx->vins[j].sequence,bp);//,bp->hdrsi,bundlei); } } - rdata->prevhash2 = block->RO.prev_block; + rdata->prevhash2 = origtxdata->zblock.RO.prev_block; rdata->scriptspace = scriptspace = ramchain->H.scriptoffset; rdata->stackspace = stackspace = ramchain->H.stacksize; iguana_ramchain_setsize(fname,ramchain,rdata,1,coin->chain->zcash); @@ -1885,18 +1900,21 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru if ( ramchain->H.txidind != rdata->numtxids || ramchain->H.unspentind != rdata->numunspents || ramchain->H.spendind != rdata->numspends ) { printf("error creating PT ramchain.[%d:%d] ramchain->txidind %d != %d ramchain->data->numtxids || ramchain->unspentind %d != %d ramchain->data->numunspents || ramchain->spendind %d != %d ramchain->data->numspends space.(%d v %d)\n",bp->hdrsi,bp->bundleheight,ramchain->H.txidind,rdata->numtxids,ramchain->H.unspentind,rdata->numunspents,ramchain->H.spendind,rdata->numspends,ramchain->H.scriptoffset,rdata->scriptspace); - block->fpipbits = 0; - block->issued = 0; - block->RO.recvlen = 0; + if ( block != 0 ) + { + block->fpipbits = 0; + block->issued = 0; + block->RO.recvlen = 0; + } } else { if ( (err= iguana_ramchain_verify(coin,ramchain)) == 0 ) { - iguana_blockzcopyRO(coin->chain->zcash,B,0,&block->RO,0); + iguana_blockzcopyRO(coin->chain->zcash,B,0,&RO,0); rdata->scriptspace = ramchain->H.scriptoffset = scriptspace; rdata->stackspace = ramchain->H.stacksize = stackspace; - if ( (fpos= (int32_t)iguana_ramchain_save(coin,RAMCHAIN_ARG,(uint32_t)addr->ipbits,block->RO.hash2,block->RO.prev_block,bundlei,0,coin->chain->zcash)) >= 0 ) + if ( (fpos= (int32_t)iguana_ramchain_save(coin,RAMCHAIN_ARG,(uint32_t)addr->ipbits,RO.hash2,RO.prev_block,bundlei,0,coin->chain->zcash)) >= 0 ) { origtxdata->datalen = (int32_t)rdata->allocsize; //char str[65]; printf("saved.%s [%d:%d] fpos.%d datalen.%d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,bundlei,fpos,origtxdata->datalen); @@ -1907,7 +1925,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru if ( addr->dirty[1] != 0 && addr->vinsfp != 0 ) fflush(addr->vinsfp); memset(&R,0,sizeof(R)); - if ( verifyflag != 0 && (mapchain= iguana_ramchain_map(coin,fname,0,1,&R,0,(uint32_t)addr->ipbits,block->RO.hash2,block->RO.prev_block,bundlei,fpos,1,0)) == 0 ) + if ( verifyflag != 0 && (mapchain= iguana_ramchain_map(coin,fname,0,1,&R,0,(uint32_t)addr->ipbits,RO.hash2,RO.prev_block,bundlei,fpos,1,0)) == 0 ) { printf("delete unverified [%d:%d]\n",bp->hdrsi,bundlei); iguana_ramchain_free(coin,&R,1); @@ -1920,7 +1938,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru bp->numspends += rdata->numspends; //bp->rawscriptspace += rdata->scriptspace; } - if ( fpos >= 0 ) + if ( block != 0 && fpos >= 0 ) block->fpos = fpos, block->fpipbits = (uint32_t)addr->ipbits; } else printf("save error\n"); } @@ -1931,7 +1949,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru } } } - if ( fpos < 0 ) + if ( fpos < 0 && block != 0 ) iguana_blockunmark(coin,block,bp,bundlei,1); //fprintf(stderr,"finished with hdrsi.%d ht.%d scripts.%u:%u\n",bp->hdrsi,bp->bundleheight,ramchain->H.scriptoffset,rdata->scriptspace); ramchain->H.ROflag = 0; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 9d647e07d..0c4deb1d3 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -789,43 +789,46 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); return; } - if ( block == 0 ) + /*if ( block == 0 ) block = iguana_blockhashset("noblock",coin,bp->bundleheight+bundlei,origtxdata->zblock.RO.hash2,1); if ( block->hdrsi != bp->hdrsi || block->bundlei != bundlei ) { block->hdrsi = bp->hdrsi; block->bundlei = bundlei; - } - if ( bp->blocks[bundlei] == 0 || bits256_nonz(bp->hashes[bundlei]) == 0 ) + }*/ + if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(bp->hashes[bundlei]) == 0 ) { //printf("SET [%d:%d]\n",bp->hdrsi,bundlei); //iguana_hash2set(coin,"noblock",bp,bundlei,origtxdata->zblock.RO.hash2); bp->hashes[bundlei] = origtxdata->zblock.RO.hash2; if ( bp->speculative != 0 ) bp->speculative[bundlei] = bp->hashes[bundlei]; - bp->blocks[bundlei] = block; + //bp->blocks[bundlei] = block; } numtx = origtxdata->zblock.RO.txn_count; iguana_RTgotblock(coin,origtxdata->zblock.RO.hash2,data,&recvlen,&numtx); //printf("getblockM update [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2)); - block->txvalid = 1; - if ( block->fpipbits != 0 && block->fpos >= 0 ) + if ( block != 0 ) { - static int32_t numredundant; static double redundantsize; static uint32_t lastdisp; - char str[65],str2[65]; - numredundant++, redundantsize += recvlen; - if ( time(NULL) > lastdisp+30 ) - { - lastdisp = (uint32_t)time(NULL); - printf("%s have %d:%d at %d | %d blocks %s redundant xfers total %s %.2f%% wasted\n",coin->symbol,bp->hdrsi,bundlei,block->fpos,numredundant,mbstr(str,redundantsize),mbstr(str2,totalrecv),100.*redundantsize/totalrecv); - } - if ( bundlei > 1 ) + block->txvalid = 1; + if ( block->fpipbits != 0 && block->fpos >= 0 ) { - // printf("DUP s.%d [%d:%d].(%s) %s n%d\n",numsaved,bp!=0?bp->hdrsi:-1,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks); + static int32_t numredundant; static double redundantsize; static uint32_t lastdisp; + char str[65],str2[65]; + numredundant++, redundantsize += recvlen; + if ( time(NULL) > lastdisp+30 ) + { + lastdisp = (uint32_t)time(NULL); + printf("%s have %d:%d at %d | %d blocks %s redundant xfers total %s %.2f%% wasted\n",coin->symbol,bp->hdrsi,bundlei,block->fpos,numredundant,mbstr(str,redundantsize),mbstr(str2,totalrecv),100.*redundantsize/totalrecv); + } + if ( bundlei > 1 ) + { + // printf("DUP s.%d [%d:%d].(%s) %s n%d\n",numsaved,bp!=0?bp->hdrsi:-1,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks); + } + req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); + queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + return; } - req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); - return; } txdata = origtxdata; if ( iguana_ramchain_data(coin,addr,origtxdata,txarray,origtxdata->zblock.RO.txn_count,data,recvlen,bp,block) >= 0 ) From 00d84d74f33f4ebda326fa7d9bcb0e3eb0e7a85c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:39:44 -0300 Subject: [PATCH 39/55] test --- iguana/iguana_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index d9d71747f..9d6ec1aee 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -378,7 +378,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { if ( iguana_bundleinitmap(myinfo,coin,bp,height,hash2,hash1) == 0 ) lastbundle = hash2, lastheight = height; - else if ( missing++ > coin->MAXBUNDLES )//&& strcmp("BTC",coin->symbol) == 0 ) + else if ( missing++ > coin->MAXBUNDLES && strcmp("BTC",coin->symbol) == 0 ) { printf("missing.%d\n",missing); break; From 361758498512a1e530e065e030e5215ef00e4311 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:40:48 -0300 Subject: [PATCH 40/55] test --- iguana/iguana_ramchain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 52bca772b..1c353f350 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1820,9 +1820,9 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru { int32_t verifyflag = 0; RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; - if ( bp == 0 || addr == 0 || (bundlei= block->bundlei) < 0 ) + if ( block == 0 || bp == 0 || addr == 0 || (block != 0 && (bundlei= block->bundlei) < 0) ) { - printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr); + //printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr); return(-1); } #ifdef __PNACL__ From eea34943c0880105ca6f47494aed1a4816c6b1f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:43:16 -0300 Subject: [PATCH 41/55] test --- iguana/iguana_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 0c4deb1d3..94c563e7f 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -871,7 +871,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru //printf("numsaved.%d [%d] %s\n",numsaved,bp->hdrsi,addr->ipaddr); } } - } else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2)); + } //else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2)); } void iguana_gottxidsM(struct iguana_info *coin,struct iguana_peer *addr,bits256 *txids,int32_t n) From d4cebfca5a23bb7023e987bdbc68f373c001f7b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 16:48:03 -0300 Subject: [PATCH 42/55] test --- iguana/iguana_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 94c563e7f..ae514e104 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -789,13 +789,13 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); return; } - /*if ( block == 0 ) + if ( block == 0 ) block = iguana_blockhashset("noblock",coin,bp->bundleheight+bundlei,origtxdata->zblock.RO.hash2,1); if ( block->hdrsi != bp->hdrsi || block->bundlei != bundlei ) { block->hdrsi = bp->hdrsi; block->bundlei = bundlei; - }*/ + } if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(bp->hashes[bundlei]) == 0 ) { //printf("SET [%d:%d]\n",bp->hdrsi,bundlei); From 1d77db00dc5d22e13441aa4a0c4b344748bbc9b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 17:00:49 -0300 Subject: [PATCH 43/55] test --- iguana/coins/genbtcd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/coins/genbtcd b/iguana/coins/genbtcd index 7accd6897..48fea130b 100755 --- a/iguana/coins/genbtcd +++ b/iguana/coins/genbtcd @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":11,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":256,\"endpend\":256,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"minconfirms\":5}" +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":11,\"poll\":50,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"minconfirms\":5}" From 3b7ffae825942fae2232bb5b234873bc8bbce777 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 17:23:57 -0300 Subject: [PATCH 44/55] test --- iguana/iguana_peers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index b8f2af047..9bb9dcd77 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -449,10 +449,10 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) } timeout.tv_sec = 0; timeout.tv_usec = 30000; - setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + //setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; timeout.tv_usec = 10000; - setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); + //setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); return(sock); } From 62e77e2a86075f9125bc29f2d4e58b04023846e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 17:30:11 -0300 Subject: [PATCH 45/55] test --- iguana/iguana_peers.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 9bb9dcd77..2ae9a258c 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -447,12 +447,14 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } +#ifdef __APPLE__ timeout.tv_sec = 0; timeout.tv_usec = 30000; - //setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; timeout.tv_usec = 10000; - //setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); + setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout)); +#endif return(sock); } From acea3ec0e902d989821eeceb69e1036e58d71dbc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Sep 2016 05:00:17 -0300 Subject: [PATCH 46/55] test --- iguana/iguana_recv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index ae514e104..a6b7e0fd3 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -789,13 +789,13 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); return; } - if ( block == 0 ) + /*if ( block == 0 ) block = iguana_blockhashset("noblock",coin,bp->bundleheight+bundlei,origtxdata->zblock.RO.hash2,1); if ( block->hdrsi != bp->hdrsi || block->bundlei != bundlei ) { block->hdrsi = bp->hdrsi; block->bundlei = bundlei; - } + }*/ if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(bp->hashes[bundlei]) == 0 ) { //printf("SET [%d:%d]\n",bp->hdrsi,bundlei); @@ -871,7 +871,12 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru //printf("numsaved.%d [%d] %s\n",numsaved,bp->hdrsi,addr->ipaddr); } } - } //else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2)); + } + else + { + req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); + queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + } } void iguana_gottxidsM(struct iguana_info *coin,struct iguana_peer *addr,bits256 *txids,int32_t n) From 11e8283a18e9154a544cef62cb9824ad22c325f5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Sep 2016 06:30:14 -0300 Subject: [PATCH 47/55] Merge branch 'master' into release/v0.1 --- crypto777/OS_nonportable.c | 4 ++-- iguana/iguana_bundles.c | 2 +- iguana/iguana_ramchain.c | 11 ++++++----- iguana/iguana_recv.c | 10 +++++----- iguana/iguana_unspents.c | 20 ++++++++++++-------- includes/iguana_structs.h | 4 ++-- 6 files changed, 28 insertions(+), 23 deletions(-) diff --git a/crypto777/OS_nonportable.c b/crypto777/OS_nonportable.c index 24ca8de0d..56a7a8258 100755 --- a/crypto777/OS_nonportable.c +++ b/crypto777/OS_nonportable.c @@ -47,12 +47,12 @@ void *OS_nonportable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,l #include #include -#include +/*#include static uint32_t __inline __builtin_clzll(uint64_t x) { unsigned long r = 0; _BitScanReverse64(&r, x); return (63-r); -} +}*/ void usleep(int32_t micros) { diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 936001732..af78551e9 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -266,7 +266,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo bp->n = bundlesize;//(bundlei < bundlesize-1) ? bundlesize : (bundlei + 1); if ( (setval= iguana_hash2set(coin,"blockadd",bp,bundlei,hash2)) == 0 ) { - if ( (block->hdrsi != bp->hdrsi || block->bundlei != bundlei) && (block->hdrsi != 0 || block->bundlei != 0) ) + if ( block->bundlei >= 0 && ((block->hdrsi != bp->hdrsi || block->bundlei != bundlei) && (block->hdrsi != 0 || block->bundlei != 0)) ) { char str[65]; printf("blockadd warning: %d[%d] main.%d prevent <- %d[%d] %s\n",block->hdrsi,block->bundlei,block->mainchain,bp->hdrsi,bundlei,bits256_str(str,hash2)); //iguana_blockunmark(coin,block,bp,bundlei,block->mainchain != 0); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 35cd6ede8..a8286da54 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1024,7 +1024,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits printf("ramchainsave no data ptr\n"); return(-1); } - if ( (checki= iguana_peerfname(coin,&hdrsi,ipbits==0?GLOBAL_DBDIR:GLOBAL_TMPDIR,fname,ipbits,hash2,prevhash2,ramchain->numblocks,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) + if ( (bundlei >= 0 && (checki= iguana_peerfname(coin,&hdrsi,ipbits==0?GLOBAL_DBDIR:GLOBAL_TMPDIR,fname,ipbits,hash2,prevhash2,ramchain->numblocks,1)) != bundlei) || bundlei >= coin->chain->bundlesize ) { printf(" wont save.(%s) bundlei.%d != checki.%d\n",fname,bundlei,checki); return(-1); @@ -1280,14 +1280,15 @@ int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfi struct iguana_bundle *bp; int32_t i; char fname[1024],str[65]; if ( hdrsi >= 0 && hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 ) { + iguana_volatilespurge(coin,&bp->ramchain); printf("%s delete bundle.[%d]\n",coin->symbol,hdrsi); + if ( iguana_bundlefname(coin,bp,fname) == 0 ) + OS_removefile(fname,0); if ( tmpfiles != 0 ) { for (i=0; in; i++) iguana_blockunmark(coin,bp->blocks[i],bp,i,1); } - if ( iguana_bundlefname(coin,bp,fname) == 0 ) - OS_removefile(fname,0); sprintf(fname,"%s/%s/spends/%s.%d",GLOBAL_DBDIR,coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight), OS_removefile(fname,0); sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); @@ -2031,9 +2032,9 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru } if ( deletefile != 0 && block != 0 ) iguana_blockdelete(coin,block->RO.hash2,i); - if ( coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) + if ( 0 && coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) { - printf("reduce HWM height from %d to %d\n",coin->blocks.hwmchain.height,height); + printf("reduce %s HWM height from %d to %d\n",coin->symbol,coin->blocks.hwmchain.height,height); if ( (block= iguana_blockfind("unmark",coin,iguana_blockhash(coin,height))) != 0 ) iguana_blockcopy(coin->chain->zcash,coin->chain->auxpow,coin,(struct iguana_block *)&coin->blocks.hwmchain,block); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index a6b7e0fd3..c71408997 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -810,6 +810,8 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru //printf("getblockM update [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2)); if ( block != 0 ) { + if ( block->height < 0 ) + block->bundlei = -1; block->txvalid = 1; if ( block->fpipbits != 0 && block->fpos >= 0 ) { @@ -1077,12 +1079,9 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i } } if ( bp->blocks[bundlei] == 0 ) - { firstflag = 1; - bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; - } - bp->blocks[bundlei] = block; + //bp->blocks[bundlei] = block; + //bp->hashes[bundlei] = block->RO.hash2; iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); if ( firstflag != 0 && bp->emitfinish == 0 ) { @@ -1127,6 +1126,7 @@ void iguana_bundle_set(struct iguana_info *coin,struct iguana_block *block,int32 { bp->blocks[bundlei] = block; bp->hashes[bundlei] = block->RO.hash2; + iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2); if ( bp->speculative != 0 ) bp->speculative[bundlei] = block->RO.hash2; //char str[65]; printf("SET %s ht.%d in [%d:%d]\n",bits256_str(str,block->RO.hash2),height,hdrsi,bundlei); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index c49ace449..2dbf20860 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -382,7 +382,11 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout,uint8_t *rmd160,uint8_t *pubkey33) { +<<<<<<< HEAD char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; +======= + char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; +>>>>>>> master memset(outpt,0,sizeof(*outpt)); outpt->txid = txid; outpt->vout = vout; @@ -840,10 +844,10 @@ int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info * //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); //return(iguana_RTspentflag(myinfo,coin,&RTspend,&spentheight,ramchain,outpt,height,minconf,coin->longestchain,U[unspentind].value)); /*if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 ) - { - char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",outpt.hdrsi,outpt.unspentind,bits256_str(str,txid)); - return(1); - } else return(0);*/ + { + char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",outpt.hdrsi,outpt.unspentind,bits256_str(str,txid)); + return(1); + } else return(0);*/ return(0); } printf("iguana_unspent_check: couldnt find (%d %d)\n",outpt.hdrsi,outpt.unspentind); @@ -1366,9 +1370,9 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info { iguana_volatilespurge(coin,&bp->ramchain); /*sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); - OS_removefile(fname,0); - sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); - OS_removefile(fname,0);*/ + OS_removefile(fname,0); + sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); + OS_removefile(fname,0);*/ iguana_volatilesmap(coin,&bp->ramchain); } total = 0; @@ -1512,7 +1516,7 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co if ( counts[ind] > 0 ) { qsort(&table[offsets[ind] * UTXOADDR_ITEMSIZE],counts[ind],UTXOADDR_ITEMSIZE,_utxoaddr_cmp); -continue; + continue; for (j=0; j Date: Sun, 18 Sep 2016 06:30:43 -0300 Subject: [PATCH 48/55] test --- iguana/iguana_unspents.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 2dbf20860..44bef6db7 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -382,11 +382,7 @@ int32_t iguana_uheight(struct iguana_info *coin,int32_t bundleheight,struct igua int32_t iguana_outpt_set(struct iguana_info *coin,struct iguana_outpoint *outpt,struct iguana_unspent *u,uint32_t unspentind,int16_t hdrsi,bits256 txid,int32_t vout,uint8_t *rmd160,uint8_t *pubkey33) { -<<<<<<< HEAD - char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; -======= char scriptstr[IGUANA_MAXSCRIPTSIZE*2+1],asmstr[16384]; ->>>>>>> master memset(outpt,0,sizeof(*outpt)); outpt->txid = txid; outpt->vout = vout; From d2e818d53162d7493b8dfe45e56b262ea56c6455 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Sep 2016 10:55:43 -0300 Subject: [PATCH 49/55] Merge branch 'master' into release/v0.1 fix auxpow coins --- crypto777/OS_portable.h | 2 +- iguana/coins/genbtc | 4 +++ iguana/iguana777.c | 30 +++++++++++++------ iguana/iguana_bundles.c | 52 +++++++++++++++++---------------- iguana/iguana_ramchain.c | 56 +++++++++++++++++++++++++++--------- iguana/iguana_recv.c | 28 +++++++++++------- iguana/iguana_spendvectors.c | 17 +++++------ iguana/iguana_tx.c | 25 +++++++++------- includes/iguana_structs.h | 4 +-- 9 files changed, 138 insertions(+), 80 deletions(-) diff --git a/crypto777/OS_portable.h b/crypto777/OS_portable.h index ccdc774d3..9d4423615 100755 --- a/crypto777/OS_portable.h +++ b/crypto777/OS_portable.h @@ -358,7 +358,7 @@ void escape_code(char *escaped,char *str); void SaM_PrepareIndices(); // iguana_serdes.c -#define IGUANA_LOG2PACKETSIZE 21 +#define IGUANA_LOG2PACKETSIZE 22 #define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE) struct iguana_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED; diff --git a/iguana/coins/genbtc b/iguana/coins/genbtc index e241aaa34..1f69c6dde 100755 --- a/iguana/coins/genbtc +++ b/iguana/coins/genbtc @@ -1 +1,5 @@ +<<<<<<< HEAD curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":256,\"endpend\":256,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" +======= +curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" +>>>>>>> master diff --git a/iguana/iguana777.c b/iguana/iguana777.c index b1dadd4d9..331eb5f7e 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -176,7 +176,7 @@ int32_t iguana_peermetrics(struct supernet_info *myinfo,struct iguana_info *coin } coin->peers->numranked = n; portable_mutex_unlock(&coin->peers_mutex); - //printf("NUMRANKED.%d\n",n); + //printf("peer metrics NUMRANKED.%d\n",n); if ( i > 0 ) { coin->peers->avemetric = (sum / i); @@ -340,7 +340,7 @@ int32_t iguana_utxofinished(struct iguana_info *coin) struct iguana_bundle *bp; int32_t i,n = 0; for (i=0; ibundlescount-1; i++) { - if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish > 1 ) + if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish > 1 ) n++; } return(n); @@ -391,14 +391,14 @@ int32_t iguana_helperA(struct supernet_info *myinfo,struct iguana_info *coin,int if ( iguana_bundlevalidate(myinfo,coin,bp,0) == bp->n ) // { retval = 0; - if ( bp->utxofinish > 1 || (retval= iguana_spendvectors(myinfo,coin,bp,&bp->ramchain,0,bp->n,convertflag,0)) >= 0 ) + if ( bp->emitfinish > 1 || (retval= iguana_spendvectors(myinfo,coin,bp,&bp->ramchain,0,bp->n,convertflag,0)) >= 0 ) { if ( retval > 0 ) { printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - bp->startutxo); num++; } - bp->utxofinish = (uint32_t)time(NULL); + bp->emitfinish = (uint32_t)time(NULL); } else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi); } else @@ -661,7 +661,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co void iguana_helper(void *arg) { static uint64_t helperidbits; - cJSON *argjson=0; int32_t iter,n,j,numpeers,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0; + cJSON *argjson=0; int32_t iter,n,i,j,numpeers,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0; struct iguana_helper *ptr; struct iguana_info *coin,*tmp; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp; struct supernet_info *myinfo = SuperNET_MYINFO(0); helperid %= 64; if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 ) @@ -707,12 +707,24 @@ void iguana_helper(void *arg) else { for (j=helperid; jbundlescount; j+=IGUANA_NUMHELPERS) - if ( (bp= coin->bundles[j]) != 0 && bp->startutxo == 0 && bp->numsaved >= coin->chain->bundlesize && iguana_bundleready(myinfo,coin,bp,0) == bp->n ) + { + if ( (bp= coin->bundles[j]) != 0 ) { - //printf("finalize.[%d]\n",bp->hdrsi); - if ( iguana_bundlefinalize(myinfo,coin,bp,&MEM,MEMB) > 0 ) - continue; + if ( bp->startutxo == 0 && bp->numsaved >= coin->chain->bundlesize && iguana_bundleready(myinfo,coin,bp,0) == bp->n ) + iguana_bundlefinalize(myinfo,coin,bp,&MEM,MEMB); + if ( bp->emitfinish != 0 && time(NULL) > bp->emitfinish+60 ) + { + if ( bp->validated == 0 ) + { + for (i=0; ibundles[i] == 0 || coin->bundles[i]->validated <= 1 ) + break; + if ( i == j ) + iguana_bundlevalidate(myinfo,coin,bp,1); + } + } } + } } } if ( helperid == 0 ) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index af78551e9..f1e968c0f 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -615,7 +615,7 @@ struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t priority,double mult) { - int32_t i,max,nonz,starti,lasti,firsti,lag,num,n=0; uint32_t now; bits256 hash2; double aveduration; struct iguana_peer *addr; struct iguana_block *block; + int32_t i,max,nonz,starti,lasti,firsti,lag,num,n=0; uint32_t now; bits256 hash2; double aveduration; struct iguana_peer *addr; char str[65]; //struct iguana_block *block; if ( coin->peers == 0 ) { printf("%s has no peers\n",coin->symbol); @@ -657,10 +657,10 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf lasti = firsti = -1; for (i=nonz=0; in; i++) { - if ( (block= bp->blocks[i]) != 0 && block->txvalid != 0 && block->mainchain != 0 ) - continue; - //if ( GETBIT(bp->haveblock,i) != 0 ) + //if ( (block= bp->blocks[i]) != 0 && block->txvalid != 0 && block->mainchain != 0 ) // continue; + if ( GETBIT(bp->haveblock,i) != 0 ) + continue; nonz++; if ( firsti < 0 ) firsti = i; @@ -670,10 +670,8 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf iguana_bundleblock(coin,&hash2,bp,i); if ( bits256_nonz(hash2) != 0 ) { - if ( (addr= coin->peers->ranked[rand() % max]) != 0 && addr->usock >= 0 && addr->dead == 0 ) //strcmp("BTC",coin->symbol) != 0 || (bp->issued[i] > 1 && now > bp->issued[i]+lag && + if ( (addr= coin->peers->ranked[rand() % max]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack > 0 ) { - if ( 0 && bp == coin->current ) - printf("iguana_bundleissuemissing.[%d:%d]\n",bp->hdrsi,i); iguana_sendblockreqPT(coin,0,bp,i,hash2,0); } struct iguana_blockreq *req = 0; @@ -685,23 +683,27 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf queue_enqueue("missing",&coin->priorityQ,&req->DL,0); bp->issued[i] = 1; n++; - } //else printf("[z%d] ",i); + if ( 0 && bp == coin->current ) + printf("%s issuemissing.[%d:%d]\n",bits256_str(str,hash2),bp->hdrsi,i); + } //else printf("[z%d] ",i); } //else printf("%d ",now - (bp->issued[i]+lag)); } if ( firsti >= 0 )//&& bp == coin->current ) { - //printf("[%d] first missing.%d of %d\n",bp->hdrsi,firsti,nonz); + if ( 0 && bp == coin->current ) + printf("%s [%d] first missing.%d of %d\n",bits256_str(str,hash2),bp->hdrsi,firsti,nonz); iguana_bundleblock(coin,&hash2,bp,firsti); if ( bits256_nonz(hash2) != 0 ) { - if ( (addr= coin->peers->ranked[rand() % max]) != 0 && addr->usock >= 0 && addr->dead == 0 ) + if ( (addr= coin->peers->ranked[rand() % max]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack > 0 ) { //if ( bp == coin->current ) // printf("iguana_bundleissuemissing.[%d:%d]\n",bp->hdrsi,i); n++; + //printf("send reqPT [%d:%d]\n",bp->hdrsi,firsti); iguana_sendblockreqPT(coin,0,bp,firsti,hash2,0); } - } + } // else printf("no hash for [%d:%d]\n",bp->hdrsi,firsti); } } //if ( n > 0 || bp == coin->current ) @@ -1040,7 +1042,7 @@ int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *c if ( bp->emitfinish != 0 ) { printf("already EMIT for bundle.%d\n",bp->hdrsi); - return(0); + //return(0); } bp->emitfinish = 1; usleep(100000); // make sure new incoming packet didnt overwrite @@ -1064,10 +1066,10 @@ int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *c //coin->spendvectorsaved = 0; for (i=0; ibundlescount; i++) if ( (tmpbp= coin->bundles[i]) != 0 ) - tmpbp->converted = tmpbp->balancefinish = tmpbp->validated = 0; -//#ifdef __PNACL__ + tmpbp->converted = tmpbp->balancefinish = 0; +#ifdef __PNACL__ iguana_bundlevalidate(myinfo,coin,bp,1); -//#endif +#endif } else { @@ -1115,7 +1117,7 @@ int32_t iguana_bundleiters(struct supernet_info *myinfo,struct iguana_info *coin if ( coin->blockdepth == 0 && coin->blockdepth == 0 && bp->hdrsi == coin->bundlescount-1 ) iguana_autoextend(myinfo,coin,bp); if ( 0 && bp->hdrsi == 0 ) - printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); + printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->emitfinish,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); bp->nexttime = (uint32_t)time(NULL) + ((bp->hdrsi > starti) ? 0 : -2); if ( bp->hdrsi == coin->bundlescount-1 || (bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize) ) iguana_bundlehdr(myinfo,coin,bp,starti); @@ -1362,7 +1364,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch numcached += bp->numcached; numrecv += bp->numrecv; numsaved += bp->numsaved; - if ( bp->utxofinish > 1 ) + if ( bp->emitfinish > 1 ) numutxo++; if ( bp->balancefinish > 1 ) numbalances++; @@ -1423,20 +1425,20 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch tmp = (difft.millis * 1000000); tmp %= 1000000000; difft.millis = ((double)tmp / 1000000.); - if ( (bp= firstgap) != 0 )//&& coin->PREFETCHLAG < 0 ) + if ( (bp= firstgap) != 0 ) { if ( bp != coin->current ) { printf("%s new 1st.%d\n",coin->symbol,bp->hdrsi); - iguana_bundleissuemissing(myinfo,coin,bp,1 + (rand() % 3),1.); + iguana_bundleissuemissing(myinfo,coin,bp,3,1.); if ( bp->queued == 0 ) iguana_bundleQ(myinfo,coin,bp,0); } - //else printf("issue 1st.%d\n",bp->hdrsi); - //for (i=0; in; i++) - // if ( GETBIT(bp->haveblock,i) == 0 ) - // bp->issued[i] = 0; - //iguana_bundleissuemissing(myinfo,coin,bp,1 + (rand() % 3),1.); + for (i=j=0; in; i++) + if ( GETBIT(bp->haveblock,i) == 0 ) + bp->issued[i] = 0, j++; + n = iguana_bundleissuemissing(myinfo,coin,bp,3,1.); + //printf("issued 1st.[%d] %d of %d\n",bp->hdrsi,n,j); } if ( (coin->current= firstgap) == 0 ) { @@ -1515,7 +1517,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch { //printf("bundleQ.[%d]\n",j); bp->balancefinish = bp->startutxo = 0; - bp->utxofinish = 1; + bp->emitfinish = 1; iguana_bundleQ(myinfo,coin,bp,1000); } } diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index a8286da54..a24ef57f3 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1293,7 +1293,7 @@ int32_t iguana_bundleremove(struct iguana_info *coin,int32_t hdrsi,int32_t tmpfi sprintf(fname,"%s/%s/accounts/debits.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight), OS_removefile(fname,0); - bp->utxofinish = bp->startutxo = bp->balancefinish = bp->validated = bp->emitfinish = bp->converted = 0; + bp->startutxo = bp->balancefinish = bp->validated = bp->emitfinish = bp->converted = 0; //iguana_ramchain_free(coin,&bp->ramchain,1); return(0); } @@ -1334,7 +1334,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha { ramchain->Xspendptr = ptr; ramchain->numXspends = (int32_t)((filesize - sizeof(sha256)) / sizeof(*ramchain->Xspendinds)); - bp->startutxo = bp->utxofinish = (uint32_t)time(NULL); + bp->startutxo = bp->emitfinish = (uint32_t)time(NULL); if ( bp->Xvalid == 0 ) { if ( (rand() % 10) == 0 ) @@ -1875,6 +1875,11 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru { tx = &txarray[i]; iguana_ramchain_addtxid(coin,RAMCHAIN_ARG,tx->txid,tx->tx_out,tx->tx_in,tx->lock_time,tx->version,tx->timestamp,bundlei); + if ( tx->tx_out == 0 && tx->tx_in == 0 ) + { + printf("strange tx without any inputs or outputs? ht.%d\n",bp->bundleheight); + break; + } for (j=0; jtx_out; j++) { memset(rmd160,0,sizeof(rmd160)); @@ -1994,10 +1999,10 @@ void iguana_blockdelete(struct iguana_info *coin,bits256 hash2,int32_t i) if ( fname[0] != 0 ) { OS_removefile(fname,0); -#ifndef WIN32 +/*#ifndef WIN32 strcat(fname,".tmp"); OS_removefile(fname,0); -#endif +#endif*/ } } @@ -2082,7 +2087,7 @@ int32_t iguana_oldbundlefiles(struct iguana_info *coin,uint32_t *ipbits,void **p void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,struct iguana_bundle *bp,int32_t bundlei,int32_t renameflag) { - int32_t checki,hdrsi; void *ptr = 0; FILE *fp; char renamed[1024]; static const bits256 zero; + int32_t checki,hdrsi; long checksize; void *ptr = 0; FILE *fp; static const bits256 zero; //char renamed[1024]; *filesizep = 0; fname[0] = 0; if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBAL_TMPDIR,fname,0,bp->hashes[bundlei],zero,1,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) @@ -2094,20 +2099,39 @@ void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,str return(0); else { + fseek(fp,0,SEEK_END); + checksize = ftell(fp); fclose(fp); -#ifndef WIN32 +/*#ifndef WIN32 if ( renameflag != 0 ) { sprintf(renamed,"%s.tmp",fname); - OS_renamefile(fname,renamed); + OS_copyfile(fname,renamed,1); strcpy(fname,renamed); } -#endif +//#endif*/ if ( (ptr= OS_mapfile(fname,filesizep,0)) == 0 ) { printf("error mapping.(%s) bundlei.%d\n",fname,bundlei); return(0); } + if ( *filesizep != checksize ) + { + printf("%s *filesizep %ld != %ld\n",fname,*filesizep,checksize); + OS_releasemap(ptr,*filesizep); + sleep(1); + if ( (ptr= OS_mapfile(fname,filesizep,0)) == 0 ) + { + printf("error mapping.(%s) bundlei.%d\n",fname,bundlei); + return(0); + } + if ( *filesizep != checksize ) + { + printf("second %s failure *filesizep %ld != %ld\n",fname,*filesizep,checksize); + OS_releasemap(ptr,*filesizep); + return(0); + } + } } //printf("mapped.(%s) bundlei.[%d:%d] %p[%ld]\n",fname,hdrsi,bundlei,ptr,*filesizep); return(ptr); @@ -2255,7 +2279,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig { static const bits256 zero; struct iguana_blockRO *B; struct iguana_txid *T; int32_t i,firsti = 1; char fname[512]; - struct iguana_block *block,*prev,*prev2; struct iguana_ramchain *mapchain; struct iguana_ramchaindata *rdata; + struct iguana_block *block,*prev,*prev2; struct iguana_ramchain *mapchain; struct iguana_ramchaindata *rdata; uint32_t firsttxidind; if ( bp->emitfinish > 1 ) return(ramchain); memset(ramchain,0,sizeof(*ramchain)); @@ -2264,6 +2288,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig iguana_ramchain_link(mapchain,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,1); //char str[65]; printf("%s bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",coin->symbol,bp->hdrsi,mapchain->H.data->numtxids,mapchain->H.data->numunspents,mapchain->H.data->numspends,mapchain->H.data->numpkinds,mapchain->H.data->numexternaltxids,mbstr(str,mapchain->H.data->allocsize),mapchain->H.data); //ramcoder_test(mapchain->H.data,mapchain->H.data->allocsize); + firsttxidind = 1; if ( (rdata= ramchain->H.data) != 0 ) { B = RAMCHAIN_PTR(rdata,Boffset); @@ -2287,8 +2312,11 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig block->fpipbits = (uint32_t)calc_ipbits("127.0.0.1"); iguana_blockzcopyRO(coin->chain->zcash,&block->RO,0,B,i); //printf("%x ",(int32_t)B[i].hash2.ulongs[3]); - iguana_hash2set(coin,"bundleload",bp,i,block->RO.hash2); bp->blocks[i] = block; + bp->hashes[i] = block->RO.hash2; + block->RO.firsttxidind = firsttxidind; + bp->firsttxidinds[i] = firsttxidind; + iguana_hash2set(coin,"bundleload",bp,i,block->RO.hash2); if ( (prev= block->hh.prev) != 0 ) { prev2 = prev->hh.prev; @@ -2304,10 +2332,12 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig //_iguana_chainlink(coin,block); //wrong context } prev2 = prev, prev = block; + //printf("%p.%d ",block,block->RO.txn_count); + firsttxidind += block->RO.txn_count; } } } - //printf("mapped bundle.[%d]\n",bp->hdrsi); + //printf("mapped bundle.[%d] numtxn.%d\n",bp->hdrsi,firsttxidind); bp->emitfinish = (uint32_t)time(NULL) + 1; iguana_bundlecalcs(myinfo,coin,bp,60); } @@ -2348,10 +2378,10 @@ int64_t iguana_ramchainopen(char *fname,struct iguana_info *coin,struct iguana_r if ( rdata->scriptspace > scriptspace ) scriptspace = rdata->scriptspace; } -#ifndef __APPLE__ +//#ifndef __APPLE__ numtxids *= 1.25; numexternaltxids *= 1.25, scriptspace *= 1.25; numunspents *= 1.25, numspends *= 1.25, numpkinds *= 1.25; -#endif +//#endif if ( mem->ptr == 0 ) { while ( (allocsize= _iguana_rdata_action(fname,0,0,0,0,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,coin->chain->zcash)) > 2*1024LL*1024L*1024L ) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index c71408997..e9b449761 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -78,7 +78,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, return(0); } checkbp = 0, j = -2; - if ( (checkbp= iguana_bundlefind(coin,&checkbp,&j,hash2)) != 0 && j >= 0 && j < checkbp->n ) + if ( (checkbp= iguana_bundlefind(coin,&checkbp,&j,hash2)) != 0 && j >= 0 && j < checkbp->n && checkbp != coin->current ) { if ( checkbp->emitfinish != 0 || ((block= checkbp->blocks[j]) != 0 && block->txvalid != 0 && block->mainchain != 0 && block->valid != 0 && block->bundlei != 0 && coin->RTheight == 0) ) return(0); @@ -105,26 +105,29 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, { if ( (rand() % 10000) == 0 ) printf("iguana_sendblockreq (%s) addrind.%d hasn't verack'ed yet\n",addr->ipaddr,addr->addrind); - //iguana_send_version(coin,addr,coin->myservices); - return(-1); + iguana_send_version(coin,addr,coin->myservices); + //return(-1); } lastreq2 = lastreq; lastreq = hash2; if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,&hash2,1)) > 0 ) { - iguana_send(coin,addr,serialized,len); coin->numreqsent++; addr->pendblocks++; addr->pendtime = (uint32_t)time(NULL); if ( bp != 0 && bundlei >= 0 && bundlei < bp->n ) { if ( coin->RTheight == 0 && bp != coin->current && bp->issued[bundlei] > 1 && addr->pendtime < bp->issued[bundlei]+7 ) + { + //printf("SKIP.(%s) [%d:%d] %s n.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr,addr->pendblocks); return(0); + } bp->issued[bundlei] = addr->pendtime; } + iguana_send(coin,addr,serialized,len); if ( block != 0 ) block->issued = addr->pendtime; - if ( 0 && coin->RTheight > 0 )//&& coin->current == bp ) + if ( 0 && coin->current == bp ) printf("REQ.(%s) [%d:%d] %s n.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr,addr->pendblocks); } else printf("MSG_BLOCK null datalen.%d\n",len); return(len); @@ -503,7 +506,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s { numtx = origtxdata->zblock.RO.txn_count; for (i=0; ibundlescount; i++) - if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish <= 1 ) + if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish <= 1 ) break; if ( (i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize*2) || coin->RTheight > 0 ) { @@ -673,7 +676,7 @@ void iguana_RTgotblock(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 if ( coin->almostRT == 0 ) { for (i=0; ibundlescount; i++) - if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish <= 1 ) + if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish <= 1 ) break; if ( (i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize*2) || coin->RTheight > 0 ) coin->almostRT = 1; @@ -774,6 +777,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru } if ( bp == 0 ) { + printf("gotblockM no bp %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); return; @@ -787,6 +791,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru { req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + //printf("negative speculative return %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); return; } /*if ( block == 0 ) @@ -807,12 +812,14 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru } numtx = origtxdata->zblock.RO.txn_count; iguana_RTgotblock(coin,origtxdata->zblock.RO.hash2,data,&recvlen,&numtx); - //printf("getblockM update [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2)); + if ( 0 && bp == coin->current ) + printf("getblockM update [%d:%d] %s %p\n",bp->hdrsi,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),block); if ( block != 0 ) { if ( block->height < 0 ) block->bundlei = -1; block->txvalid = 1; + block->RO.txn_count = origtxdata->zblock.RO.txn_count; if ( block->fpipbits != 0 && block->fpos >= 0 ) { static int32_t numredundant; static double redundantsize; static uint32_t lastdisp; @@ -841,9 +848,8 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0); req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata); queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); - if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) + if ( 0 && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 ) printf("[%d:%d].s%d %s Q.(%s) %s\n",bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr); - //if ( (bp == coin->current || (coin->peers != 0 && ) && (rand() % coin->chain->bundlesize) < numsaved ) if ( numsaved < coin->chain->bundlesize ) { for (i=numsaved=0; ichain->bundlesize; i++) @@ -2086,7 +2092,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle { if ( bp->emitfinish != 0 ) return(0); - if ( coin->RTheight == 0 && bp->issued[bundlei] > 0 ) + if ( bp != coin->current && coin->RTheight == 0 && bp->issued[bundlei] > 0 ) return(0); } if ( priority != 0 ) diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 2a6b4c9c6..4c0d49ff7 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -261,7 +261,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi { bp->tmpspends = ramchain->Xspendinds; bp->numtmpspends = ramchain->numXspends; - bp->utxofinish = (uint32_t)time(NULL); + bp->emitfinish = (uint32_t)time(NULL); bp->balancefinish = 0; //printf("iguana_spendvectors.[%d]: already have Xspendinds[%d]\n",bp->hdrsi,ramchain->numXspends); return(0); @@ -622,7 +622,7 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co { if ( (bp= coin->bundles[i]) == 0 ) continue; - if ( bp->emitfinish <= 1 || (i > 0 && bp->utxofinish <= 1) ) + if ( bp->emitfinish <= 1 || (i > 0 && bp->emitfinish <= 1) ) { //printf("hdrsi.[%d] emitfinish.%u utxofinish.%u\n",i,bp->emitfinish,bp->utxofinish); continue; @@ -753,11 +753,11 @@ void iguana_initfinal(struct supernet_info *myinfo,struct iguana_info *coin,bits { if ( (bp= coin->bundles[i]) == 0 || bp->emitfinish <= 1 ) { - printf("%s initfinal break.[%d]: bp.%p or emit.%u utxofinish.%u\n",coin->symbol,i,bp,bp!=0?bp->emitfinish:-1,bp!=0?bp->utxofinish:-1); + printf("%s initfinal break.[%d]: bp.%p or emit.%u utxofinish.%u\n",coin->symbol,i,bp,bp!=0?bp->emitfinish:-1,bp!=0?bp->emitfinish:-1); break; } if ( i == 0 ) - bp->utxofinish = bp->startutxo = (uint32_t)time(NULL); + bp->emitfinish = bp->startutxo = (uint32_t)time(NULL); } if ( i < coin->bundlescount-1 ) { @@ -765,7 +765,7 @@ void iguana_initfinal(struct supernet_info *myinfo,struct iguana_info *coin,bits for (i=0; ibundlescount-1; i++) { if ( (bp= coin->bundles[i]) != 0 ) - bp->startutxo = bp->utxofinish = bp->converted = bp->balancefinish = bp->validated = 0; + bp->startutxo = bp->emitfinish = bp->converted = bp->balancefinish = bp->validated = 0; } } else @@ -1105,9 +1105,10 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c if ( coin->chain->zcash != 0 ) { printf("need to process joinsplits before can validate.%s\n",coin->symbol); + bp->validated = (uint32_t)time(NULL); return(bp->n); } - if ( (coin->MAXPEERS > 1 && coin->VALIDATENODE == 0 && coin->FULLNODE == 0) || bp->ramchain.from_ro != 0 || bp == coin->current ) + if ( (coin->MAXPEERS > 1 && coin->VALIDATENODE == 0 && coin->FULLNODE == 0) || bp->ramchain.from_ro != 0 )//|| bp == coin->current ) { bp->validated = (uint32_t)time(NULL); return(bp->n); @@ -1159,7 +1160,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c printf("%s %s VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d %llx\n",coin->symbol,errs!=0?"NOT":"",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated,(long long)validatehash.txid); if ( errs == 0 ) bp->validated = (uint32_t)time(NULL); - else bp->startutxo = bp->utxofinish = 0; + else bp->startutxo = bp->emitfinish = 0; //iguana_volatilesmap(coin,&bp->ramchain); //if ( bp == coin->current ) // coin->RTdatabad = -1; @@ -1178,7 +1179,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c if ( errs != 0 ) { printf("%s remove.[%d]\n",coin->symbol,bp->hdrsi); - //iguana_bundleremove(coin,bp->hdrsi,0); + iguana_bundleremove(coin,bp->hdrsi,0); return(-errs); } return(bp->n - errs); diff --git a/iguana/iguana_tx.c b/iguana/iguana_tx.c index 98ae3a79e..3bfc95324 100755 --- a/iguana/iguana_tx.c +++ b/iguana/iguana_tx.c @@ -152,19 +152,19 @@ struct iguana_txid *iguana_blocktx(struct iguana_info *coin,struct iguana_txid * struct iguana_bundle *bp; uint32_t txidind; if ( i >= 0 && i < block->RO.txn_count ) { - if ( block->height >= 0 ) + if ( block->height >= 0 && block->bundlei >= 0 && block->bundlei < coin->chain->bundlesize ) { if ( (bp= coin->bundles[block->hdrsi]) != 0 ) { - if ( (txidind= block->RO.firsttxidind) > 0 ) + if ( (txidind= block->RO.firsttxidind) == bp->firsttxidinds[block->bundlei] ) { if ( iguana_bundletx(coin,bp,block->bundlei,tx,txidind+i) == tx ) return(tx); printf("error getting txidind.%d + i.%d from hdrsi.%d\n",txidind,i,block->hdrsi); return(0); - } else printf("iguana_blocktx null txidind [%d:%d] i.%d\n",block->hdrsi,block->bundlei,i); + } else printf("iguana_blocktx null txidind [%d:%d] i.%d txidind.%d vs %d\n",block->hdrsi,block->bundlei,i,txidind,bp->firsttxidinds[block->bundlei]); } else printf("iguana_blocktx no bp.[%d]\n",block->hdrsi); - } else printf("%s blocktx illegal height.%d\n",coin->symbol,block->height); + } else printf("%s blocktx illegal height.%d or [%d:%d]\n",coin->symbol,block->height,block->hdrsi,block->bundlei); } else printf("i.%d vs txn_count.%d\n",i,block->RO.txn_count); return(0); } @@ -178,16 +178,12 @@ int32_t iguana_ramtxbytes(struct iguana_info *coin,uint8_t *serialized,int32_t m version = tx->version; locktime = tx->locktime; timestamp = tx->timestamp; + numvins = tx->numvins; + numvouts = tx->numvouts; } len += iguana_rwnum(rwflag,&serialized[len],sizeof(version),&version); if ( coin->chain->isPoS != 0 ) len += iguana_rwnum(rwflag,&serialized[len],sizeof(timestamp),×tamp); - if ( rwflag == 0 ) - { - tx->version = version; - tx->timestamp = timestamp; - } - numvins = tx->numvins, numvouts = tx->numvouts; len += iguana_rwvarint32(rwflag,&serialized[len],&numvins); memset(&vin,0,sizeof(vin)); for (i=0; iversion = version; + tx->timestamp = timestamp; + tx->numvins = numvins; + tx->numvouts = numvouts; tx->locktime = locktime; + } *txidp = bits256_doublesha256(txidstr,serialized,len); if ( memcmp(txidp,tx->txid.bytes,sizeof(*txidp)) != 0 ) { @@ -272,6 +274,7 @@ int32_t iguana_peerblockrequest(struct supernet_info *myinfo,struct iguana_info { if ( (tx= iguana_blocktx(coin,&T,block,i)) != 0 ) { + //printf("ht.%d [%d:%d] txi.%d i.%d o.%d %s\n",block->height,block->hdrsi,block->bundlei,i,tx->numvins,tx->numvouts,bits256_str(str,tx->txid)); if ( (len= iguana_ramtxbytes(coin,&blockspace[sizeof(struct iguana_msghdr) + total],max - total,&checktxid,tx,block->height,0,0,validatesigs)) > 0 )//&& bits256_cmp(checktxid,T.txid) == 0 ) total += len; else @@ -341,7 +344,7 @@ int32_t iguana_peerblockrequest(struct supernet_info *myinfo,struct iguana_info //printf("validated.[%d:%d] len.%d\n",bp->hdrsi,bundlei,total); return(total); } - } else printf("iguana_peerblockrequest: %s error merkle cmp tx.[%d] for ht.%d\n",coin->symbol,i,bp->bundleheight+bundlei); + } else printf("iguana_peerblockrequest: %s error %s merkle cmp tx.[%d] for ht.%d\n",coin->symbol,bits256_str(str,block->RO.hash2),i,bp->bundleheight+bundlei); } else printf("iguana_peerblockrequest: error merkle verify tx.[%d] for ht.%d\n",i,bp->bundleheight+bundlei); } else diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index b36bbc4fd..0a230db22 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -374,13 +374,13 @@ struct iguana_bundle { struct queueitem DL; struct iguana_info *coin; struct iguana_bundle *nextbp; struct iguana_bloom16 bloom; int64_t totaldurations,duplicatedurations; int32_t durationscount,duplicatescount; - uint32_t issuetime,hdrtime,emitfinish,mergefinish,purgetime,queued,startutxo,utxofinish,balancefinish,validated,lastspeculative,dirty,nexttime,currenttime,lastprefetch,lastRT,missingstime,unsticktime,converted; + uint32_t issuetime,hdrtime,emitfinish,mergefinish,purgetime,queued,startutxo,balancefinish,validated,lastspeculative,dirty,nexttime,currenttime,lastprefetch,lastRT,missingstime,unsticktime,converted; int32_t numhashes,numrecv,numsaved,numcached,generrs,currentflag,origmissings,numissued,Xvalid; int32_t minrequests,n,hdrsi,bundleheight,numtxids,numspends,numunspents,numspec,isRT; double avetime,threshold,metric; uint64_t datasize,estsize; struct iguana_block *blocks[IGUANA_MAXBUNDLESIZE]; uint8_t *speculativecache[IGUANA_MAXBUNDLESIZE],haveblock[IGUANA_MAXBUNDLESIZE/3+1]; - uint32_t issued[IGUANA_MAXBUNDLESIZE]; + uint32_t issued[IGUANA_MAXBUNDLESIZE],firsttxidinds[IGUANA_MAXBUNDLESIZE]; bits256 prevbundlehash2,hashes[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash; struct iguana_ramchain ramchain; uint8_t red,green,blue; struct iguana_spendvector *tmpspends; int32_t numtmpspends; From 518b5c722fd08f61b317acb9b64c1541548de4f1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Sep 2016 10:56:18 -0300 Subject: [PATCH 50/55] match --- iguana/coins/genbtc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/iguana/coins/genbtc b/iguana/coins/genbtc index 1f69c6dde..42ceea975 100755 --- a/iguana/coins/genbtc +++ b/iguana/coins/genbtc @@ -1,5 +1 @@ -<<<<<<< HEAD -curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":256,\"endpend\":256,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" -======= curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}" ->>>>>>> master From a458241ec3b0986cb9f5eb4af03eaf48501b39a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Sep 2016 13:05:24 -0300 Subject: [PATCH 51/55] test --- iguana/coins/genbtc.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/iguana/coins/genbtc.json b/iguana/coins/genbtc.json index a429c24a0..96be3ba69 100755 --- a/iguana/coins/genbtc.json +++ b/iguana/coins/genbtc.json @@ -1,5 +1 @@ -<<<<<<< HEAD -{"numhelpers":4,"prefetchlag":-1,"poll":1,"active":1,"agent":"iguana","method":"addcoin","newcoin":"BTC","startpend":16,"endpend":16,"services":129,"maxpeers":512,"RELAY":1,"VALIDATE":1,"portp2p":8333} -======= {"numhelpers":1,"prefetchlag":-1,"poll":1,"active":1,"agent":"iguana","method":"addcoin","newcoin":"BTC","startpend":64,"endpend":64,"services":129,"maxpeers":512,"RELAY":1,"VALIDATE":1,"portp2p":8333} ->>>>>>> master From 28ad1e17fc813f0ed3fdef2eb68f28aba7eeae3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 11:04:16 -0300 Subject: [PATCH 52/55] fix --- iguana/iguana_sign.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/iguana/iguana_sign.c b/iguana/iguana_sign.c index 583d671d0..590d3dba4 100755 --- a/iguana/iguana_sign.c +++ b/iguana/iguana_sign.c @@ -273,11 +273,6 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin { if ( vin->vinscript == 0 ) { -<<<<<<< HEAD - //printf("null vinscript case\n"); -======= - //printf("null vinscript case -> need to sign this tx\n"); ->>>>>>> master vin->vinscript = serialized; vin->vinscript[0] = 0; vin->scriptlen = 1; From c800e2309c266e0339df525197725ee70b6cf1e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 15:27:21 -0300 Subject: [PATCH 53/55] merge --- basilisk/basilisk.c | 80 ++---------------------------------- basilisk/basilisk_DEX.c | 22 +++++++++- basilisk/basilisk_bitcoin.c | 15 +++++-- basilisk/basilisk_tradebot.c | 74 +++++++++++++++++++++++++++++++++ iguana/iguana777.c | 5 ++- iguana/iguana_realtime.c | 7 +++- iguana/iguana_spendvectors.c | 30 ++++++++++---- iguana/iguana_unspents.c | 1 + iguana/iguana_wallet.c | 6 --- iguana/tests/addnode2 | 2 + iguana/tests/listunspent | 2 +- includes/iguana_funcs.h | 1 + includes/iguana_structs.h | 2 +- 13 files changed, 145 insertions(+), 102 deletions(-) create mode 100755 iguana/tests/addnode2 diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index a1a1a4b07..b123cbeeb 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -799,80 +799,6 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t free(ptr); } -double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n) -{ - int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; uint64_t destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.; - memset(issueR,0,sizeof(*issueR)); - minamount = list[0].minamount; - //printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); - if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 ) - pendingid = active->req.quoteid; - if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request - myrequest = 1; - for (i=0; imyaddr.persistent,list[i].desthash) == 0 ) // my quoteid - myrequest |= 2; - havequoteflag++; - if ( pendingid == 0 ) - { - if ( list[i].destamount > maxamount ) - { - maxamount = list[i].destamount; - maxi = i; - } - } - else if ( active != 0 && pendingid == list[i].quoteid ) - { - } - } else noquoteflag++; - } - printf("myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount)); - double retvals[4],refprice,profitmargin,aveprice,balance=0.; cJSON *retjson; char *retstr; - if ( myinfo->IAMLP != 0 && myrequest == 0 && pendingid == 0 && noquoteflag != 0 && (profitmargin= tradebot_liquidity_active(myinfo,&refprice,list[0].src,list[0].dest)) > 0. ) - { - if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice ) - aveprice = refprice; - if ( fabs(aveprice) < SMALLVAL ) - return(0); - destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount; - if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - balance = jdouble(retjson,"result"); - free_json(retjson); - } - free(retstr); - } - printf("balance %.8f destamount %.8f aveprice %.8f minamount %.8f\n",balance,dstr(destamount),aveprice,dstr(minamount)); - if ( balance > destamount && destamount > 0 && destamount >= maxamount && destamount >= minamount ) - { - metric = 1.; - *issueR = list[0]; - issueR->desthash = myinfo->myaddr.persistent; - issueR->destamount = destamount; - issueR->quotetime = (uint32_t)time(NULL); - } - } - else if ( myrequest != 0 && pendingid == 0 && maxi >= 0 ) // automatch best quote - { - if ( minamount != 0 && maxamount > minamount && time(NULL) > BASILISK_DEXDURATION/2 ) - { - printf("automatch quoteid.%u triggered %.8f > %.8f\n",list[maxi].quoteid,dstr(maxamount),dstr(minamount)); - *issueR = list[maxi]; - if ( minamount > 0 ) - metric = (dstr(maxamount) / dstr(minamount)) - 1.; - else metric = 1.; - } - } - return(metric); -} - void basilisk_requests_poll(struct supernet_info *myinfo) { char *retstr; cJSON *outerarray,*retjson; int32_t i,n; struct basilisk_request issueR; double hwm = 0.; @@ -914,7 +840,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo) void basilisks_loop(void *arg) { - struct iguana_info *virt,*tmpcoin,*coin,*notary; struct basilisk_message *msg,*tmpmsg; struct basilisk_item *tmp,*pending; uint32_t now; int32_t iter,maxmillis,flag=0; struct supernet_info *myinfo = arg; + struct iguana_info *virt,*tmpcoin,*notary; struct basilisk_message *msg,*tmpmsg; struct basilisk_item *tmp,*pending; uint32_t now; int32_t iter,maxmillis,flag=0; struct supernet_info *myinfo = arg; iter = 0; while ( 1 ) { @@ -951,7 +877,7 @@ void basilisks_loop(void *arg) } // else printf("not notary %p %d\n",notary,myinfo->NOTARY.RELAYID); else if ( myinfo->expiration != 0 ) { - HASH_ITER(hh,myinfo->allcoins,coin,tmpcoin) + /*HASH_ITER(hh,myinfo->allcoins,coin,tmpcoin) { if ( strcmp(coin->symbol,"NOTARY") != 0 && (myinfo->Cunspents == 0 || time(NULL) > coin->lastunspentsupdate+60) ) { @@ -960,7 +886,7 @@ void basilisks_loop(void *arg) coin->lastunspentsupdate = now; //printf(">>>>>>>>>>>>> update %s finished\n",coin->symbol); } - } + }*/ if ( myinfo->IAMLP != 0 || myinfo->DEXactive > now ) basilisk_requests_poll(myinfo); } diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index 657f6baa4..5bdfbc126 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -413,10 +413,30 @@ ZERO_ARGS(InstantDEX,allcoins) STRING_ARG(InstantDEX,available,source) { + char *retstr; cJSON *vals,*balancejson,*retjson = 0; if ( source != 0 && source[0] != 0 && (coin= iguana_coinfind(source)) != 0 ) { if ( myinfo->expiration != 0 ) - return(bitcoinrpc_getbalance(myinfo,coin,json,remoteaddr,"*",coin->chain->minconfirms,1,1<<30)); + { + //return(bitcoinrpc_getbalance(myinfo,coin,json,remoteaddr,"*",coin->chain->minconfirms,1,1<<30)); + if ( (vals= basilisk_balance_valsobj(myinfo,coin)) != 0 ) + { + if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 ) + { + printf("available.(%s)\n",retstr); + if ( (balancejson= cJSON_Parse(retstr)) != 0 ) + { + retjson = cJSON_CreateObject(); + jaddnum(retjson,"result",jdouble(balancejson,"balance")); + free_json(balancejson); + } + free(retstr); + } + free_json(vals); + if ( retjson != 0 ) + return(jprint(retjson,1)); + } + } printf("InstantDEX_available: need to unlock wallet\n"); return(clonestr("{\"error\":\"need to unlock wallet\"}")); } diff --git a/basilisk/basilisk_bitcoin.c b/basilisk/basilisk_bitcoin.c index 6251972e7..2fab0e662 100755 --- a/basilisk/basilisk_bitcoin.c +++ b/basilisk/basilisk_bitcoin.c @@ -334,6 +334,7 @@ void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info * jaddstr(retjson,"result","success"); jaddstr(retjson,"ipaddr",myinfo->ipaddr); jaddnum(retjson,"total",dstr(total)); + jaddnum(retjson,"balance",dstr(total)); jadd(retjson,"addresses",array); if ( unspents != 0 ) jadd(retjson,"unspents",unspents); @@ -1006,17 +1007,23 @@ void basilisk_unspents_process(struct supernet_info *myinfo,struct iguana_info * portable_mutex_unlock(&myinfo->bu_mutex); } -void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin) +cJSON *basilisk_balance_valsobj(struct supernet_info *myinfo,struct iguana_info *coin) { - char *retstr; cJSON *vals; int32_t oldest,i,RTheight; - vals = cJSON_CreateObject(); + int32_t oldest,i,RTheight; cJSON *vals; for (i=oldest=0; irelay_RTheights[i]) != 0 && (oldest == 0 || RTheight < oldest) ) oldest = RTheight; + vals = cJSON_CreateObject(); jaddnum(vals,"firstheight",oldest); jaddnum(vals,"history",3); jaddstr(vals,"coin",coin->symbol); - if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 ) + return(vals); +} + +void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin) +{ + char *retstr; cJSON *vals; + if ( (vals= basilisk_balance_valsobj(myinfo,coin)) != 0 && (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 ) { basilisk_unspents_process(myinfo,coin,retstr); free(retstr); diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index ee975cb6e..ae3dfa0dd 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -158,6 +158,80 @@ double tradebot_liquidity_active(struct supernet_info *myinfo,double *refpricep, return(0.); } +double basilisk_request_listprocess(struct supernet_info *myinfo,struct basilisk_request *issueR,struct basilisk_request *list,int32_t n) +{ + int32_t i,noquoteflag=0,havequoteflag=0,myrequest=0,maxi=-1; uint64_t destamount,minamount = 0,maxamount = 0; uint32_t pendingid=0; struct basilisk_swap *active; double metric = 0.; + memset(issueR,0,sizeof(*issueR)); + minamount = list[0].minamount; + //printf("need to verify null quoteid is list[0] requestid.%u quoteid.%u\n",list[0].requestid,list[0].quoteid); + if ( (active= basilisk_request_started(myinfo,list[0].requestid)) != 0 ) + pendingid = active->req.quoteid; + if ( bits256_cmp(myinfo->myaddr.persistent,list[0].srchash) == 0 ) // my request + myrequest = 1; + for (i=0; imyaddr.persistent,list[i].desthash) == 0 ) // my quoteid + myrequest |= 2; + havequoteflag++; + if ( pendingid == 0 ) + { + if ( list[i].destamount > maxamount ) + { + maxamount = list[i].destamount; + maxi = i; + } + } + else if ( active != 0 && pendingid == list[i].quoteid ) + { + } + } else noquoteflag++; + } + printf("%s -> %s myrequest.%d pendingid.%u noquoteflag.%d havequoteflag.%d maxi.%d %.8f\n",list[0].src,list[0].dest,myrequest,pendingid,noquoteflag,havequoteflag,maxi,dstr(maxamount)); + double retvals[4],refprice,profitmargin,aveprice,balance=0.; cJSON *retjson; char *retstr; + if ( myinfo->IAMLP != 0 && myrequest == 0 && pendingid == 0 && noquoteflag != 0 && (profitmargin= tradebot_liquidity_active(myinfo,&refprice,list[0].src,list[0].dest)) > 0. ) + { + if ( (aveprice= instantdex_avehbla(myinfo,retvals,list[0].src,list[0].dest,1.3 * dstr(list[0].srcamount))) == 0. || refprice > aveprice ) + aveprice = refprice; + if ( fabs(aveprice) < SMALLVAL ) + return(0); + destamount = (1.0 - profitmargin) * aveprice * list[0].srcamount; + if ( (retstr= InstantDEX_available(myinfo,iguana_coinfind(list[0].dest),0,0,list[0].dest)) != 0 ) + { + if ( (retjson= cJSON_Parse(retstr)) != 0 ) + { + balance = jdouble(retjson,"result"); + free_json(retjson); + } + free(retstr); + } + printf("%s balance %.8f destamount %.8f aveprice %.8f minamount %.8f\n",list[0].dest,balance,dstr(destamount),aveprice,dstr(minamount)); + if ( balance > destamount && destamount > 0 && destamount >= maxamount && destamount >= minamount ) + { + metric = 1.; + *issueR = list[0]; + issueR->desthash = myinfo->myaddr.persistent; + issueR->destamount = destamount; + issueR->quotetime = (uint32_t)time(NULL); + } + } + else if ( myrequest != 0 && pendingid == 0 && maxi >= 0 ) // automatch best quote + { + if ( minamount != 0 && maxamount > minamount && time(NULL) > BASILISK_DEXDURATION/2 ) + { + printf("automatch quoteid.%u triggered %.8f > %.8f\n",list[maxi].quoteid,dstr(maxamount),dstr(minamount)); + *issueR = list[maxi]; + if ( minamount > 0 ) + metric = (dstr(maxamount) / dstr(minamount)) - 1.; + else metric = 1.; + } + } + return(metric); +} + double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_request *issueR,cJSON *retjson,double hwm) { cJSON *array,*item; uint8_t *hexdata,*allocptr,hexspace[8192]; char *hexstr; int32_t i,hexlen,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; diff --git a/iguana/iguana777.c b/iguana/iguana777.c index ceca16074..dbbab44bf 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -615,7 +615,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co //if ( (bp= coin->current) != 0 && bp->numsaved >= coin->chain->bundlesize && bp->startutxo == 0 ) // iguana_bundlefinalize(myinfo,coin,bp,mem,memB); n = coin->bundlescount-1; - if ( coin->spendvectorsaved == 0 && coin->blocks.hwmchain.height/coin->chain->bundlesize >= (coin->longestchain-coin->chain->bundlesize)/coin->chain->bundlesize ) + if ( coin->matchedfiles == 0 && coin->spendvectorsaved == 0 && coin->blocks.hwmchain.height/coin->chain->bundlesize >= (coin->longestchain-coin->chain->bundlesize)/coin->chain->bundlesize ) { //printf("%s n.%d emitfinished.%d coin->spendvectorsaved %d\n",coin->symbol,n,iguana_emitfinished(myinfo,coin,1),coin->spendvectorsaved); if ( iguana_emitfinished(myinfo,coin,1) >= n ) @@ -627,8 +627,9 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co iguana_alloctxbits(coin,&coin->bundles[j]->ramchain); sleep(3); }*/ - if ( iguana_validated(coin) < n || iguana_utxofinished(coin) < n || iguana_balancefinished(coin) < n ) + if ( (iguana_utxofinished(coin) < n || iguana_balancefinished(coin) < n || iguana_validated(coin) < n) ) { + //printf("About to generate tables\n"), getchar(); iguana_fastfindreset(coin); iguana_fastfindcreate(coin); if ( coin->fastfind == 0 ) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 8dc95fe6e..1290d80e6 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -781,7 +781,7 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str } if ( block != 0 && coin->RTheight > 0 && coin->utxoaddrtable != 0 )//&& coin->RTheight <= coin->blocks.hwmchain.height ) { - if ( block->height <= coin->lastRTheight+coin->minconfirms ) + if ( block->height <= (coin->RTheight - coin->minconfirms + 1) ) return; if ( (block= iguana_blockfind("RTnew",coin,iguana_blockhash(coin,block->height-coin->minconfirms))) == 0 ) return; @@ -817,6 +817,11 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str } } coin->RTheight += i; +<<<<<<< HEAD +======= + //if ( coin->RTheight != coin->lastRTheight+1 ) + // printf("ERROR: "); +>>>>>>> master //printf("%s >= RTnewblock RTheight %d prev %d\n",coin->symbol,coin->RTheight,coin->lastRTheight); } else if ( block->height == coin->lastRTheight ) diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 103bfd574..c99bb2b44 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -634,6 +634,11 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co from_ro = 0; } } + if ( coin->longestchain <= coin->bundlescount*coin->chain->bundlesize-coin->chain->minconfirms ) + { + iguana_bundlestats(myinfo,coin,buf,IGUANA_DEFAULTLAG); + return(coin->bundlescount); + } /*if ( i < coin->balanceswritten-1 ) { printf("TRUNCATE balances written.%d -> %d\n",coin->balanceswritten,i); @@ -706,6 +711,21 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co if ( fwrite(&crc,1,sizeof(crc),fp) != sizeof(crc) || fwrite(&balancehash,1,sizeof(balancehash),fp) != sizeof(balancehash) || fwrite(&allbundles,1,sizeof(allbundles),fp) != sizeof(allbundles) ) printf("error writing.(%s)\n",crcfname); fclose(fp); + if ( coin->longestchain <= coin->bundlescount*coin->chain->bundlesize-coin->chain->minconfirms ) + { + for (i=0; ibundlescount-1; i++) + { + if ( (bp= coin->bundles[i]) != 0 ) + { + bp->converted = bp->balancefinish = bp->validated = bp->utxofinish = (uint32_t)time(NULL); + } + } + coin->matchedfiles = 1; + 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); + } } else { @@ -726,17 +746,9 @@ int32_t iguana_volatilesinit(struct supernet_info *myinfo,struct iguana_info *co iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); } } - if ( iguana_fastfindinit(coin) == 0 )//&& coin->PREFETCHLAG >= 0 ) + if ( iguana_fastfindinit(coin) == 0 ) iguana_fastfindcreate(coin); - /*for (j=0; jbundlescount; j++) - if ( (bp= coin->bundles[j]) != 0 ) - { - iguana_volatilesalloc(coin,&bp->ramchain,1); - iguana_volatilesmap(coin,&bp->ramchain); - } - iguana_update_balances(coin);*/ iguana_datachain_scan(myinfo,coin,CRYPTO777_RMD160); - //iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize);*/ printf("end %s volatilesinit\n",coin->symbol); return(coin->bundlescount); } diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 8bcd08b79..2d1d57262 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1002,6 +1002,7 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi } else { + basilisk_unspents_update(myinfo,coin); portable_mutex_lock(&myinfo->bu_mutex); if ( (unspents= myinfo->Cunspents) != 0 && (array= jobj(unspents,coin->symbol)) != 0 ) unspents = jduplicate(array); diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index 3fa792ad4..30174cfa3 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -762,12 +762,6 @@ cJSON *iguana_walletiterate(struct supernet_info *myinfo,struct iguana_info *coi if ( flag < -1 ) { HASH_DELETE(hh,wacct->waddr,waddr); - /*if ( waddr->Cunspents != 0 ) - free_json(waddr->Cunspents), waddr->Cunspents = 0; - if ( waddr->Cspends != 0 ) - free_json(waddr->Cspends), waddr->Cspends = 0; - */ - //printf("walletiterate: %p free %s\n",waddr,waddr->coinaddr); myfree(waddr,sizeof(*waddr) + waddr->scriptlen); } } diff --git a/iguana/tests/addnode2 b/iguana/tests/addnode2 new file mode 100755 index 000000000..924371c17 --- /dev/null +++ b/iguana/tests/addnode2 @@ -0,0 +1,2 @@ +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"BTC\",\"ipaddr\":\"5.9.102.210\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addnode\",\"activecoin\":\"BTC\",\"ipaddr\":\"78.47.196.146\"}" diff --git a/iguana/tests/listunspent b/iguana/tests/listunspent index 119eacd67..c1795bbaa 100755 --- a/iguana/tests/listunspent +++ b/iguana/tests/listunspent @@ -1 +1 @@ -curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"listunspent\",\"params\":[1, 9999999, [\"RD1rFucYCMhCGeEqdztivP3DFdJwVAzXn7\"]]}" +curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"listunspent\",\"params\":[1, 9999999, [\"1E2ac2gxeFR2ir1H3vqETTperWkiXkwy99\"]]}" diff --git a/includes/iguana_funcs.h b/includes/iguana_funcs.h index a3ab668b0..4fb78d629 100755 --- a/includes/iguana_funcs.h +++ b/includes/iguana_funcs.h @@ -438,6 +438,7 @@ int64_t iguana_addressreceived(struct supernet_info *myinfo,struct iguana_info * cJSON *iguana_walletjson(struct supernet_info *myinfo); int32_t iguana_payloadupdate(struct supernet_info *myinfo,struct iguana_info *coin,char *retstr,struct iguana_waddress *waddr,char *account); int32_t bitcoin_MofNspendscript(uint8_t p2sh_rmd160[20],uint8_t *script,int32_t n,const struct vin_info *vp); +cJSON *basilisk_balance_valsobj(struct supernet_info *myinfo,struct iguana_info *coin); void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin); struct iguana_txid *iguana_blocktx(struct iguana_info *coin,struct iguana_txid *tx,struct iguana_block *block,int32_t i); cJSON *iguana_p2shjson(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *retjson,struct iguana_waddress *waddr); diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index d459c99d6..f1550d962 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -482,7 +482,7 @@ struct iguana_info struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending; struct OS_memspace RTrawmem,RTmem,RThashmem; // struct iguana_ramchain RTramchain; bits256 RThash1; - int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth; + int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth,matchedfiles; uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated,coinid; double bandwidth,maxbandwidth,backstopmillis; bits256 backstophash2; int64_t spaceused; int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy,almostRT,busy_processing; bits256 reqtxids[64]; From 75e2c3d83ccdb626900f0017b9d3221bf460e0a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 15:28:55 -0300 Subject: [PATCH 54/55] test --- iguana/iguana_realtime.c | 51 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index 1290d80e6..9c20847a1 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -767,12 +767,12 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str } iguana_RTbalance_verify("start iterate",coin); /*if ( strcmp(coin->symbol,"BTC") != 0 && strcmp(coin->symbol,"LTC") != 0 ) - { - if ( block->height < coin->firstRTheight+coin->minconfirms ) - return; - if ( (block= iguana_blockfind("RTnew",coin,iguana_blockhash(coin,block->height-coin->minconfirms))) == 0 ) - return; - }*/ + { + if ( block->height < coin->firstRTheight+coin->minconfirms ) + return; + if ( (block= iguana_blockfind("RTnew",coin,iguana_blockhash(coin,block->height-coin->minconfirms))) == 0 ) + return; + }*/ if ( block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) ) { if ( 0 && coin->firstRTheight > 0 ) @@ -817,11 +817,8 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str } } coin->RTheight += i; -<<<<<<< HEAD -======= //if ( coin->RTheight != coin->lastRTheight+1 ) // printf("ERROR: "); ->>>>>>> master //printf("%s >= RTnewblock RTheight %d prev %d\n",coin->symbol,coin->RTheight,coin->lastRTheight); } else if ( block->height == coin->lastRTheight ) @@ -842,24 +839,24 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str char str[65]; printf("reorg RTheight.%d vs block.%d %s\n",coin->RTheight,block->height,bits256_str(str,block->RO.hash2)); iguana_RTreset(coin); /*while ( coin->RTheight > block->height ) - { - if ( iguana_RTblocksub(myinfo,coin,iguana_RTblock(coin,coin->RTheight-1)) < 0 ) - { - printf("error subtracting %d\n",coin->RTheight-1); - coin->lastRTheight = coin->RTheight-1; - portable_mutex_unlock(&coin->RTmutex); - return; - } - coin->RTheight--; - } - if ( iguana_RTblockadd(myinfo,coin,block) < 0 ) - { - printf("error adding %d\n",block->height); - portable_mutex_unlock(&coin->RTmutex); - return; - } - coin->lastRTheight = block->height; - coin->RTheight = coin->lastRTheight+1;*/ + { + if ( iguana_RTblocksub(myinfo,coin,iguana_RTblock(coin,coin->RTheight-1)) < 0 ) + { + printf("error subtracting %d\n",coin->RTheight-1); + coin->lastRTheight = coin->RTheight-1; + portable_mutex_unlock(&coin->RTmutex); + return; + } + coin->RTheight--; + } + if ( iguana_RTblockadd(myinfo,coin,block) < 0 ) + { + printf("error adding %d\n",block->height); + portable_mutex_unlock(&coin->RTmutex); + return; + } + coin->lastRTheight = block->height; + coin->RTheight = coin->lastRTheight+1;*/ } portable_mutex_unlock(&coin->RTmutex); } From 078ac28c6748666a16a80f75869438316f8df736 Mon Sep 17 00:00:00 2001 From: flamingice Date: Fri, 23 Sep 2016 01:00:27 +0200 Subject: [PATCH 55/55] vs files in iguana dir, project file paths changed --- iguana/iguana.vcxproj | 297 ++++++++++++++++++++++++++++++++++ iguana/iguana.vcxproj.filters | 146 +++++++++++++++++ iguana/pthreadVC2.lib | Bin 0 -> 28767 bytes iguana/pthreadvc2.dll | Bin 0 -> 86070 bytes 4 files changed, 443 insertions(+) create mode 100644 iguana/iguana.vcxproj create mode 100644 iguana/iguana.vcxproj.filters create mode 100644 iguana/pthreadVC2.lib create mode 100644 iguana/pthreadvc2.dll diff --git a/iguana/iguana.vcxproj b/iguana/iguana.vcxproj new file mode 100644 index 000000000..6bb9c2eaa --- /dev/null +++ b/iguana/iguana.vcxproj @@ -0,0 +1,297 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {80F58B93-D1FC-4FC4-A880-1F40A1FC851B} + Win32Proj + ConsoleApplication3 + 8.1 + iguana + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level2 + Disabled + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + 1Byte + + + Console + true + Ws2_32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + 1Byte + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + true + Ws2_32.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + _CRT_SECURE_NO_WARNINGS;NATIVE_WINDOWS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions) + 1Byte + + + Console + true + true + true + Ws2_32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iguana/iguana.vcxproj.filters b/iguana/iguana.vcxproj.filters new file mode 100644 index 000000000..da9ab88db --- /dev/null +++ b/iguana/iguana.vcxproj.filters @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/iguana/pthreadVC2.lib b/iguana/pthreadVC2.lib new file mode 100644 index 0000000000000000000000000000000000000000..d793e7144bf2708aea58459ff135919f9ca9d996 GIT binary patch literal 28767 zcmd^HON>;<)jkYPOo&5>jh%-v9%GELjRy?OfC+{H2Fzm^U>M$yrl-4M8hW~$?jBx= zl8t3$5m{M8UL{hLMdTH-qR5NLioD1o@*?_WdGRZXvWTKAtSE|{P2^4fuc~g{Tc_@+ zYMSX`^N)1szI7g7ovKrHPd%FFb`)EsnVm~F4D!F%HgDdxam&c?$S^P8m^^OXJd%99 zyp)LkO|%`KJ4T7#xJy(YGPL(yB1OA?Z)kKok)p9BhW7lDNYVbLp}i|158D5kp*`!t z2kra9&_UQybl?w$4vyg&bZDociN6vlI`R)g6IbvII(o*?sdYq(j;}Rz^(i7nlLLlM zzfGj*0_-U|`-!1*9}_9MxW&*V_^0SR>Z0i4uMM3)fM?Jt_^jx{2Zqj#LmzbFPll#Y zA4Mn1hAzDad!Sj^R8+fXs0`bRO2AfB-fyU~gGkZ79~j#GK9MHWZ#QV{EkmQgS2TIo zPy=;R)LfPj+O??&J}bIWH`M+Sk)j)@ucA5BP0`Fh4V^?kYx)g7L6iS7R2xFQL9_P^ z?L)gNI)*wZs{Gc_%ps3_AW(L%Sw0 zZa_QXi=tz|RdoHHq08TgT}7W8Dt<gZ&l*_mloise&#H&LN5adLb-FGD}fgpA14fs+%5 z3uC*dc0;K;+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