Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
9c8776ef90
  1. 6
      basilisk/basilisk.c
  2. 8
      gecko/gecko.c
  3. 18
      gecko/gecko_headers.c

6
basilisk/basilisk.c

@ -916,12 +916,14 @@ void basilisks_loop(void *arg)
valsobj = cJSON_CreateObject(); valsobj = cJSON_CreateObject();
if ( btcd->RELAYNODE == 0 && btcd->VALIDATENODE == 0 ) if ( btcd->RELAYNODE == 0 && btcd->VALIDATENODE == 0 )
{ {
fprintf(stderr,"e");
jaddnum(valsobj,"BTCD",btcd->SEQ.BTCD.numstamps+GECKO_FIRSTPOSSIBLEBTCD); jaddnum(valsobj,"BTCD",btcd->SEQ.BTCD.numstamps+GECKO_FIRSTPOSSIBLEBTCD);
basilisk_standardservice("SEQ",myinfo,GENESIS_PUBKEY,valsobj,0,0); basilisk_standardservice("SEQ",myinfo,GENESIS_PUBKEY,valsobj,0,0);
flag++; flag++;
} }
if ( (done & 2) == 0 ) if ( (done & 2) == 0 )
{ {
fprintf(stderr,"f");
free_json(valsobj); free_json(valsobj);
valsobj = cJSON_CreateObject(); valsobj = cJSON_CreateObject();
jaddnum(valsobj,"BTC",btcd->SEQ.BTC.numstamps+GECKO_FIRSTPOSSIBLEBTC); jaddnum(valsobj,"BTC",btcd->SEQ.BTC.numstamps+GECKO_FIRSTPOSSIBLEBTC);
@ -930,6 +932,7 @@ void basilisks_loop(void *arg)
} }
free_json(valsobj); free_json(valsobj);
} }
fprintf(stderr,"G");
if ( flag == 0 && myinfo->allcoins_numvirts > 0 ) if ( flag == 0 && myinfo->allcoins_numvirts > 0 )
{ {
maxmillis = (1000 / myinfo->allcoins_numvirts) + 1; maxmillis = (1000 / myinfo->allcoins_numvirts) + 1;
@ -938,6 +941,7 @@ void basilisks_loop(void *arg)
{ {
if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 ) if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 )
{ {
fprintf(stderr,"h");
gecko_iteration(myinfo,btcd,virt,maxmillis); gecko_iteration(myinfo,btcd,virt,maxmillis);
flag++; flag++;
} }
@ -945,7 +949,7 @@ void basilisks_loop(void *arg)
//portable_mutex_unlock(&Allcoins_mutex); //portable_mutex_unlock(&Allcoins_mutex);
} }
} }
fprintf(stderr,"E "); fprintf(stderr,"i ");
//for (i=0; i<IGUANA_MAXCOINS; i++) //for (i=0; i<IGUANA_MAXCOINS; i++)
// if ( (coin= Coins[i]) != 0 && coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 ) // if ( (coin= Coins[i]) != 0 && coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 )
// basilisk_bitcoinscan(coin,blockspace,&RAWMEM); // basilisk_bitcoinscan(coin,blockspace,&RAWMEM);

8
gecko/gecko.c

@ -44,18 +44,22 @@ 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 ) 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,"r");
gecko_requesthdrs(myinfo,virt,hwmhdrsi); gecko_requesthdrs(myinfo,virt,hwmhdrsi);
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-1 ) if ( btcd->RELAYNODE != 0 && virt->blocks.hwmchain.height >= virt->longestchain-1 )
{ {
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33); bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//printf("mine.%s %s\n",virt->symbol,mineraddr); fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);
gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33); gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33);
} }
} }

18
gecko/gecko_headers.c

@ -40,10 +40,10 @@ int32_t basilisk_respond_geckogetheaders(struct supernet_info *myinfo,struct igu
return(-1); return(-1);
} }
void gecko_headerupdate(struct iguana_info *virt,bits256 hash2,int32_t height) void gecko_blockhashupdate(struct iguana_info *virt,bits256 hash2,int32_t height)
{ {
int32_t bundlei; struct iguana_bundle *bp; bits256 zero; int32_t bundlei; struct iguana_bundle *bp; bits256 zero;
char str[65]; printf("height.%d %s\n",height,bits256_str(str,hash2)); char str[65]; printf("gecko_blockhashupdate height.%d %s\n",height,bits256_str(str,hash2));
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
if ( (height % virt->chain->bundlesize) == 0 ) if ( (height % virt->chain->bundlesize) == 0 )
bp = iguana_bundlecreate(virt,&bundlei,height,hash2,zero,0); bp = iguana_bundlecreate(virt,&bundlei,height,hash2,zero,0);
@ -53,17 +53,23 @@ void gecko_headerupdate(struct iguana_info *virt,bits256 hash2,int32_t height)
char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2) char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2)
{ {
bits256 hash2; struct iguana_block *block; int32_t firstheight,i,len=0,n,num; struct iguana_msgblock msgB; bits256 hash2,prevhash2; struct iguana_block *block; int32_t height,firstheight,i,len=0,n,num; struct iguana_msgblock msgB;
num = (int32_t)(datalen / 84); num = (int32_t)(datalen / 84);
char str[65]; printf("headers arrived.%d from %s\n",n,bits256_str(str,firsthash2)); char str[65]; printf("headers arrived.%d from %s\n",num,bits256_str(str,firsthash2));
if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 ) if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 )
{ {
gecko_headerupdate(virt,firsthash2,firstheight); gecko_blockhashupdate(virt,firsthash2,firstheight);
prevhash2 = firsthash2;
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
if ( (n= iguana_rwblock(virt->symbol,virt->chain->zcash,virt->chain->auxpow,virt->chain->hashalgo,0,&hash2,&data[len],&msgB,datalen-len)) > 0 ) if ( (n= iguana_rwblock(virt->symbol,virt->chain->zcash,virt->chain->auxpow,virt->chain->hashalgo,0,&hash2,&data[len],&msgB,datalen-len)) > 0 )
{ {
gecko_headerupdate(virt,hash2,firstheight + i + 1); if ( bits256_cmp(msgB.H.prev_block,prevhash2) == 0 )
{
height = (firstheight + i + 1);
gecko_blockhashupdate(virt,hash2,height);
printf("ht.%d %s %08x t.%u\n",height,bits256_str(str,hash2),msgB.H.bits,msgB.H.timestamp);
} else printf("ht.%d non prevhash i.%d\n",height,i);
len += n; len += n;
} }
} }

Loading…
Cancel
Save