Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
e1e1ca9131
  1. 3
      gecko/gecko_blocks.c
  2. 7
      gecko/gecko_miner.c

3
gecko/gecko_blocks.c

@ -162,12 +162,10 @@ int32_t gecko_hwmset(struct supernet_info *myinfo,struct iguana_info *virt,struc
char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2,int32_t verifyonly) char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 hash2,int32_t verifyonly)
{ {
struct iguana_txblock txdata; int32_t height,valid,adjacent,gap,n,i,j,len = -1; struct iguana_block *block,*prev; struct iguana_txid tx; char str[65]; bits256 txid; struct iguana_msgtx *txs; struct iguana_txblock txdata; int32_t height,valid,adjacent,gap,n,i,j,len = -1; struct iguana_block *block,*prev; struct iguana_txid tx; char str[65]; bits256 txid; struct iguana_msgtx *txs;
printf("gecko_blockarrived\n");
memset(&txdata,0,sizeof(txdata)); memset(&txdata,0,sizeof(txdata));
iguana_memreset(&virt->TXMEM); iguana_memreset(&virt->TXMEM);
if ( (n= iguana_gentxarray(virt,&virt->TXMEM,&txdata,&len,data,datalen)) == datalen ) if ( (n= iguana_gentxarray(virt,&virt->TXMEM,&txdata,&len,data,datalen)) == datalen )
{ {
printf("gentxarray datalen.%d\n",datalen);
if ( bits256_cmp(hash2,txdata.zblock.RO.hash2) != 0 ) if ( bits256_cmp(hash2,txdata.zblock.RO.hash2) != 0 )
{ {
printf("gecko_blockarrived: mismatched hash2\n"); printf("gecko_blockarrived: mismatched hash2\n");
@ -297,7 +295,6 @@ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *bt
int32_t i,datalen,num,numerrs,numresults=0; uint8_t *data,space[16384],*allocptr; cJSON *valsobj=0,*retjson,*retarray,*item; char *str,*str2,*othercoin; bits256 othertip; int32_t i,datalen,num,numerrs,numresults=0; uint8_t *data,space[16384],*allocptr; cJSON *valsobj=0,*retjson,*retarray,*item; char *str,*str2,*othercoin; bits256 othertip;
if ( (data= get_dataptr(sizeof(struct iguana_msghdr) + BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),blockstr)) != 0 ) if ( (data= get_dataptr(sizeof(struct iguana_msghdr) + BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),blockstr)) != 0 )
{ {
printf("call gecko_blockarrived\n");
if ( (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2,0)) != 0 ) if ( (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2,0)) != 0 )
{ {
if ( (retjson= cJSON_Parse(str)) != 0 ) if ( (retjson= cJSON_Parse(str)) != 0 )

7
gecko/gecko_miner.c

@ -306,7 +306,7 @@ cJSON *gecko_paymentsobj(struct supernet_info *myinfo,cJSON *txjson,cJSON *valso
int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2,int32_t height) int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2,int32_t height)
{ {
uint8_t *data,space[16384],*allocptr=0; int32_t i,len,numranked=0; struct iguana_peers *peers; struct iguana_peer *addr; uint8_t *data,space[16384],*allocptr=0; int32_t i,len,numranked=0; struct iguana_peers *peers; struct iguana_peer *addr;
printf("submit.(%s)\n",blockstr); //printf("submit.(%s)\n",blockstr);
if ( (peers= virt->peers) == 0 || (numranked= peers->numranked) <= 0 ) if ( (peers= virt->peers) == 0 || (numranked= peers->numranked) <= 0 )
{ {
if ( basilisk_blocksubmit(myinfo,btcd,virt,blockstr,hash2,height) < 0 )//(myinfo->numrelays >> 1) ) if ( basilisk_blocksubmit(myinfo,btcd,virt,blockstr,hash2,height) < 0 )//(myinfo->numrelays >> 1) )
@ -342,14 +342,15 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig
{ {
//if ( myinfo->numrelays < 3 ) //if ( myinfo->numrelays < 3 )
// return; // return;
gap = (int32_t)(time(NULL) - virt->backstoptime) / virt->chain->estblocktime; gap = (int32_t)(time(NULL) - virt->blocks.hwmchain.RO.timstamp) / 10;//virt->chain->estblocktime;
for (i=1; i<gap; i++) for (i=0; i<gap; i++)
{ {
if ( ((virt->blocks.hwmchain.height+i) % myinfo->numrelays) == myinfo->RELAYID ) if ( ((virt->blocks.hwmchain.height+i) % myinfo->numrelays) == myinfo->RELAYID )
break; break;
} }
if ( i == gap ) if ( i == gap )
return; return;
printf("backup block generator RELAYID.%d gap.%d ht.%d i.%d num.%d\n",myinfo->RELAYID,gap,virt->blocks.hwmchain.height,i,myinfo->numrelays);
} }
#endif #endif
/*if ( virt->newblockstr != 0 ) /*if ( virt->newblockstr != 0 )

Loading…
Cancel
Save