Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c888b1aef7
  1. 8
      gecko/gecko.c
  2. 30
      gecko/gecko_blocks.c
  3. 2
      gecko/gecko_headers.c

8
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; char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi;
hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize; hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize;
longesthdrsi = virt->longestchain / 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 ( time(NULL) > virt->hdrstime+3 )
{ {
if ( strcmp("BTCD",virt->symbol) == 0 ) fprintf(stderr,"request headers\n");
;
//fprintf(stderr,"r");
gecko_requesthdrs(myinfo,virt,hwmhdrsi); gecko_requesthdrs(myinfo,virt,hwmhdrsi);
//fprintf(stderr,"R"); //fprintf(stderr,"R");
virt->hdrstime = (uint32_t)time(NULL); 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); bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr); //fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);

30
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) 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; 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)); printf("cant find ht.%d %s\n",block->height,bits256_str(str,block->RO.hash2));
} }
}*/ }*/
hdrsi = (block->height / virt->chain->bundlesize); return(gecko_bundleset(virt,block));
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);
} }
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) 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; prev->mainchain = 1;
if ( prev->height != (adjacent + 1 - j) ) if ( prev->height != (adjacent + 1 - j) )
prev->height = (adjacent + 1 - j); prev->height = (adjacent + 1 - j);
gecko_bundleset(virt,prev);
if ( prev->height == 0 ) if ( prev->height == 0 )
break; break;
} }

2
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)); memset(zero.bytes,0,sizeof(zero));
jaddstr(vals,"symbol",virt->symbol); jaddstr(vals,"symbol",virt->symbol);
jaddstr(vals,"type","HDR"); 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(retstr);
free_json(vals); free_json(vals);
} else printf("dont have bundle needed\n"); } else printf("dont have bundle needed\n");

Loading…
Cancel
Save