From ececd150a1e76cc712a464ce53ad33c49f6061e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 19 Jun 2016 17:20:11 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 36 +++++++++++++++++++----------------- gecko/gecko.c | 8 ++++---- gecko/gecko_blocks.c | 2 +- gecko/gecko_miner.c | 2 +- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 8c2335457..07a1aece1 100755 --- a/basilisk/basilisk.c +++ b/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) { char *sendstr,*hexstr=0; uint8_t *data,hexspace[8192],*allocptr=0,*hexdata; int32_t datalen,hexlen=0; - if ( jobj(sendjson,"coin") == 0 ) - jaddstr(sendjson,"coin",symbol); + if ( jobj(sendjson,"symbol") == 0 ) + jaddstr(sendjson,"symbol",symbol); if ( (hexstr= jstr(sendjson,"data")) != 0 ) { 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 ) { - jaddstr(valsobj,"coin",symbol); + jaddstr(valsobj,"symbol",symbol); jaddnum(valsobj,"longest",virt->longestchain); 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 ) { vals = cJSON_CreateObject(); - jaddstr(vals,"coin",virt->symbol); + jaddstr(vals,"symbol",virt->symbol); if ( (retstr= basilisk_standardservice(CMD,myinfo,hash,vals,hexstr,0)) != 0 ) free(retstr); free_json(vals); @@ -791,16 +791,16 @@ void basilisks_loop(void *arg) iter = 0; while ( 1 ) { - fprintf(stderr,"basilisk iter.%d\n",iter); - sleep(3); - fprintf(stderr,"basilisk iter.%d\n",iter); + //fprintf(stderr,"basilisk iter.%d\n",iter); + //sleep(3); + //fprintf(stderr,"basilisk iter.%d\n",iter); iter++; if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 ) { HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); continue; } - fprintf(stderr,"A"); + //fprintf(stderr,"A"); if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) { HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending); @@ -823,7 +823,7 @@ void basilisks_loop(void *arg) 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); if ( (parent= pending->parent) != 0 ) @@ -831,13 +831,15 @@ void basilisks_loop(void *arg) pending->parent = 0; parent->childrendone++; } + if ( strcmp(ptr->CMD,"GET") == 0 ) + basilisk_geckoresult(myinfo,ptr); } } } else printf("couldnt find issued.%u\n",ptr->basilisktag); free(ptr); continue; } - fprintf(stderr,"B"); + //fprintf(stderr,"B"); flag = 0; HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp) { @@ -873,7 +875,7 @@ void basilisks_loop(void *arg) flag++; } } - fprintf(stderr,"c"); + //fprintf(stderr,"c"); if ( pending->finished != 0 && time(NULL) > pending->finished+60 ) { 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 ) { done = 3; @@ -916,14 +918,14 @@ void basilisks_loop(void *arg) valsobj = cJSON_CreateObject(); if ( btcd->RELAYNODE == 0 && btcd->VALIDATENODE == 0 ) { - fprintf(stderr,"e"); + //fprintf(stderr,"e"); jaddnum(valsobj,"BTCD",btcd->SEQ.BTCD.numstamps+GECKO_FIRSTPOSSIBLEBTCD); basilisk_standardservice("SEQ",myinfo,GENESIS_PUBKEY,valsobj,0,0); flag++; } if ( (done & 2) == 0 ) { - fprintf(stderr,"f"); + //fprintf(stderr,"f"); free_json(valsobj); valsobj = cJSON_CreateObject(); jaddnum(valsobj,"BTC",btcd->SEQ.BTC.numstamps+GECKO_FIRSTPOSSIBLEBTC); @@ -932,7 +934,7 @@ void basilisks_loop(void *arg) } free_json(valsobj); } - fprintf(stderr,"G"); + //fprintf(stderr,"G"); if ( flag == 0 && myinfo->allcoins_numvirts > 0 ) { 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 ) { - fprintf(stderr,"h"); + //fprintf(stderr,"h"); gecko_iteration(myinfo,btcd,virt,maxmillis); flag++; } @@ -949,7 +951,7 @@ void basilisks_loop(void *arg) //portable_mutex_unlock(&Allcoins_mutex); } } - fprintf(stderr,"i "); + //fprintf(stderr,"i "); //for (i=0; iRELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 ) // basilisk_bitcoinscan(coin,blockspace,&RAWMEM); diff --git a/gecko/gecko.c b/gecko/gecko.c index 9a68b393b..fad8e9f63 100755 --- a/gecko/gecko.c +++ b/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 ) ; - fprintf(stderr,"r"); + //fprintf(stderr,"r"); gecko_requesthdrs(myinfo,virt,hwmhdrsi); - fprintf(stderr,"R"); + //fprintf(stderr,"R"); virt->hdrstime = (uint32_t)time(NULL); } } if ( btcd->RELAYNODE != 0 && virt->blocks.hwmchain.height >= virt->longestchain-1 ) { 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); } } @@ -441,7 +441,7 @@ char *basilisk_standardreturn(char *CMD,char *type,struct iguana_info *virt,uint { jaddstr(retjson,"CMD",CMD); jaddstr(retjson,"type",type); - jaddstr(retjson,"coin",virt->symbol); + jaddstr(retjson,"symbol",virt->symbol); //jaddnum(retjson,"longest",virt->longestchain); jaddnum(retjson,"hwm",virt->blocks.hwmchain.height); jaddnum(retjson,"datalen",datalen); diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index 63ebd9bd0..d023cfff5 100755 --- a/gecko/gecko_blocks.c +++ b/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; 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 ) { diff --git a/gecko/gecko_miner.c b/gecko/gecko_miner.c index 9f9649da2..6dc69d6bb 100755 --- a/gecko/gecko_miner.c +++ b/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); 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); free(blockstr); }