Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
ececd150a1
  1. 36
      basilisk/basilisk.c
  2. 8
      gecko/gecko.c
  3. 2
      gecko/gecko_blocks.c
  4. 2
      gecko/gecko_miner.c

36
basilisk/basilisk.c

@ -81,8 +81,8 @@ uint8_t *get_dataptr(int32_t hdroffset,uint8_t **ptrp,int32_t *datalenp,uint8_t
uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag) uint8_t *basilisk_jsondata(int32_t extraoffset,uint8_t **ptrp,uint8_t *space,int32_t spacesize,int32_t *datalenp,char *symbol,cJSON *sendjson,uint32_t basilisktag)
{ {
char *sendstr,*hexstr=0; uint8_t *data,hexspace[8192],*allocptr=0,*hexdata; int32_t datalen,hexlen=0; char *sendstr,*hexstr=0; uint8_t *data,hexspace[8192],*allocptr=0,*hexdata; int32_t datalen,hexlen=0;
if ( jobj(sendjson,"coin") == 0 ) if ( jobj(sendjson,"symbol") == 0 )
jaddstr(sendjson,"coin",symbol); jaddstr(sendjson,"symbol",symbol);
if ( (hexstr= jstr(sendjson,"data")) != 0 ) if ( (hexstr= jstr(sendjson,"data")) != 0 )
{ {
hexdata = get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr); hexdata = get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr);
@ -377,7 +377,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char
{ {
if ( (virt= iguana_coinfind(symbol)) != 0 ) if ( (virt= iguana_coinfind(symbol)) != 0 )
{ {
jaddstr(valsobj,"coin",symbol); jaddstr(valsobj,"symbol",symbol);
jaddnum(valsobj,"longest",virt->longestchain); jaddnum(valsobj,"longest",virt->longestchain);
jaddnum(valsobj,"hwm",virt->blocks.hwmchain.height); jaddnum(valsobj,"hwm",virt->blocks.hwmchain.height);
} }
@ -626,7 +626,7 @@ int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *vi
if ( (hexstr= basilisk_addhexstr(&str,0,space,sizeof(space),serialized,len)) != 0 ) if ( (hexstr= basilisk_addhexstr(&str,0,space,sizeof(space),serialized,len)) != 0 )
{ {
vals = cJSON_CreateObject(); vals = cJSON_CreateObject();
jaddstr(vals,"coin",virt->symbol); jaddstr(vals,"symbol",virt->symbol);
if ( (retstr= basilisk_standardservice(CMD,myinfo,hash,vals,hexstr,0)) != 0 ) if ( (retstr= basilisk_standardservice(CMD,myinfo,hash,vals,hexstr,0)) != 0 )
free(retstr); free(retstr);
free_json(vals); free_json(vals);
@ -791,16 +791,16 @@ void basilisks_loop(void *arg)
iter = 0; iter = 0;
while ( 1 ) while ( 1 )
{ {
fprintf(stderr,"basilisk iter.%d\n",iter); //fprintf(stderr,"basilisk iter.%d\n",iter);
sleep(3); //sleep(3);
fprintf(stderr,"basilisk iter.%d\n",iter); //fprintf(stderr,"basilisk iter.%d\n",iter);
iter++; iter++;
if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 ) if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 )
{ {
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr);
continue; continue;
} }
fprintf(stderr,"A"); //fprintf(stderr,"A");
if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 )
{ {
HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending); HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending);
@ -823,7 +823,7 @@ void basilisks_loop(void *arg)
free_json(retjson); free_json(retjson);
} }
} }
else if ( strcmp(ptr->CMD,"RET") == 0 ) else if ( strcmp(ptr->CMD,"RET") == 0 || strcmp(ptr->CMD,"GET") == 0 )
{ {
printf("got return for tag.%d parent.%p\n",pending->basilisktag,pending->parent); printf("got return for tag.%d parent.%p\n",pending->basilisktag,pending->parent);
if ( (parent= pending->parent) != 0 ) if ( (parent= pending->parent) != 0 )
@ -831,13 +831,15 @@ void basilisks_loop(void *arg)
pending->parent = 0; pending->parent = 0;
parent->childrendone++; parent->childrendone++;
} }
if ( strcmp(ptr->CMD,"GET") == 0 )
basilisk_geckoresult(myinfo,ptr);
} }
} }
} else printf("couldnt find issued.%u\n",ptr->basilisktag); } else printf("couldnt find issued.%u\n",ptr->basilisktag);
free(ptr); free(ptr);
continue; continue;
} }
fprintf(stderr,"B"); //fprintf(stderr,"B");
flag = 0; flag = 0;
HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp) HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp)
{ {
@ -873,7 +875,7 @@ void basilisks_loop(void *arg)
flag++; flag++;
} }
} }
fprintf(stderr,"c"); //fprintf(stderr,"c");
if ( pending->finished != 0 && time(NULL) > pending->finished+60 ) if ( pending->finished != 0 && time(NULL) > pending->finished+60 )
{ {
if ( pending->dependents == 0 || pending->childrendone >= pending->numchildren ) if ( pending->dependents == 0 || pending->childrendone >= pending->numchildren )
@ -892,7 +894,7 @@ void basilisks_loop(void *arg)
} }
} }
} }
fprintf(stderr,"D"); //fprintf(stderr,"D");
if ( (btcd= iguana_coinfind("BTCD")) != 0 ) if ( (btcd= iguana_coinfind("BTCD")) != 0 )
{ {
done = 3; done = 3;
@ -916,14 +918,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"); //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"); //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);
@ -932,7 +934,7 @@ void basilisks_loop(void *arg)
} }
free_json(valsobj); free_json(valsobj);
} }
fprintf(stderr,"G"); //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;
@ -941,7 +943,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"); //fprintf(stderr,"h");
gecko_iteration(myinfo,btcd,virt,maxmillis); gecko_iteration(myinfo,btcd,virt,maxmillis);
flag++; flag++;
} }
@ -949,7 +951,7 @@ void basilisks_loop(void *arg)
//portable_mutex_unlock(&Allcoins_mutex); //portable_mutex_unlock(&Allcoins_mutex);
} }
} }
fprintf(stderr,"i "); //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

@ -50,16 +50,16 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
{ {
if ( strcmp("BTCD",virt->symbol) == 0 ) if ( strcmp("BTCD",virt->symbol) == 0 )
; ;
fprintf(stderr,"r"); //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-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);
fprintf(stderr,"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);
} }
} }
@ -441,7 +441,7 @@ char *basilisk_standardreturn(char *CMD,char *type,struct iguana_info *virt,uint
{ {
jaddstr(retjson,"CMD",CMD); jaddstr(retjson,"CMD",CMD);
jaddstr(retjson,"type",type); jaddstr(retjson,"type",type);
jaddstr(retjson,"coin",virt->symbol); jaddstr(retjson,"symbol",virt->symbol);
//jaddnum(retjson,"longest",virt->longestchain); //jaddnum(retjson,"longest",virt->longestchain);
jaddnum(retjson,"hwm",virt->blocks.hwmchain.height); jaddnum(retjson,"hwm",virt->blocks.hwmchain.height);
jaddnum(retjson,"datalen",datalen); jaddnum(retjson,"datalen",datalen);

2
gecko/gecko_blocks.c

@ -255,7 +255,7 @@ char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *a
{ {
char *symbol; struct iguana_info *virt; bits256 checkhash2; int32_t hdrsize; uint32_t prevtimestamp,nBits; struct iguana_msgblock msg; char *symbol; struct iguana_info *virt; bits256 checkhash2; int32_t hdrsize; uint32_t prevtimestamp,nBits; struct iguana_msgblock msg;
printf("got geckoblock len.%d from (%s) %s\n",datalen,remoteaddr!=0?remoteaddr:"",jprint(valsobj,0)); printf("got geckoblock len.%d from (%s) %s\n",datalen,remoteaddr!=0?remoteaddr:"",jprint(valsobj,0));
if ( (symbol= jstr(valsobj,"coin")) != 0 && (virt= iguana_coinfind(symbol)) != 0 ) if ( (symbol= jstr(valsobj,"symbol")) != 0 && (virt= iguana_coinfind(symbol)) != 0 )
{ {
if ( iguana_blockfind("geckoblock",virt,hash2) != 0 ) if ( iguana_blockfind("geckoblock",virt,hash2) != 0 )
{ {

2
gecko/gecko_miner.c

@ -340,7 +340,7 @@ void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct ig
//char str[65]; printf("HWM.%s %p\n",bits256_str(str,newblock.RO.prev_block),&newblock.RO.prev_block); //char str[65]; printf("HWM.%s %p\n",bits256_str(str,newblock.RO.prev_block),&newblock.RO.prev_block);
if ( (blockstr= gecko_createblock(myinfo,virt->chain->estblocktime,prevtimestamp,btcd,virt->chain->isPoS,(void *)&newblock,virt->symbol,txptrs,txn_count,maxmillis,minerpubkey33,reward)) != 0 ) if ( (blockstr= gecko_createblock(myinfo,virt->chain->estblocktime,prevtimestamp,btcd,virt->chain->isPoS,(void *)&newblock,virt->symbol,txptrs,txn_count,maxmillis,minerpubkey33,reward)) != 0 )
{ {
char str[65]; printf("%s.%x %s %u %d %.8f %d\n",virt->symbol,newblock.RO.bits,bits256_str(str,newblock.RO.hash2),newblock.RO.timestamp,newblock.height,dstr(reward),newblock.RO.txn_count); char str[65]; printf(">>>>>>>>>>>>>>>>> MINED %s.%x %s %u %d %.8f %d\n",virt->symbol,newblock.RO.bits,bits256_str(str,newblock.RO.hash2),newblock.RO.timestamp,newblock.height,dstr(reward),newblock.RO.txn_count);
gecko_blocksubmit(myinfo,btcd,virt,blockstr,newblock.RO.hash2); gecko_blocksubmit(myinfo,btcd,virt,blockstr,newblock.RO.hash2);
free(blockstr); free(blockstr);
} }

Loading…
Cancel
Save