Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c1f66a53cd
  1. 13
      basilisk/basilisk.c
  2. 4
      basilisk/basilisk.h
  3. 26
      gecko/gecko.c
  4. 9
      iguana/iguana777.c
  5. 2
      includes/iguana_structs.h

13
basilisk/basilisk.c

@ -785,12 +785,13 @@ void basilisks_loop(void *arg)
iter = 0; iter = 0;
while ( 1 ) while ( 1 )
{ {
fprintf(stderr,"basilisk iter.%d\n",iter);
sleep(1);
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 )
{ {
//if ( ptr->finished == 0 )
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr);
//else free(ptr);
continue; continue;
} }
if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 )
@ -857,7 +858,7 @@ void basilisks_loop(void *arg)
pending->finished = (uint32_t)time(NULL); pending->finished = (uint32_t)time(NULL);
if ( pending->retstr == 0 ) if ( pending->retstr == 0 )
pending->retstr = clonestr("{\"error\":\"basilisk timeout\"}"); pending->retstr = clonestr("{\"error\":\"basilisk timeout\"}");
printf("timeout.%s call metrics.%u lag %f - %f\n",pending->CMD,pending->basilisktag,OS_milliseconds(),pending->expiration); fprintf(stderr,"timeout.%s call metrics.%u lag %f - %f\n",pending->CMD,pending->basilisktag,OS_milliseconds(),pending->expiration);
for (i=0; i<pending->numresults; i++) for (i=0; i<pending->numresults; i++)
if ( (metricfunc= pending->metricfunc) != 0 ) if ( (metricfunc= pending->metricfunc) != 0 )
pending->metrics[i] = (*metricfunc)(myinfo,pending,pending->results[i]); pending->metrics[i] = (*metricfunc)(myinfo,pending,pending->results[i]);
@ -871,13 +872,13 @@ void basilisks_loop(void *arg)
HASH_DELETE(hh,myinfo->basilisks.issued,pending); HASH_DELETE(hh,myinfo->basilisks.issued,pending);
if ( pending->dependents != 0 ) if ( pending->dependents != 0 )
free(pending->dependents); free(pending->dependents);
//printf("HASH_DELETE free ptr.%u\n",pending->basilisktag); fprintf(stderr,"HASH_DELETE free ptr.%u\n",pending->basilisktag);
for (i=0; i<pending->numresults; i++) for (i=0; i<pending->numresults; i++)
if ( pending->results[i] != 0 ) if ( pending->results[i] != 0 )
free(pending->results[i]), pending->results[i] = 0; free(pending->results[i]), pending->results[i] = 0;
if ( pending->vals != 0 ) if ( pending->vals != 0 )
free_json(pending->vals), pending->vals = 0; free_json(pending->vals), pending->vals = 0;
//free(pending); free(pending);
flag++; flag++;
} }
} }
@ -1131,7 +1132,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr); basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr);
if ( retstr != 0 ) if ( retstr != 0 )
free(retstr); free(retstr);
} else printf("services null return\n"); } //else printf("services null return\n");
} else printf("non-relay got unexpected.(%s)\n",type); } else printf("non-relay got unexpected.(%s)\n",type);
free_json(valsobj); free_json(valsobj);
if ( coin != 0 ) if ( coin != 0 )

4
basilisk/basilisk.h

@ -24,8 +24,8 @@
#define BASILISK_DEFAULTDIFF 0x1effffff #define BASILISK_DEFAULTDIFF 0x1effffff
#define BASILISK_MAXFUTUREBLOCK 60 #define BASILISK_MAXFUTUREBLOCK 60
#define BASILISK_MAXBLOCKLAG 600 //#define BASILISK_MAXBLOCKLAG 600
#define BASILISK_HDROFFSET ((int32_t)(sizeof(struct iguana_msghdr)+sizeof(uint32_t))) #define BASILISK_HDROFFSET ((int32_t)(sizeof(bits256)+sizeof(struct iguana_msghdr)+sizeof(uint32_t)))
struct basilisk_value { bits256 txid; int64_t value; int32_t height; int16_t vout; char coinaddr[64]; }; struct basilisk_value { bits256 txid; int64_t value; int32_t height; int16_t vout; char coinaddr[64]; };

26
gecko/gecko.c

@ -600,9 +600,8 @@ HASH_ARRAY_STRING(basilisk,geckogenesis,hash,vals,hexstr)
{ {
if ( (retstr= basilisk_standardservice("GEN",myinfo,hash,vals,hexstr,1)) != 0 ) if ( (retstr= basilisk_standardservice("GEN",myinfo,hash,vals,hexstr,1)) != 0 )
{ {
item = cJSON_Parse(retstr); myinfo->genesisresults++;
arrayB = cJSON_CreateArray(); arrayB = cJSON_Parse(retstr);
jaddi(arrayB,item);
free(retstr); free(retstr);
} }
if ( btcd->RELAYNODE != 0 || btcd->VALIDATENODE != 0 ) if ( btcd->RELAYNODE != 0 || btcd->VALIDATENODE != 0 )
@ -616,26 +615,27 @@ HASH_ARRAY_STRING(basilisk,geckogenesis,hash,vals,hexstr)
array = arrayB; array = arrayB;
else if ( arrayB != 0 ) else if ( arrayB != 0 )
{ {
if ( (n= cJSON_GetArraySize(arrayB)) > 0 ) if ( (n= cJSON_GetArraySize(array)) > 0 )
{ {
if ( (m= cJSON_GetArraySize(array)) <= 0 ) if ( (m= cJSON_GetArraySize(arrayB)) > 0 )
array = arrayB;
else
{ {
for (i=0; i<n; i++) for (j=0; j<m; j++)
{ {
item = jitem(arrayB,i); item = jitem(arrayB,j);
if ( (symbol= jstr(item,"symbol")) != 0 ) if ( jobj(item,"error") == 0 && (symbol= jstr(item,"symbol")) != 0 )
{ {
for (j=0; j<m; j++) for (i=0; i<n; i++)
{ {
if ( (ref= jstr(jitem(array,j),"symbol")) != 0 && strcmp(symbol,ref) != 0 ) if ( (ref= jstr(jitem(array,i),"symbol")) != 0 && strcmp(symbol,ref) == 0 )
jaddi(arrayB,jduplicate(item)); break;
} }
if ( i == n )
jaddi(array,jduplicate(item));
} }
} }
} }
} }
free_json(arrayB);
} }
} else array = arrayB; } else array = arrayB;
if ( array != 0 ) if ( array != 0 )

9
iguana/iguana777.c

@ -550,7 +550,7 @@ void iguana_helper(void *arg)
{ {
static int32_t maxhelperid; static int32_t maxhelperid;
cJSON *argjson=0; int32_t iter,n,j,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0; cJSON *argjson=0; int32_t iter,n,j,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0;
struct iguana_helper *ptr; struct iguana_info *coin,*tmp; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp; struct supernet_info *myinfo = SuperNET_MYINFO(0); struct iguana_helper *ptr; struct iguana_info *coin,*btcd,*tmp; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp; struct supernet_info *myinfo = SuperNET_MYINFO(0);
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 ) if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
helperid = juint(argjson,"helperid"); helperid = juint(argjson,"helperid");
if ( helperid > maxhelperid ) if ( helperid > maxhelperid )
@ -571,6 +571,11 @@ void iguana_helper(void *arg)
sleep(2); sleep(2);
while ( 1 ) while ( 1 )
{ {
if ( helperid == 0 && (btcd= iguana_coinfind("BTCD")) != 0 )
{
if ( myinfo->numrelays > 0 && myinfo->genesisresults == 0 )
basilisk_geckogenesis(myinfo,btcd,0,0,GENESIS_PUBKEY,0,0);
}
//iguana_jsonQ(); cant do this here //iguana_jsonQ(); cant do this here
flag = 0; flag = 0;
allcurrent = 2; allcurrent = 2;
@ -685,8 +690,6 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 ) if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 )
bp->bundleheight = 0; bp->bundleheight = 0;
if ( strcmp("BTCD",coin->symbol) == 0 )
basilisk_geckogenesis(myinfo,coin,0,0,GENESIS_PUBKEY,0,0);
} }
void iguana_coinloop(void *arg) void iguana_coinloop(void *arg)

2
includes/iguana_structs.h

@ -457,7 +457,7 @@ struct supernet_info
uint8_t persistent_pubkey33[33]; uint8_t persistent_pubkey33[33];
char ipaddr[64],NXTAPIURL[512],secret[4096],rpcsymbol[64],handle[1024],permanentfile[1024]; char ipaddr[64],NXTAPIURL[512],secret[4096],rpcsymbol[64],handle[1024],permanentfile[1024];
char *decryptstr; char *decryptstr;
int32_t maxdelay,IAMRELAY,publicRPC,basilisk_busy; int32_t maxdelay,IAMRELAY,publicRPC,basilisk_busy,genesisresults;
uint32_t expiration,dirty; uint32_t expiration,dirty;
uint16_t argport,rpcport; uint16_t argport,rpcport;
struct basilisk_info basilisks; struct basilisk_info basilisks;

Loading…
Cancel
Save