Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
e1931425b8
  1. 4
      gecko/gecko_blocks.c
  2. 2
      iguana/coins/genbtcd
  3. 20
      iguana/iguana777.c
  4. 37
      iguana/iguana_bundles.c
  5. 24
      iguana/iguana_peers.c
  6. 90
      iguana/iguana_ramchain.c
  7. 376
      iguana/iguana_recv.c
  8. 4
      includes/iguana_defines.h
  9. 3
      includes/iguana_funcs.h
  10. 2
      includes/iguana_structs.h

4
gecko/gecko_blocks.c

@ -121,7 +121,7 @@ struct iguana_bundle *gecko_ensurebundle(struct iguana_info *virt,struct iguana_
int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_txblock *txdata,struct iguana_msgtx *txarray,uint8_t *data,int32_t datalen,int32_t depth,int32_t verifyonly)
{
struct iguana_peer *addr; int32_t i,hdrsi; struct iguana_bundle *bp,*prevbp; struct iguana_block *block;
struct iguana_peer *addr; int32_t i,hdrsi; struct iguana_bundle *bp=0,*prevbp; struct iguana_block *block;
if ( (block= iguana_blockhashset("gecko_hwmset",virt,txdata->zblock.height,txdata->zblock.RO.hash2,1)) != 0 )
{
iguana_blockcopy(virt->chain->zcash,virt->chain->auxpow,virt,block,(struct iguana_block *)&txdata->zblock);
@ -132,7 +132,7 @@ int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struc
printf("no bundle for %s.%d\n",virt->symbol,block->height);
return(-1);
}
if ( iguana_ramchain_data(virt,addr,txdata,txarray,block->RO.txn_count,data,datalen) >= 0 )
if ( iguana_ramchain_data(virt,addr,txdata,txarray,block->RO.txn_count,data,datalen,bp,block) >= 0 )
{
block->fpipbits = (uint32_t)addr->ipbits;
block->RO.recvlen = datalen;

2
iguana/coins/genbtcd

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"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}"
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":-1,\"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}"

20
iguana/iguana777.c

@ -288,8 +288,7 @@ void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct
ptr->starttime = (uint32_t)time(NULL);
ptr->timelimit = timelimit;
coin->numbundlesQ++;
//if ( 0 && bp->hdrsi > 170 )
printf("%s.%d %p bundle.%d[%d] ht.%d emitfinish.%u\n",coin->symbol,n,bp,ptr->hdrsi,bp->n,bp->bundleheight,bp->emitfinish);
// printf("%s.%d %p bundle.%d[%d] ht.%d emitfinish.%u\n",coin->symbol,n,bp,ptr->hdrsi,bp->n,bp->bundleheight,bp->emitfinish);
queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL,0);
}
else
@ -595,6 +594,8 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co
printf("%s main.%u vs %u, svs %u %d vs %d\n",coin->symbol,(uint32_t)time(NULL),coin->startutc+10,coin->spendvectorsaved ,coin->blocks.hwmchain.height/coin->chain->bundlesize,(coin->longestchain-coin->minconfirms)/coin->chain->bundlesize);
if ( time(NULL) > coin->startutc+60 )
{
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->blocks.hwmchain.height/coin->chain->bundlesize >= (coin->longestchain-coin->chain->bundlesize)/coin->chain->bundlesize )
{
@ -623,16 +624,16 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co
else
{
for (j=0; j<coin->bundlescount; j++)
if ( (bp= coin->bundles[j]) != 0 && bp->ramchain.H.data == 0 && bp->queued == 0 )
if ( (bp= coin->bundles[j]) != 0 && bp->ramchain.H.data == 0 && bp->startutxo == 0 )//&& bp->queued == 0 )
{
if ( iguana_bundleready(myinfo,coin,bp,0) == bp->n )
{
printf("finalize.[%d]\n",bp->hdrsi);
//printf("finalize.[%d]\n",bp->hdrsi);
if ( iguana_bundlefinalize(myinfo,coin,bp,mem,memB) > 0 )
continue;
}
//printf("bundleQ.[%d]\n",j);
iguana_bundleQ(myinfo,coin,bp,1000);
//iguana_bundleQ(myinfo,coin,bp,1000);
}
//coin->spendvectorsaved = 1;
}
@ -725,7 +726,7 @@ void iguana_helper(void *arg)
allcurrent = 0;
//printf("h.%d [%d] bundleQ size.%d lag.%ld\n",helperid,bp->hdrsi,queue_size(&bundlesQ),time(NULL) - bp->nexttime);
coin->numbundlesQ--;
if ( coin->started != 0 && time(NULL) > bp->nexttime && coin->active != 0 )
if ( bp->startutxo == 0 && coin->started != 0 && time(NULL) > bp->nexttime && coin->active != 0 )
{
flag += iguana_bundleiters(myinfo,ptr->coin,&MEM,MEMB,bp,ptr->timelimit,IGUANA_DEFAULTLAG);
}
@ -946,7 +947,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
if ( (coin->MAXRECVCACHE= maxrecvcache) == 0 )
coin->MAXRECVCACHE = IGUANA_MAXRECVCACHE;
if ( (coin->MAXPENDINGREQUESTS= maxrequests) <= 0 )
coin->MAXPENDINGREQUESTS = (strcmp(symbol,"BTC") == 0) ? IGUANA_MAXPENDINGREQUESTS : IGUANA_PENDINGREQUESTS;
coin->MAXPENDINGREQUESTS = (strcmp(symbol,"BTC") == 0) ? IGUANA_BTCPENDINGREQUESTS : IGUANA_PENDINGREQUESTS;
if ( jobj(json,"prefetchlag") != 0 )
coin->PREFETCHLAG = jint(json,"prefetchlag");
else if ( strcmp("BTC",coin->symbol) == 0 )
@ -1134,3 +1135,8 @@ char *busdata_sync(uint32_t *noncep,char *jsonstr,char *broadcastmode,char *dest
printf("busdata_sync.(%s)\n",jsonstr);
return(0);
}
// getnewaddress, setaccount, validate address, restart, validate address
// importprivkey, setaccount, validate, restart, validate

37
iguana/iguana_bundles.c

@ -841,7 +841,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
}
else
{
iguana_blockunmark(coin,block,bp,i,0);
//iguana_blockunmark(coin,block,bp,i,0);
//printf("cant find (%s)\n",fname);
}
}
@ -863,7 +863,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin
int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti)
{
int32_t i,dist,counter=0; char str[65];
int32_t dist,counter=0; char str[65];
if ( 0 && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) )
printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec);
dist = 30 + (coin->current != 0 ? bp->hdrsi - coin->current->hdrsi : 0);
@ -879,9 +879,9 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s
if ( bp->numhashes < bp->n && bp->numcached < bp->n )
{
//printf("issue current hdr.[%d]\n",bp->hdrsi);
for (i=0; i<bp->n; i++)
if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0;
//for (i=0; i<bp->n; i++)
// if ( GETBIT(bp->haveblock,i) == 0 )
// bp->issued[i] = 0;
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
}
iguana_bundleissuemissing(myinfo,coin,bp,3,3.);
@ -1130,10 +1130,10 @@ int32_t iguana_bundleiters(struct supernet_info *myinfo,struct iguana_info *coin
{
max = bp->n;
counter = iguana_bundleissuemissing(myinfo,coin,bp,1,1.);
if ( 0 && counter > 0 )
if ( 1 && counter > 0 )
printf("starti.%d range.%d now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",starti,range,(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);
} else bp->nexttime++;
if ( bp->emitfinish <= 1 )
if ( 0 && bp->emitfinish <= 1 )
iguana_bundleQ(myinfo,coin,bp,1000);
else
{
@ -1175,12 +1175,7 @@ int32_t iguana_cacheprocess(struct supernet_info *myinfo,struct iguana_info *coi
memset(&H,0,sizeof(H));
if ( iguana_sethdr(&H,coin->chain->netmagic,"block",&data[sizeof(recvlen)],recvlen) > 0 )
{
if ( coin->internaladdr.RAWMEM.ptr == 0 )
iguana_meminit(&coin->internaladdr.RAWMEM,"cache",0,IGUANA_MAXPACKETSIZE + 65536*3,0);
if ( coin->TXMEM.ptr == 0 )
iguana_meminit(&coin->internaladdr.TXDATA,"txdata",0,IGUANA_MAXPACKETSIZE*1.5,0);
if ( coin->internaladdr.HASHMEM.ptr == 0 )
iguana_meminit(&coin->internaladdr.HASHMEM,"HASHPTRS",0,256,0);
iguana_peer_meminit(coin,&coin->internaladdr);
if ( iguana_msgparser(myinfo,coin,&coin->internaladdr,&coin->internaladdr.RAWMEM,&coin->internaladdr.TXDATA,&coin->internaladdr.HASHMEM,&H,&data[sizeof(recvlen)],recvlen,1) < 0 )
printf("error parsing speculativecache.[%d:%d]\n",bp->hdrsi,bundlei);
}
@ -1353,7 +1348,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
bp->issued[j] = block->issued;
}
}
if ( bp->hdrsi >= starti && bp->hdrsi < lasti )
if ( 0 && bp->hdrsi >= starti && bp->hdrsi < lasti )
iguana_bundlemissings(myinfo,coin,bp,now);
}
bp->metric = coin->bundlescount - bp->hdrsi;
@ -1450,10 +1445,10 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
iguana_bundleQ(myinfo,coin,bp,0);
}
//else printf("issue 1st.%d\n",bp->hdrsi);
for (i=0; i<bp->n; i++)
if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0;
iguana_bundleissuemissing(myinfo,coin,bp,1 + (rand() % 3),1.);
//for (i=0; i<bp->n; i++)
// if ( GETBIT(bp->haveblock,i) == 0 )
// bp->issued[i] = 0;
//iguana_bundleissuemissing(myinfo,coin,bp,1 + (rand() % 3),1.);
}
if ( (coin->current= firstgap) == 0 )
{
@ -1503,9 +1498,9 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,1);
}
}
for (i=0; i<bp->n; i++)
if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0;
//for (i=0; i<bp->n; i++)
// if ( GETBIT(bp->haveblock,i) == 0 )
// bp->issued[i] = 0;
if ( (n= iguana_bundleissuemissing(myinfo,coin,bp,3,1.)) > 0 )
printf("issued %d priority requests [%d] to unstick stuckiters.%d lag.%d\n",n,bp->hdrsi,coin->stuckiters,lag);
//else printf("no bundlerequests issued\n");

24
iguana/iguana_peers.c

@ -572,6 +572,20 @@ int32_t iguana_recv(char *ipaddr,int32_t usock,uint8_t *recvbuf,int32_t len)
return(len);
}
void iguana_peer_meminit(struct iguana_info *coin,struct iguana_peer *addr)
{
if ( addr->RAWMEM.ptr == 0 )
iguana_meminit(&addr->RAWMEM,addr->ipaddr,0,IGUANA_MAXPACKETSIZE * 2,0);
if ( addr->TXDATA.ptr == 0 )
iguana_meminit(&addr->TXDATA,"txdata",0,IGUANA_MAXPACKETSIZE * 2,0);
if ( addr->HASHMEM.ptr == 0 )
iguana_meminit(&addr->HASHMEM,"HASHPTRS",0,256,0);//IGUANA_MAXPACKETSIZE*16,0);
//printf("Init %s memory %p %p %p\n",addr->ipaddr,addr->RAWMEM.ptr,addr->TXDATA.ptr,addr->HASHMEM.ptr);
iguana_memreset(&addr->RAWMEM);
iguana_memreset(&addr->TXDATA);
iguana_memreset(&addr->HASHMEM);
}
void iguana_parsebuf(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len,int32_t fromcache)
{
struct iguana_msghdr checkH;
@ -579,15 +593,7 @@ void iguana_parsebuf(struct supernet_info *myinfo,struct iguana_info *coin,struc
if ( iguana_sethdr(&checkH,coin->chain->netmagic,H->command,buf,len) > 0 && memcmp(&checkH,H,sizeof(checkH)) == 0 )
{
if ( strcmp(H->command,"block") == 0 || strcmp(H->command,"getblocks") == 0 || strcmp(H->command,"tx") == 0 )
{
if ( addr->RAWMEM.ptr == 0 )
iguana_meminit(&addr->RAWMEM,addr->ipaddr,0,IGUANA_MAXPACKETSIZE * 2,0);
if ( addr->TXDATA.ptr == 0 )
iguana_meminit(&addr->TXDATA,"txdata",0,IGUANA_MAXPACKETSIZE * 2,0);
if ( addr->HASHMEM.ptr == 0 )
iguana_meminit(&addr->HASHMEM,"HASHPTRS",0,256,0);//IGUANA_MAXPACKETSIZE*16,0);
//printf("Init %s memory %p %p %p\n",addr->ipaddr,addr->RAWMEM.ptr,addr->TXDATA.ptr,addr->HASHMEM.ptr);
}
iguana_peer_meminit(coin,addr);
if ( iguana_msgparser(myinfo,coin,addr,&addr->RAWMEM,&addr->TXDATA,&addr->HASHMEM,H,buf,len,fromcache) < 0 || addr->dead != 0 )
{
printf("%p addr->dead.%d or parser break at %u\n",&addr->dead,addr->dead,(uint32_t)time(NULL));

90
iguana/iguana_ramchain.c

@ -1831,88 +1831,22 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info
return(0);
}
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)
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)
{
static uint64_t totalrecv;
int32_t verifyflag = 0;
RAMCHAIN_DECLARE; uint32_t addr_ipbits; 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,msize,sigsize,subdir,firsti=1,err,flag,bundlei = -2; bits256 merkle_root; struct iguana_bundle *bp = 0; struct iguana_block *block; uint32_t scriptspace,stackspace;
totalrecv += recvlen;
#ifdef __PNACL__
//verifyflag = 1;
#endif
if ( addr == 0 || (addr_ipbits= (uint32_t)addr->ipbits) == 0 )
addr_ipbits = 1;
if ( bits256_nonz(origtxdata->zblock.RO.merkle_root) == 0 )
{
memset(&origtxdata->zblock.RO.prev_block,0,sizeof(bits256));
origtxdata->zblock.RO.recvlen = 0;
origtxdata->zblock.issued = 0;
return(-1);
}
if ( addr != 0 )
{
for (i=0; i<sizeof(addr->dirty)/sizeof(*addr->dirty); i++)
addr->dirty[i] = 0;
}
msize = (int32_t)sizeof(bits256) * (txn_count+1) * 2;
if ( msize <= addr->TXDATA.totalsize )
{
bits256 *tree = addr->TXDATA.ptr;
iguana_memreset(&addr->TXDATA);
for (i=0; i<txn_count; i++)
tree[i] = txarray[i].txid;
merkle_root = iguana_merkle(tree,txn_count);
if ( bits256_cmp(merkle_root,origtxdata->zblock.RO.merkle_root) != 0 )
{
char str[65],str2[65];
printf(">>>>>>>>>> %s %s merkle mismatch.[%d] calc.(%s) vs (%s)\n",addr->ipaddr,coin->symbol,txn_count,bits256_str(str,merkle_root),bits256_str(str2,origtxdata->zblock.RO.merkle_root));
origtxdata->zblock.RO.recvlen = 0;
origtxdata->zblock.issued = 0;
return(-1);
} //else printf("matched merkle.%d\n",txn_count);
} else printf("not enough memory for merkle verify %d vs %lu\n",(int32_t)(sizeof(bits256)*(txn_count+1)),(long)addr->TXDATA.totalsize);
bp = 0, bundlei = -2;
if ( iguana_bundlefind(coin,&bp,&bundlei,origtxdata->zblock.RO.hash2) == 0 )
{
bp = 0, bundlei = -2;
if ( iguana_bundlefind(coin,&bp,&bundlei,origtxdata->zblock.RO.prev_block) == 0 )
{
origtxdata->zblock.RO.recvlen = 0;
origtxdata->zblock.issued = 0;
return(-1);
}
else if ( bundlei < coin->chain->bundlesize-1 )
bundlei++;
else
{
origtxdata->zblock.issued = 0;
origtxdata->zblock.RO.recvlen = 0;
char str[65]; printf("ramchain data: error finding block %s\n",bits256_str(str,origtxdata->zblock.RO.hash2));
return(-1);
}
}
if ( (block= bp->blocks[bundlei]) == 0 || bits256_cmp(block->RO.hash2,origtxdata->zblock.RO.hash2) != 0 || bits256_cmp(bp->hashes[bundlei],origtxdata->zblock.RO.hash2) != 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 )
{
char str[65];
if ( 0 && block != 0 )
printf("%d:%d has no block ptr.%p %s or wrong hash\n",bp->hdrsi,bundlei,block,bits256_str(str,origtxdata->zblock.RO.hash2));
printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr);
return(-1);
}
block->txvalid = 1;
if ( block->fpipbits != 0 && block->fpos >= 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("ramchaindata have %d:%d at %d | %d blocks %s redundant xfers total %s %.2f%% wasted\n",bp->hdrsi,bundlei,block->fpos,numredundant,mbstr(str,redundantsize),mbstr(str2,totalrecv),100.*redundantsize/totalrecv);
}
return(block->fpos);
}
#ifdef __PNACL__
//verifyflag = 1;
#endif
sigsize = pubkeysize = 0;
scriptspace = 1;//iguana_scriptspaceraw(coin,&scriptsize,&sigsize,&pubkeysize,txarray,txn_count);
for (i=0; i<sizeof(addr->dirty)/sizeof(*addr->dirty); i++)
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 )
@ -1977,7 +1911,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru
iguana_blockzcopyRO(coin->chain->zcash,B,0,&block->RO,0);
rdata->scriptspace = ramchain->H.scriptoffset = scriptspace;
rdata->stackspace = ramchain->H.stacksize = stackspace;
if ( (fpos= (int32_t)iguana_ramchain_save(coin,RAMCHAIN_ARG,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,block->RO.hash2,block->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);
@ -1988,7 +1922,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,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,block->RO.hash2,block->RO.prev_block,bundlei,fpos,1,0)) == 0 )
{
printf("delete unverified [%d:%d]\n",bp->hdrsi,bundlei);
iguana_ramchain_free(coin,&R,1);
@ -2002,7 +1936,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru
//bp->rawscriptspace += rdata->scriptspace;
}
if ( fpos >= 0 )
block->fpos = fpos, block->fpipbits = addr_ipbits;
block->fpos = fpos, block->fpipbits = (uint32_t)addr->ipbits;
} else printf("save error\n");
}
else

376
iguana/iguana_recv.c

@ -91,6 +91,8 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,
} //else printf("no RTrawdata for %s\n",bits256_str(str,hash2));
}
}
if ( checkbp != bp || j != bundlei )
bp = 0, bundlei = -1;
if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 )
{
if ( block != 0 && block->hdrsi != 0 && block->bundlei != 0 )
@ -123,7 +125,11 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,
addr->pendblocks++;
addr->pendtime = (uint32_t)time(NULL);
if ( bp != 0 && bundlei >= 0 && bundlei < bp->n )
{
if ( bp->issued[bundlei] > 1 )
return(0);
bp->issued[bundlei] = addr->pendtime;
}
if ( block != 0 )
block->issued = addr->pendtime;
if ( 0 && coin->current == bp )
@ -298,7 +304,6 @@ void iguana_bundletime(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
starttime = block->issued;
if ( starttime == 0 || bp->issued[bundlei] > block->issued )
starttime = bp->issued[bundlei];
bp->issued[bundlei] = 1;
if ( starttime != 0 )
{
duration = (uint32_t)time(NULL) - starttime;
@ -312,13 +317,13 @@ void iguana_bundletime(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
bp->totaldurations += duration;
bp->durationscount++;
}
if ( (block= bp->blocks[bundlei]) != 0 && block->lag == 0 )
if ( (block != 0 || (block= bp->blocks[bundlei]) != 0) && block->lag == 0 )
block->lag = duration;
}
}
}
void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,int32_t fromcache)
void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,int32_t fromcache)
{
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag,numtx; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65];
if ( recvlen < 0 || recvlen > IGUANA_MAXPACKETSIZE )
@ -392,6 +397,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
bp = 0, bundlei = -2;
bp = iguana_bundlefind(coin,&bp,&bundlei,origtxdata->zblock.RO.hash2);
printf("[%d:%d].(%s) %s n%d\n",bp!=0?bp->hdrsi:-1,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks);
if ( bp != 0 && bundlei >= 0 && bundlei < bp->n )
{
block = bp->blocks[bundlei];
@ -492,25 +498,14 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
addr->recvblocks += 1.;
addr->recvtotal += recvlen;
}
if ( speculative == 0 && iguana_ramchain_data(coin,addr,origtxdata,txarray,origtxdata->zblock.RO.txn_count,data,recvlen) >= 0 )
if ( speculative == 0 && iguana_ramchain_data(coin,addr,origtxdata,txarray,origtxdata->zblock.RO.txn_count,data,recvlen,bp,block) >= 0 )
{
txdata->zblock.fpipbits = (uint32_t)addr->ipbits;
txdata->zblock.RO.recvlen = recvlen;
txdata->zblock.fpos = 0;
req->datalen = txdata->datalen;
req->ipbits = txdata->zblock.fpipbits;
/*if ( 0 )
{
struct iguana_txblock *checktxdata; struct OS_memspace checkmem; int32_t checkbundlei;
memset(&checkmem,0,sizeof(checkmem));
iguana_meminit(&checkmem,"checkmem",0,txdata->datalen + 4096,0);
if ( (checktxdata= iguana_peertxdata(coin,&checkbundlei,fname,&checkmem,(uint32_t)addr->ipbits,txdata->block.RO.hash2)) != 0 )
{
printf("check datalen.%d bundlei.%d T.%d U.%d S.%d P.%d X.%d\n",checktxdata->datalen,checkbundlei,checktxdata->numtxids,checktxdata->numunspents,checktxdata->numspends,checktxdata->numpkinds,checktxdata->numexternaltxids);
}
iguana_mempurge(&checkmem);
}*/
} //else printf("cant save block\n");
} //else printf("cant save block\n");
}
if ( txdata->zblock.fpos == 0 )
{
@ -542,6 +537,316 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
} else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2));
}
void iguana_recvstats_update(struct iguana_info *coin,struct iguana_peer *addr,int32_t recvlen)
{
static uint64_t received[IGUANA_MAXPEERS],count[IGUANA_MAXPEERS],lastcount,lastreceived,last;
char str[65],str2[65],str3[65],str4[65]; uint32_t now; int32_t i; int64_t sum2= 0,sum = 0,diffr,diff; double bw = 0.;
coin->recvcount++;
coin->recvtime = (uint32_t)time(NULL);
netBLOCKS++;
if ( addr->pendblocks > 0 )
addr->pendblocks--;
addr->lastblockrecv = (uint32_t)time(NULL);
addr->recvblocks += 1.;
addr->recvtotal += recvlen;
received[addr->addrind] += recvlen;
count[addr->addrind]++;
now = (uint32_t)time(NULL);
if ( ((rand() % 10000) == 0 && now > last+60) || now > last+600 )
{
for (i=0; i<sizeof(received)/sizeof(*received); i++)
sum += received[i], sum2 += count[i];
diffr = (sum - lastreceived), diff = (sum2 - lastcount);
lastreceived = sum, lastcount = sum2;
if ( diff != 0 )
{
bw = ((double)diffr / (now - last + 1));
if ( bw > coin->maxbandwidth )
coin->maxbandwidth = bw;
}
dxblend(&coin->bandwidth,bw,.9);
printf("%s BLOCKS.%llu RECV %s ave %.1f | dup.%d %s after.%d %s %s/sec %.2f%% %s\n",coin->symbol,(long long)sum2,mbstr(str,sum),(double)sum/(sum2!=0?sum2:1),numDuplicates,mbstr(str2,sizeDuplicates),numAfteremit,mbstr(str3,sizeAfteremit),mbstr(str4,bw),coin->maxbandwidth!=0.?100.*coin->bandwidth/coin->maxbandwidth:0.,coin->maxbandwidth>4*coin->bandwidth?"SLOW":"");
last = now;
}
if ( coin->bandwidth < 0.25*coin->maxbandwidth )
{
//printf(">>SLOW.%d<< ",addr->addrind);
//iguana_blast(coin,addr);
}
}
int32_t iguana_bundlestats_update(struct iguana_info *coin,struct iguana_block **blockp,struct iguana_bundle *bp,int32_t bundlei,struct iguana_txblock *origtxdata,uint8_t *data,int32_t recvlen)
{
char str[65]; struct iguana_block *block; int32_t i,j;
*blockp = 0;
if ( bp != 0 && bundlei >= 0 && bundlei < bp->n )
{
*blockp = block = bp->blocks[bundlei];
if ( bp->emitfinish != 0 )
{
numAfteremit++;
sizeAfteremit += recvlen;
if ( block != 0 )
iguana_bundletime(coin,bp,bundlei,block,1);
printf("got [%d:%d] with emitfinish.%u\n",bp->hdrsi,bundlei,bp->emitfinish);
return(-1);
}
bp->dirty++;
if ( bundlei >= 0 && block != 0 )
{
if ( block->fpipbits != 0 && block->txvalid != 0 )
{
numDuplicates++;
sizeDuplicates += recvlen;
//printf("duplicate [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
if ( bits256_cmp(origtxdata->zblock.RO.hash2,block->RO.hash2) != 0 )
{
//printf("mismatched tx %s received? mainchain.%d\n",bits256_str(str,block->RO.hash2),block->mainchain);
return(-1);
}
else
{
iguana_bundletime(coin,bp,bundlei,block,1);
iguana_blockzcopyRO(coin->chain->zcash,&block->RO,0,&origtxdata->zblock.RO,0);
return(0);
}
}
else
{
iguana_bundletime(coin,bp,bundlei,block,0);
if ( 0 && bp == coin->current )
printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
return(0);
}
}
}
else
{
if ( (bp= coin->current) != 0 )
{
for (i=0; i<coin->bundlescount; i++)
{
if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish == 0 && bp->speculative != 0 && bp->numhashes < bp->n )
{
if ( (j= iguana_speculativefind(coin,bp,(struct iguana_block *)&origtxdata->zblock,data,recvlen)) >= 0 )
{
printf("speculative found\n");
//copyflag = 0;
//speculative = 1;
if ( (*blockp= bp->blocks[j]) != 0 )
iguana_bundletime(coin,bp,j,*blockp,0);
return(1);
}
}
}
}
}
return(0);
}
struct iguana_bundlereq *iguana_recv_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t copyflag,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,struct iguana_bundle *bp,int32_t bundlei,struct iguana_txblock *txdata)
{
struct iguana_bundlereq *req; struct iguana_block *block = 0;
if ( copyflag != 0 && recvlen != 0 && (bp == 0 || bundlei < 0 || ((block= bp->blocks[bundlei]) != 0 && block->fpipbits == 0 && block->req == 0)) )
{
struct iguana_msghdr checkH;
req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen);
req->copyflag = 1;
req->H = *H;
if ( 0 && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 )
{
int z;
for (z=0; z<sizeof(checkH); z++)
printf("%02x",((uint8_t *)&checkH)[z]);
printf(" req->H datalen.%d crc.%08x error\n",recvlen,calc_crc32(0,data,recvlen));
}
}
else
{
copyflag = 0;
req = iguana_bundlereq(coin,addr,'B',0,0);
}
req->recvlen = recvlen;
req->datalen = txdata->datalen;
req->ipbits = txdata->zblock.fpipbits;
req->zblock = txdata->zblock;
req->zblock.RO.txn_count = req->numtx = txdata->zblock.RO.txn_count;
req->addr = addr;
return(req);
}
void iguana_RTgotblock(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp)
{
int32_t i; struct iguana_bundle *bp;
if ( coin->almostRT == 0 )
{
for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish <= 1 )
break;
if ( (i > coin->bundlescount-2 && coin->blocks.hwmchain.height > coin->longestchain-coin->chain->bundlesize*2) || coin->RTheight > 0 )
coin->almostRT = 1;
}
if ( coin->almostRT != 0 )
{
portable_mutex_lock(&coin->RTmutex);
iguana_RTrawdata(coin,hash2,data,recvlenp,numtxp,0);
portable_mutex_unlock(&coin->RTmutex);
}
}
int32_t iguana_txmerkle(struct iguana_info *coin,bits256 *tree,int32_t treesize,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray)
{
int32_t i,msize; bits256 merkle_root;
if ( bits256_nonz(origtxdata->zblock.RO.merkle_root) == 0 )
{
memset(&origtxdata->zblock.RO.prev_block,0,sizeof(bits256));
origtxdata->zblock.RO.recvlen = 0;
origtxdata->zblock.issued = 0;
return(-1);
}
msize = (int32_t)sizeof(bits256) * (origtxdata->zblock.RO.txn_count+1) * 2;
if ( msize <= treesize )
{
for (i=0; i<origtxdata->zblock.RO.txn_count; i++)
tree[i] = txarray[i].txid;
merkle_root = iguana_merkle(tree,origtxdata->zblock.RO.txn_count);
if ( bits256_cmp(merkle_root,origtxdata->zblock.RO.merkle_root) != 0 )
{
char str[65],str2[65];
printf(">>>>>>>>>> %s merkle mismatch.[%d] calc.(%s) vs (%s)\n",coin->symbol,origtxdata->zblock.RO.txn_count,bits256_str(str,merkle_root),bits256_str(str2,origtxdata->zblock.RO.merkle_root));
origtxdata->zblock.RO.recvlen = 0;
origtxdata->zblock.issued = 0;
return(-1);
} //else printf("matched merkle.%d\n",txn_count);
return(0);
} else printf("not enough memory for merkle verify %d vs %u\n",(int32_t)(sizeof(bits256)*(origtxdata->zblock.RO.txn_count+1)),treesize);
return(-1);
}
void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,int32_t fromcache)
{
static uint64_t totalrecv;
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t incr,i,numsaved,valid,speculative=0,bundlei,copyflag,numtx; struct iguana_bundle *bp; struct iguana_block *block; char str[65];
if ( addr == 0 )
addr = &coin->internaladdr;
if ( recvlen < 0 || recvlen > IGUANA_MAXPACKETSIZE )
{
printf("iguana_getblockM: illegal recvlen.%d\n",recvlen);
return;
}
if ( fromcache == 0 && coin->virtualchain == 0 && addr != 0 && addr != &coin->internaladdr )
{
iguana_recvstats_update(coin,addr,recvlen);
totalrecv += recvlen;
}
origtxdata->zblock.RO.allocsize = sizeof(origtxdata->zblock);
if ( iguana_blockvalidate(myinfo,coin,&valid,(struct iguana_block *)&origtxdata->zblock,1) < 0 )
{
printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->zblock.RO.hash2));
return;
}
iguana_peer_meminit(coin,addr);
if ( iguana_txmerkle(coin,addr->TXDATA.ptr,(int32_t)addr->TXDATA.totalsize,origtxdata,txarray) < 0 )
return;
origtxdata->zblock.txvalid = 1;
bp = 0, bundlei = -2;
if ( iguana_bundlefind(coin,&bp,&bundlei,origtxdata->zblock.RO.hash2) == 0 )
{
bp = 0, bundlei = -2;
if ( iguana_bundlefind(coin,&bp,&bundlei,origtxdata->zblock.RO.prev_block) == 0 )
{
origtxdata->zblock.RO.recvlen = 0;
origtxdata->zblock.issued = 0;
//printf("gotblockM: RTblock? %s\n",bits256_str(str,origtxdata->zblock.RO.hash2));
return;
}
else if ( bundlei < coin->chain->bundlesize-1 )
bundlei++;
else // new bundle case, but bad context to extend
{
origtxdata->zblock.issued = 0;
origtxdata->zblock.RO.recvlen = 0;
printf("gotblockM2: error finding block %s\n",bits256_str(str,origtxdata->zblock.RO.hash2));
return;
}
}
if ( bp == 0 )
return;
for (i=numsaved=0; i<coin->chain->bundlesize; i++)
{
if ( (block= bp->blocks[i]) != 0 && block->fpipbits != 0 && block->fpos >= 0 && block->txvalid != 0 )
numsaved++;
}
if ( (speculative= iguana_bundlestats_update(coin,&block,bp,bundlei,origtxdata,data,recvlen)) < 0 )
return;
if ( block == 0 )
{
printf("no block to update\n");
return;
}
block->txvalid = 1;
if ( block->fpipbits != 0 && block->fpos >= 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("ramchaindata have %d:%d at %d | %d blocks %s redundant xfers total %s %.2f%% wasted\n",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);
}
return;
}
txdata = origtxdata;
if ( iguana_ramchain_data(coin,addr,origtxdata,txarray,origtxdata->zblock.RO.txn_count,data,recvlen,bp,block) >= 0 )
{
txdata->zblock.fpipbits = (uint32_t)addr->ipbits;
txdata->zblock.RO.recvlen = recvlen;
txdata->zblock.fpos = 0;
numtx = origtxdata->zblock.RO.txn_count;
iguana_RTgotblock(coin,txdata->zblock.RO.hash2,data,&recvlen,&numtx);
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 )
//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 ( coin->current == 0 || coin->current->startutxo != 0 || numsaved > (rand() % coin->chain->bundlesize) || (bp= coin->current) != 0 )
{
for (i=numsaved=0; i<coin->chain->bundlesize; i++)
{
if ( (block= bp->blocks[i]) != 0 && block->fpipbits != 0 && block->fpos >= 0 && block->txvalid != 0 )
numsaved++;
}
if ( numsaved < coin->chain->bundlesize && bp->startutxo == 0 )
{
if ( (incr= coin->peers->numranked) == 0 )
incr = 1;
i = addr->addrind % incr;
for (; i<coin->chain->bundlesize; i+=incr)
{
if ( (bp->issued[i] == 0 && bits256_nonz(bp->hashes[i]) != 0) && ((block= bp->blocks[i]) == 0 || bits256_cmp(bp->hashes[i],block->RO.hash2) != 0 || block->fpipbits == 0 || block->fpos < 0 || block->txvalid == 0) )
{
bp->issued[i] = 1;
iguana_sendblockreqPT(coin,addr,0,-1,bp->hashes[i],0);
//printf("numsaved.%d auto issue.[%d:%d] %s\n",numsaved,bp->hdrsi,i,addr->ipaddr);
break;
} //else printf("numsaved.%d SKIP auto issue.[%d:%d] %s\n",numsaved,bp->hdrsi,i,addr->ipaddr);
}
}
else if ( bp->queued == 0 )
{
iguana_bundleQ(myinfo,coin,bp,0);
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));
}
void iguana_gottxidsM(struct iguana_info *coin,struct iguana_peer *addr,bits256 *txids,int32_t n)
{
struct iguana_bundlereq *req;
@ -662,8 +967,8 @@ uint32_t iguana_allhashcmp(struct supernet_info *myinfo,struct iguana_info *coin
n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.);
if ( 0 && n > 0 )
printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n);
if ( bp->queued == 0 )
iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500));
//if ( bp->queued == 0 )
// iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500));
return(bp->queued);
}
}
@ -879,7 +1184,7 @@ struct iguana_bundle *iguana_bundleset(struct supernet_info *myinfo,struct iguan
{
if ( iguana_bundlehashadd(coin,bp,bundlei,block) < 0 )
{
if ( bp->emitfinish == 0 && block->issued == 0 && strcmp("BTC",coin->symbol) != 0 )//|| coin->PREFETCHLAG < 0) )
if ( bp->emitfinish == 0 && bp->issued[bundlei] == 0 && block->issued == 0 && strcmp("BTC",coin->symbol) != 0 )//|| coin->PREFETCHLAG < 0) )
iguana_blockQ("bundleset",coin,bp,bundlei,block->RO.hash2,1);//coin->current == 0 || bp->hdrsi <= coin->current->hdrsi+coin->MAXBUNDLES);
}
//fprintf(stderr,"bundle found %d:%d\n",bp->hdrsi,bundlei);
@ -1085,7 +1390,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
if ( bp != 0 && bp->speculative != 0 && i < bp->n )
bp->speculative[i] = blockhashes[i];
}
iguana_blockQ("recvhash",coin,0,-1,blockhashes[i],1);
//iguana_blockQ("recvhash",coin,0,-1,blockhashes[i],1);
}
}
if ( bp != 0 )
@ -1099,7 +1404,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
if ( bits256_nonz(bp->nextbundlehash2) == 0 && num > coin->chain->bundlesize )
{
bp->nextbundlehash2 = blockhashes[coin->chain->bundlesize];
iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1);
//iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1);
}
//printf("call allhashes\n");
if ( 0 && bp->hdrsi == coin->bundlescount-1 )
@ -1126,10 +1431,10 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
if ( bp->speculative == 0 )
{
bp->speculative = mycalloc('s',bp->n+1,sizeof(*bp->speculative));
for (i=0; i<bp->n; i++)
if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0;
iguana_bundleissuemissing(myinfo,coin,bp,3,1.);
//for (i=0; i<bp->n; i++)
// if ( GETBIT(bp->haveblock,i) == 0 )
// bp->issued[i] = 0;
//iguana_bundleissuemissing(myinfo,coin,bp,3,1.);
}
for (i=1; i<num&&i<=bp->n; i++)
{
@ -1200,17 +1505,17 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
{
if ( (block= iguana_blockfind("recvhashes2",coin,blockhashes[1])) == 0 )
{
iguana_blockhashset("recvhashes3",coin,-1,blockhashes[1],1);
//iguana_blockhashset("recvhashes3",coin,-1,blockhashes[1],1);
if ( (block= iguana_blockfind("recvhashes4",coin,blockhashes[1])) != 0 )
iguana_blockQ("recvhash6",coin,0,-6,blockhashes[1],1); // should be RT block
}
if ( block != 0 )
block->newtx = 1;
iguana_blockQ("RTblock",coin,0,-7,blockhashes[1],1); // should be RT block
//iguana_blockQ("RTblock",coin,0,-7,blockhashes[1],1); // should be RT block
}
if ( strcmp("BTC",coin->symbol) != 0 )
{
iguana_blockQ("recvhash7",coin,0,-7,blockhashes[1],1);
//iguana_blockQ("recvhash7",coin,0,-7,blockhashes[1],1);
iguana_blockQ("recvhash7",coin,0,-7,blockhashes[num-1],1);
//if ( 1 && coin->RTheight > 0 )
{
@ -1219,7 +1524,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
if ( iguana_bundlehash2_check(coin,blockhashes[i]) == 0 )
{
//fprintf(stderr,"%d ",i);
iguana_blockQ("recvhashRT",coin,0,-8,blockhashes[i],1);
//iguana_blockQ("recvhashRT",coin,0,-8,blockhashes[i],1);
//iguana_sendblockreqPT(coin,0,0,-1,blockhashes[i],0);
}
}
@ -1692,8 +1997,13 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
return(0);
height = block->height;
}
if ( bp != 0 && bp->emitfinish != 0 )
return(0);
if ( bp != 0 )
{
if ( bp->emitfinish != 0 )
return(0);
if ( bp->issued[bundlei] > 0 )
return(0);
}
if ( priority != 0 )
str = "priorityQ", Q = &coin->priorityQ;
else str = "blocksQ", Q = &coin->blocksQ;
@ -1868,10 +2178,10 @@ int32_t iguana_processrecv(struct supernet_info *myinfo,struct iguana_info *coin
}
}
flag += iguana_processrecvQ(myinfo,coin,&newhwm);
if ( coin->RTheight == 0 || (rand() % 30) == 0 )
if ( coin->RTheight == 0 || (rand() % 7) == 0 )
flag += iguana_reqblocks(myinfo,coin);
iguana_jsonQ(myinfo,coin);
if ( time(NULL) > coin->laststats+30 )
if ( time(NULL) > coin->laststats+3 )
{
flag += iguana_reqhdrs(coin);
iguana_bundlestats(myinfo,coin,str,IGUANA_DEFAULTLAG);

4
includes/iguana_defines.h

@ -44,8 +44,8 @@
#define IGUANA_HEADPERCENTAGE 0.
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define IGUANA_MAXPENDINGREQUESTS 16
#define IGUANA_PENDINGREQUESTS 512
#define IGUANA_BTCPENDINGREQUESTS 3
#define IGUANA_PENDINGREQUESTS 3
#define IGUANA_MINPENDBUNDLES 4
#define IGUANA_MAXPENDBUNDLES 64
#define IGUANA_RPCPORT 7778

3
includes/iguana_funcs.h

@ -193,7 +193,7 @@ struct iguana_txblock *iguana_peertxdata(struct iguana_info *coin,int32_t *bundl
int32_t iguana_peerfile_exists(struct iguana_info *coin,struct iguana_peer *addr,char *dirname,char *fname,bits256 hash2,bits256 prevhash2,int32_t numblocks);
struct iguana_ramchain *iguana_ramchainset(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_txblock *txdata);
void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA);
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);
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 iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blockp,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2);
struct iguana_block *iguana_bundleblockadd(struct iguana_info *coin,struct iguana_bundle **bpp,int32_t *bundleip,struct iguana_block *origblock);
int32_t iguana_chainextend(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_block *newblock);
@ -237,6 +237,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
struct iguana_peer *iguana_peerslot(struct iguana_info *coin,uint64_t ipbits,int32_t forceflag);
void iguana_dedicatedglue(void *arg);
void SuperNET_remotepeer(struct supernet_info *myinfo,struct iguana_info *coin,char *symbol,char *ipaddr,int32_t supernetflag);
void iguana_peer_meminit(struct iguana_info *coin,struct iguana_peer *addr);
void SuperNET_yourip(struct supernet_info *myinfo,char *yourip);
void iguana_peerkill(struct iguana_info *coin);
int32_t blockhash_sha256(uint8_t *blockhashp,uint8_t *serialized,int32_t len);

2
includes/iguana_structs.h

@ -459,7 +459,7 @@ struct iguana_info
int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified,blockdepth;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp,RTgenesis,firstRTgenesis,RTstarti,idletime,stucktime,stuckmonitor,maxstuck,lastreqtime,RThdrstime,nextchecked,lastcheckpoint,sigserrs,sigsvalidated;
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; bits256 reqtxids[64];
int32_t disableUTXO,initialheight,mapflags,minconfirms,numrecv,bindsock,isRT,backstop,blocksrecv,merging,firstRTheight,polltimeout,numreqtxids,allhashes,balanceflush,basilisk_busy,almostRT; bits256 reqtxids[64];
void *launched,*started,*rpcloop;
uint64_t bloomsearches,bloomhits,bloomfalse,collisions,txfee_perkb,txfee;
uint8_t *blockspace; int32_t blockspacesize; struct OS_memspace blockMEM,RTHASHMEM;

Loading…
Cancel
Save