Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
15632ab490
  1. 12
      basilisk/basilisk.c
  2. 2
      gecko/gecko_blocks.c
  3. 12
      gecko/gecko_miner.c

12
basilisk/basilisk.c

@ -635,8 +635,16 @@ void basilisk_respond_ping(struct supernet_info *myinfo,struct iguana_peer *addr
printf("(%s %d).%p ",symbol,height,addr);
if ( myinfo->numrelays > 0 && addr != 0 && (virt= iguana_coinfind(symbol)) != 0 )
{
if ( virt->blocks.hwmchain.height > height && (height % myinfo->numrelays) == myinfo->RELAYID )
basilisk_blocksend(myinfo,btcd,virt,addr,height+1);
if ( height > virt->longestchain )
virt->longestchain = height;
if ( myinfo->numrelays > 0 && virt->blocks.hwmchain.height > height )
{
diff = ((height % myinfo->numrelays) - myinfo->RELAYID);
diff *= diff;
diff++;
if ( (rand() % diff) == 0 )
basilisk_blocksend(myinfo,btcd,virt,addr,height+1);
}
}
}
for (i=0; i<datalen; i++)

2
gecko/gecko_blocks.c

@ -288,7 +288,7 @@ char *gecko_blockarrived(struct supernet_info *myinfo,struct iguana_info *virt,c
char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash2,int32_t from_basilisk)
{
char *symbol; struct iguana_info *virt; bits256 checkhash2; int32_t hdrsize; uint32_t prevtimestamp,nBits; struct iguana_msgblock msg; struct iguana_block *block;
char *symbol; struct iguana_info *virt; bits256 checkhash2; int32_t hdrsize; struct iguana_msgblock msg; struct iguana_block *block;
printf("got geckoblock len.%d from (%s) %s\n",datalen,remoteaddr!=0?remoteaddr:"",jprint(valsobj,0));
if ( (symbol= jstr(valsobj,"symbol")) != 0 && (virt= iguana_coinfind(symbol)) != 0 )
{

12
gecko/gecko_miner.c

@ -49,7 +49,7 @@ int32_t gecko_blocknonce_verify(struct iguana_info *virt,uint8_t *serialized,int
hash2 = iguana_calcblockhash(virt->symbol,virt->chain->hashalgo,serialized,datalen);
if ( bits256_cmp(threshold,hash2) > 0 )
{
printf("nonce worked crc.%x\n",calc_crc32(0,serialized,datalen));
//printf("nonce worked crc.%x\n",calc_crc32(0,serialized,datalen));
return(1);
}
else
@ -232,13 +232,13 @@ char *gecko_blockconstruct(struct supernet_info *myinfo,struct iguana_info *virt
hash2 = iguana_calcblockhash(virt->symbol,virt->chain->hashalgo,serialized,len);
if ( bits256_cmp(threshold,hash2) > 0 )
{
printf("FOUND NONCE %d iterations\n",i+1);
//printf("FOUND NONCE %d iterations\n",i+1);
newblock->RO.hash2 = hash2;
break;
}
if ( newblock->height != 0 && OS_milliseconds() > expiration )
{
printf("time limit exceeded %u %d iterations\n",virt->blocks.hwmchain.RO.timestamp,i+1);
//printf("time limit exceeded %u %d iterations\n",virt->blocks.hwmchain.RO.timestamp,i+1);
free(coinbasestr);
if ( txids != txspace )
free(txids);
@ -365,11 +365,13 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig
//printf("skip non-virtual chain.%s\n",virt->symbol);
return;
}
if ( virt->blocks.hwmchain.height < virt->longestchain-1 )
return;
if ( (virt->blocks.hwmchain.height % myinfo->numrelays) != myinfo->RELAYID )
{
//if ( myinfo->numrelays < 3 )
return;
gap = (int32_t)(time(NULL) - virt->blocks.hwmchain.RO.timestamp) / 10;//virt->chain->estblocktime;
// return;
gap = (int32_t)(time(NULL) - virt->blocks.hwmchain.RO.timestamp) / 60;//virt->chain->estblocktime;
for (i=0; i<gap; i++)
{
if ( ((virt->blocks.hwmchain.height+i) % myinfo->numrelays) == myinfo->RELAYID )

Loading…
Cancel
Save