From c888b1aef7da09747fac6e54f563cc565a6a6ef1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Jun 2016 07:25:10 -0300 Subject: [PATCH] test --- gecko/gecko.c | 8 +++----- gecko/gecko_blocks.c | 30 +++++++++++++++++++----------- gecko/gecko_headers.c | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/gecko/gecko.c b/gecko/gecko.c index 3def793a5..fd6ca1aac 100755 --- a/gecko/gecko.c +++ b/gecko/gecko.c @@ -44,19 +44,17 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi; hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize; longesthdrsi = virt->longestchain / virt->chain->bundlesize; - if ( hwmhdrsi <= longesthdrsi && virt->blocks.hwmchain.height < virt->longestchain-1 ) + if ( hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 ) { if ( time(NULL) > virt->hdrstime+3 ) { - if ( strcmp("BTCD",virt->symbol) == 0 ) - ; - //fprintf(stderr,"r"); + fprintf(stderr,"request headers\n"); gecko_requesthdrs(myinfo,virt,hwmhdrsi); //fprintf(stderr,"R"); virt->hdrstime = (uint32_t)time(NULL); } } - if ( btcd->RELAYNODE != 0 && virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize ) + if ( btcd->RELAYNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize ) { bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33); //fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr); diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index 7ef1abdbe..1a8bd795d 100755 --- a/gecko/gecko_blocks.c +++ b/gecko/gecko_blocks.c @@ -48,6 +48,23 @@ void gecko_txidpurge(struct iguana_info *virt,bits256 txid) } } +struct iguana_bundle *gecko_bundleset(struct iguana_info *virt,struct iguana_block *block) +{ + int32_t hdrsi,bundlei; struct iguana_bundle *bp; + hdrsi = (block->height / virt->chain->bundlesize); + bundlei = (block->height % virt->chain->bundlesize); + if ( (bp= virt->bundles[hdrsi]) == 0 ) + printf("error ensuring bundle ht.%d\n",block->height); + else + { + bp->blocks[bundlei] = block; + bp->hashes[bundlei] = block->RO.hash2; + //char str[65]; printf("[%d:%d] <- %s %p\n",hdrsi,bundlei,bits256_str(str,block->RO.hash2),block); + iguana_hash2set(virt,"ensure",bp,bundlei,block->RO.hash2); + } + return(bp); +} + struct iguana_bundle *gecko_ensurebundle(struct iguana_info *virt,struct iguana_block *block,int32_t origheight,int32_t depth) { int32_t hdrsi,bundlei,checkbundlei,height = origheight; bits256 zero; struct iguana_bundle *bp = 0; @@ -99,17 +116,7 @@ struct iguana_bundle *gecko_ensurebundle(struct iguana_info *virt,struct iguana_ printf("cant find ht.%d %s\n",block->height,bits256_str(str,block->RO.hash2)); } }*/ - hdrsi = (block->height / virt->chain->bundlesize); - if ( (bp= virt->bundles[hdrsi]) == 0 ) - printf("error ensuring bundle ht.%d\n",origheight); - else - { - bp->blocks[bundlei] = block; - bp->hashes[bundlei] = block->RO.hash2; - //char str[65]; printf("[%d:%d] <- %s %p\n",hdrsi,bundlei,bits256_str(str,block->RO.hash2),block); - iguana_hash2set(virt,"ensure",bp,bundlei,block->RO.hash2); - } - return(bp); + return(gecko_bundleset(virt,block)); } 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) @@ -226,6 +233,7 @@ char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,c prev->mainchain = 1; if ( prev->height != (adjacent + 1 - j) ) prev->height = (adjacent + 1 - j); + gecko_bundleset(virt,prev); if ( prev->height == 0 ) break; } diff --git a/gecko/gecko_headers.c b/gecko/gecko_headers.c index 821d67e95..567780bde 100755 --- a/gecko/gecko_headers.c +++ b/gecko/gecko_headers.c @@ -96,7 +96,7 @@ void gecko_requesthdrs(struct supernet_info *myinfo,struct iguana_info *virt,int memset(zero.bytes,0,sizeof(zero)); jaddstr(vals,"symbol",virt->symbol); jaddstr(vals,"type","HDR"); - if ( (retstr= basilisk_standardservice("GET",myinfo,bp->hashes[0],vals,0,0)) != 0 ) + if ( (retstr= basilisk_standardservice("GET",myinfo,bp->hashes[0],vals,0,1)) != 0 ) free(retstr); free_json(vals); } else printf("dont have bundle needed\n");