Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
d7e42bc7cd
  1. 7
      basilisk/basilisk.c
  2. 40
      gecko/gecko.c
  3. 28
      gecko/gecko_blocks.c
  4. 19
      gecko/gecko_headers.c
  5. 2
      gecko/gecko_miner.c
  6. 2
      iguana/iguana_init.c

7
basilisk/basilisk.c

@ -786,7 +786,7 @@ void basilisks_loop(void *arg)
while ( 1 )
{
fprintf(stderr,"basilisk iter.%d\n",iter);
sleep(1);
sleep(3);
fprintf(stderr,"basilisk iter.%d\n",iter);
iter++;
if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 )
@ -794,6 +794,7 @@ void basilisks_loop(void *arg)
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr);
continue;
}
fprintf(stderr,"A");
if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 )
{
HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending);
@ -830,6 +831,7 @@ void basilisks_loop(void *arg)
free(ptr);
continue;
}
fprintf(stderr,"B");
flag = 0;
HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp)
{
@ -865,6 +867,7 @@ void basilisks_loop(void *arg)
flag++;
}
}
fprintf(stderr,"c");
if ( pending->finished != 0 && time(NULL) > pending->finished+60 )
{
if ( pending->dependents == 0 || pending->childrendone >= pending->numchildren )
@ -883,6 +886,7 @@ void basilisks_loop(void *arg)
}
}
}
fprintf(stderr,"D");
if ( (btcd= iguana_coinfind("BTCD")) != 0 )
{
done = 3;
@ -935,6 +939,7 @@ void basilisks_loop(void *arg)
//portable_mutex_unlock(&Allcoins_mutex);
}
}
fprintf(stderr,"E ");
//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 )
// basilisk_bitcoinscan(coin,blockspace,&RAWMEM);

40
gecko/gecko.c

@ -39,32 +39,25 @@
#include "gecko_miner.c"
#include "gecko_blocks.c"
int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2)
void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis)
{
int32_t datalen; uint8_t *data,space[16384],*allocptr; cJSON *valsobj=0,*retjson; char *str,*str2;
if ( (data= get_dataptr(sizeof(struct iguana_msghdr) + BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),blockstr)) != 0 )
char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi;
hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize;
longesthdrsi = virt->longestchain / virt->chain->bundlesize;
if ( hwmhdrsi <= longesthdrsi )
{
if ( (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2)) != 0 )
if ( time(NULL) > virt->hdrstime+3 )
{
if ( (retjson= cJSON_Parse(str)) != 0 )
{
if ( jobj(retjson,"error") == 0 )
{
valsobj = cJSON_CreateObject();
jaddnum(valsobj,"fanout",-1);
jaddstr(valsobj,"symbol",virt->symbol);
if ( (str2= basilisk_standardservice("BLK",myinfo,hash2,valsobj,blockstr,0)) != 0 )
free(str2);
free_json(valsobj);
}
free_json(retjson);
}
free(str);
gecko_requesthdrs(myinfo,virt,hwmhdrsi);
virt->hdrstime = (uint32_t)time(NULL);
}
}
if ( allocptr != 0 )
free(allocptr);
return(0);
if ( btcd->RELAYNODE != 0 && virt->blocks.hwmchain.height >= virt->longestchain-1 )
{
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//printf("mine.%s %s\n",virt->symbol,mineraddr);
gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33);
}
}
int32_t iguana_ROallocsize(struct iguana_info *virt)
@ -448,8 +441,7 @@ char *basilisk_standardreturn(char *CMD,char *type,struct iguana_info *virt,uint
jaddnum(retjson,"longest",virt->longestchain);
jaddnum(retjson,"hwm",virt->blocks.hwmchain.height);
jaddbits256(retjson,"hash",hash);
}
else jaddstr(retjson,"error","no data to send");
} else jaddstr(retjson,"error","no data to send");
if ( allocstr != 0 )
free(allocstr);
return(jprint(retjson,1));
@ -474,7 +466,7 @@ char *basilisk_respond_geckoget(struct supernet_info *myinfo,char *CMD,void *add
if ( (symbol= jstr(valsobj,"symbol")) != 0 && (virt= iguana_coinfind(symbol)) != 0 )
{
datalen = (*getfunc)(myinfo,virt,serialized,maxsize,valsobj,hash2);
return(basilisk_standardreturn(CMD,type,virt,serialized,len,hash2));
return(basilisk_standardreturn(CMD,type,virt,serialized,datalen,hash2));
} else return(clonestr("{\"error\":\"couldt find gecko chain\"}"));
} else return(clonestr("{\"error\":\"invalid geckoget type, mustbe (HDR or BLK or GTX)\"}"));
}

28
gecko/gecko_blocks.c

@ -272,6 +272,34 @@ char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *a
return(0);
}
int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2)
{
int32_t datalen; uint8_t *data,space[16384],*allocptr; cJSON *valsobj=0,*retjson; char *str,*str2;
if ( (data= get_dataptr(sizeof(struct iguana_msghdr) + BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),blockstr)) != 0 )
{
if ( (str= gecko_blockarrived(myinfo,virt,"127.0.0.1",data,datalen,hash2)) != 0 )
{
if ( (retjson= cJSON_Parse(str)) != 0 )
{
if ( jobj(retjson,"error") == 0 )
{
valsobj = cJSON_CreateObject();
jaddnum(valsobj,"fanout",-1);
jaddstr(valsobj,"symbol",virt->symbol);
if ( (str2= basilisk_standardservice("BLK",myinfo,hash2,valsobj,blockstr,0)) != 0 )
free(str2);
free_json(valsobj);
}
free_json(retjson);
}
free(str);
}
}
if ( allocptr != 0 )
free(allocptr);
return(0);
}
int32_t basilisk_respond_geckogetblock(struct supernet_info *myinfo,struct iguana_info *virt,uint8_t *serialized,int32_t maxsize,cJSON *valsobj,bits256 hash2)
{
int32_t datalen = 0; char str[65];

19
gecko/gecko_headers.c

@ -81,24 +81,11 @@ void gecko_requesthdrs(struct supernet_info *myinfo,struct iguana_info *virt,int
{
vals = cJSON_CreateObject();
memset(zero.bytes,0,sizeof(zero));
jaddstr(vals,"coin",virt->symbol);
if ( (retstr= basilisk_standardservice("HDR",myinfo,bp->hashes[0],vals,0,0)) != 0 )
jaddstr(vals,"symbol",virt->symbol);
jaddstr(vals,"type","HDR");
if ( (retstr= basilisk_standardservice("GET",myinfo,bp->hashes[0],vals,0,0)) != 0 )
free(retstr);
free_json(vals);
} else printf("dont have bundle needed\n");
}
void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis)
{
char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi;
hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize;
longesthdrsi = virt->longestchain / virt->chain->bundlesize;
if ( hwmhdrsi < longesthdrsi )
gecko_requesthdrs(myinfo,virt,hwmhdrsi);
if ( btcd->RELAYNODE != 0 )
{
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//printf("mine.%s %s\n",virt->symbol,mineraddr);
gecko_miner(myinfo,btcd,virt,maxmillis,myinfo->persistent_pubkey33);
}
}

2
gecko/gecko_miner.c

@ -304,7 +304,7 @@ cJSON *gecko_paymentsobj(struct supernet_info *myinfo,cJSON *txjson,cJSON *valso
void gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2)
{
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 )
basilisk_blocksubmit(myinfo,btcd,virt,blockstr,hash2);
else // physical node for geckochain

2
iguana/iguana_init.c

@ -316,7 +316,7 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
{
decode_hex(hash2.bytes,sizeof(hash2),line+k+1);
if ( coin->virtualchain != 0 )
printf("line.(%s) k.%d (%c)(%c)(%d)\n",line,k,line[k+63],line[k+64],line[k+65]);
printf("%s line.(%s) k.%d (%c)(%c)(%d)\n",coin->symbol,line,k,line[k+63],line[k+64],line[k+65]);
if ( height >= 0 && bits256_nonz(hash2) != 0 )
{
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,zero,0)) != 0 )

Loading…
Cancel
Save