jl777 8 years ago
parent
commit
79acf87a8f
  1. 108
      basilisk/basilisk.c
  2. 6
      basilisk/basilisk.h
  3. 8
      basilisk/basilisk_CMD.c
  4. 2
      basilisk/basilisk_MSG.c
  5. 4
      basilisk/basilisk_bitcoin.c
  6. 2
      basilisk/basilisk_tradebot.c
  7. 5
      iguana/iguana777.c
  8. 4
      iguana/iguana_unspents.c
  9. 4
      iguana/iguana_wallet.c
  10. 12
      iguana/pnacl/Release/iguana.nmf
  11. 1
      includes/iguana_funcs.h

108
basilisk/basilisk.c

@ -141,7 +141,9 @@ struct basilisk_item *basilisk_itemcreate(struct supernet_info *myinfo,char *CMD
ptr->numrequired = 1; ptr->numrequired = 1;
strcpy(ptr->CMD,CMD); strcpy(ptr->CMD,CMD);
safecopy(ptr->symbol,symbol,sizeof(ptr->symbol)); safecopy(ptr->symbol,symbol,sizeof(ptr->symbol));
ptr->duration = timeoutmillis;
ptr->expiration = OS_milliseconds() + timeoutmillis; ptr->expiration = OS_milliseconds() + timeoutmillis;
//printf("itemcreate.%p %s %f timeout.%d\n",ptr,CMD,OS_milliseconds(),timeoutmillis);
return(ptr); return(ptr);
} }
@ -335,7 +337,7 @@ void basilisk_sendback(struct supernet_info *myinfo,char *origCMD,char *symbol,c
struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,struct iguana_peer *addr,int32_t *numsentp,char *CMD,char *symbol,int32_t blockflag,cJSON *valsobj,int32_t fanout,int32_t numrequired,uint32_t basilisktag,int32_t timeoutmillis,void *deprecated_dontuse,char *retstr,int32_t encryptflag,int32_t delaymillis,uint32_t nBits) struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,struct iguana_peer *addr,int32_t *numsentp,char *CMD,char *symbol,int32_t blockflag,cJSON *valsobj,int32_t fanout,int32_t numrequired,uint32_t basilisktag,int32_t timeoutmillis,void *deprecated_dontuse,char *retstr,int32_t encryptflag,int32_t delaymillis,uint32_t nBits)
{ {
struct basilisk_item *pending; uint8_t *allocptr,*data,space[4096]; int32_t datalen; cJSON *retarray; struct basilisk_item *pending; uint8_t *allocptr,*data,space[4096]; int32_t datalen;
pending = basilisk_itemcreate(myinfo,CMD,symbol,basilisktag,numrequired,valsobj,timeoutmillis,0); pending = basilisk_itemcreate(myinfo,CMD,symbol,basilisktag,numrequired,valsobj,timeoutmillis,0);
pending->nBits = nBits; pending->nBits = nBits;
*numsentp = 0; *numsentp = 0;
@ -356,31 +358,23 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,struct i
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(basilisktag),pending); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(basilisktag),pending);
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
if ( pending->expiration <= OS_milliseconds() ) if ( pending->expiration <= OS_milliseconds() )
pending->expiration = OS_milliseconds() + BASILISK_TIMEOUT; pending->expiration = OS_milliseconds() + pending->duration;
strcpy(pending->symbol,"BTCD"); strcpy(pending->symbol,"NOTARY");
strcpy(pending->CMD,CMD); strcpy(pending->CMD,CMD);
//printf("block for %f\n",pending->expiration - OS_milliseconds());
while ( OS_milliseconds() < pending->expiration ) while ( OS_milliseconds() < pending->expiration )
{ {
portable_mutex_lock(&myinfo->basilisk_mutex); portable_mutex_lock(&myinfo->basilisk_mutex);
if ( pending->numresults >= pending->numrequired )//|| (retstr= pending->retstr) != 0 ) if ( pending->numresults >= pending->numrequired )
{ {
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
//printf("<<<<<<<<<<<<< numresults.%d vs numrequired.%d\n",pending->numresults,pending->numrequired); //printf("%p <<<<<<<<<<<<< numresults.%d vs numrequired.%d\n",pending,pending->numresults,pending->numrequired);
break; break;
} }
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
usleep(10000); usleep(10000);
} }
portable_mutex_lock(&myinfo->basilisk_mutex); }
if ( (retarray= pending->retarray) != 0 )
{
pending->retstr = jprint(retarray,0);
printf("num.%d:%d required.%d RETSTR.(%s)\n",pending->numresults,cJSON_GetArraySize(pending->retarray),pending->numrequired,pending->retstr);
pending->retarray = 0;
free_json(retarray);
}
portable_mutex_unlock(&myinfo->basilisk_mutex);
} else free(pending), pending = 0; //ptr->finished = (uint32_t)time(NULL);
if ( allocptr != 0 ) if ( allocptr != 0 )
free(allocptr); free(allocptr);
} }
@ -409,7 +403,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc
if ( fanout < minfanout ) if ( fanout < minfanout )
fanout = minfanout; fanout = minfanout;
if ( (numrequired= jint(valsobj,"numrequired")) <= 0 ) if ( (numrequired= jint(valsobj,"numrequired")) <= 0 )
numrequired = MIN(fanout,sqrt(myinfo->NOTARY.NUMRELAYS)+1); numrequired = MIN(fanout/2,sqrt(myinfo->NOTARY.NUMRELAYS)+1);
if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 ) if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 )
{ {
if ( (virt= iguana_coinfind(symbol)) != 0 ) if ( (virt= iguana_coinfind(symbol)) != 0 )
@ -420,7 +414,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc
} }
} }
if ( symbol == 0 ) if ( symbol == 0 )
symbol = "BTCD"; symbol = "NOTARY";
encryptflag = jint(valsobj,"encrypt"); encryptflag = jint(valsobj,"encrypt");
delaymillis = jint(valsobj,"delay"); delaymillis = jint(valsobj,"delay");
ptr = basilisk_issueremote(myinfo,addr,&numsent,CMD,symbol,blockflag,valsobj,fanout,numrequired,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits); ptr = basilisk_issueremote(myinfo,addr,&numsent,CMD,symbol,blockflag,valsobj,fanout,numrequired,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits);
@ -429,7 +423,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc
char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_addr,bits256 hash,cJSON *valsobj,char *hexstr,int32_t blockflag) // client side char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_addr,bits256 hash,cJSON *valsobj,char *hexstr,int32_t blockflag) // client side
{ {
uint32_t nBits = 0; uint8_t space[4096],*allocptr=0,*data = 0; struct basilisk_item *ptr; int32_t datalen = 0; cJSON *retjson; char *retstr=0; uint32_t nBits = 0; uint8_t space[4096],*allocptr=0,*data = 0; struct basilisk_item *ptr; int32_t i,datalen = 0; cJSON *retjson; char *retstr=0;
if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 && (strcmp(CMD,"INF") != 0 && basilisk_notarycmd(CMD) == 0) ) if ( myinfo->IAMNOTARY != 0 && myinfo->NOTARY.RELAYID >= 0 && (strcmp(CMD,"INF") != 0 && basilisk_notarycmd(CMD) == 0) )
return(clonestr("{\"error\":\"unsupported special relay command\"}")); return(clonestr("{\"error\":\"unsupported special relay command\"}"));
data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr);
@ -439,23 +433,33 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_add
free(allocptr); free(allocptr);
if ( ptr != 0 ) if ( ptr != 0 )
{ {
if ( ptr->retstr != 0 ) if ( (retstr= ptr->retstr) != 0 )
retstr = ptr->retstr, ptr->retstr = 0; ptr->retstr = 0;
else else
{ {
retjson = cJSON_CreateObject(); if ( ptr->numresults > 0 )
if ( ptr->numsent > 0 ) {
retjson = cJSON_CreateArray();
for (i=0; i<ptr->numresults; i++)
jaddi(retjson,ptr->results[i]), ptr->results[i] = 0;
//printf("numresults.%d (%p)\n",ptr->numresults,ptr);
}
else
{ {
//queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); retjson = cJSON_CreateObject();
jaddstr(retjson,"result","error"); if ( ptr->numsent > 0 )
jaddnum(retjson,"numsent",ptr->numsent); {
} else jaddstr(retjson,"error","didnt find any nodes to send to"); //queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0);
jaddstr(retjson,"result","error");
jaddnum(retjson,"numsent",ptr->numsent);
} else jaddstr(retjson,"error","didnt find any nodes to send to");
}
retstr = jprint(retjson,1); retstr = jprint(retjson,1);
} }
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
} }
//if ( strcmp("MSG",CMD) == 0 ) if ( 0 && strcmp("MSG",CMD) == 0 )
// printf("%s.(%s) -> (%s)\n",CMD,jprint(valsobj,0),retstr!=0?retstr:""); printf("%s.(%s) -> (%s)\n",CMD,jprint(valsobj,0),retstr!=0?retstr:"");
return(retstr); return(retstr);
} }
@ -588,25 +592,22 @@ void basilisk_result(struct supernet_info *myinfo,char *remoteaddr,uint32_t basi
{ {
portable_mutex_lock(&myinfo->basilisk_mutex); portable_mutex_lock(&myinfo->basilisk_mutex);
HASH_FIND(hh,myinfo->basilisks.issued,&basilisktag,sizeof(basilisktag),pending); HASH_FIND(hh,myinfo->basilisks.issued,&basilisktag,sizeof(basilisktag),pending);
//printf("HASH_FIND.%p\n",pending); portable_mutex_unlock(&myinfo->basilisk_mutex);
if ( pending != 0 && retstr != 0 ) if ( pending != 0 && retstr != 0 )
{ {
if ( (item= cJSON_Parse(retstr)) != 0 ) if ( (item= cJSON_Parse(retstr)) != 0 )
{ {
if ( pending->retarray == 0 )
pending->retarray = cJSON_CreateArray();
if ( jobj(item,"myip") == 0 ) if ( jobj(item,"myip") == 0 )
jaddstr(item,"myip",remoteaddr); jaddstr(item,"myip",remoteaddr);
jaddi(pending->retarray,item); if ( pending->numresults < sizeof(pending->results)/sizeof(*pending->results) )
if ( jobj(item,"error") == 0 )
{ {
printf("numresults.%d:%d (%s)\n",pending->numresults,cJSON_GetArraySize(pending->retarray),jprint(item,0)); //printf("%p.(RESULT).%d\n",pending,pending->numresults);
pending->numresults++; pending->results[pending->numresults++] = item;
} }
} else printf("couldnt parse.(%s)\n",retstr); } else printf("couldnt parse.(%s)\n",retstr);
} //else printf("couldnt find issued.%u\n",basilisktag); } //else printf("couldnt find issued.%u\n",basilisktag);
portable_mutex_unlock(&myinfo->basilisk_mutex);
} }
free(retstr);
} }
} }
@ -785,10 +786,10 @@ int32_t basilisk_p2pQ_process(struct supernet_info *myinfo,int32_t maxiters)
{ {
len += iguana_rwnum(0,ptr->data,sizeof(basilisktag),&basilisktag); len += iguana_rwnum(0,ptr->data,sizeof(basilisktag),&basilisktag);
if ( 0 && myinfo->IAMLP == 0 ) if ( 0 && myinfo->IAMLP == 0 )
printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,ptr->datalen,ptr->type,senderip!=0?senderip:"?",basilisktag); printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,ptr->datalen,ptr->type,senderip,basilisktag);
basilisk_msgprocess(myinfo,ptr->addr,ptr->ipbits,ptr->type,basilisktag,&ptr->data[len],ptr->datalen - len); basilisk_msgprocess(myinfo,ptr->addr,ptr->ipbits,ptr->type,basilisktag,&ptr->data[len],ptr->datalen - len);
if ( 0 && myinfo->IAMLP == 0 ) if ( 0 && myinfo->IAMLP == 0 )
printf("processed.%s from %s\n",ptr->type,senderip!=0?senderip:"?"); printf("processed.%s from %s\n",ptr->type,senderip);
} }
free(ptr); free(ptr);
n++; n++;
@ -834,8 +835,13 @@ void basilisk_p2p(struct supernet_info *myinfo,struct iguana_info *coin,struct i
void basilisk_requests_poll(struct supernet_info *myinfo) void basilisk_requests_poll(struct supernet_info *myinfo)
{ {
static uint32_t lastpoll;
char *retstr; uint8_t data[8192]; cJSON *outerarray,*retjson; int32_t datalen,i,n; struct basilisk_request issueR; double hwm = 0.; char *retstr; uint8_t data[8192]; cJSON *outerarray,*retjson; int32_t datalen,i,n; struct basilisk_request issueR; double hwm = 0.;
if ( time(NULL) < lastpoll+3 )
return;
lastpoll = (uint32_t)time(NULL);
memset(&issueR,0,sizeof(issueR)); memset(&issueR,0,sizeof(issueR));
//printf("Call incoming\n");
if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 ) if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 )
{ {
//printf("poll.(%s)\n",retstr); //printf("poll.(%s)\n",retstr);
@ -876,13 +882,19 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad) int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad)
{ {
struct basilisk_item *tmp,*pending; int32_t n = 0; double startmilli = OS_milliseconds(); struct basilisk_item *tmp,*pending; cJSON *item; int32_t i,n = 0; double startmilli = OS_milliseconds();
portable_mutex_lock(&myinfo->basilisk_mutex); portable_mutex_lock(&myinfo->basilisk_mutex);
HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp) HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp)
{ {
if ( pending != 0 && (pending->finished != 0 || startmilli > pending->expiration+timepad) ) if ( pending != 0 && ((pending->finished > 0 && startmilli > pending->finished) || startmilli > pending->expiration+timepad) )
{ {
HASH_DELETE(hh,myinfo->basilisks.issued,pending); HASH_DELETE(hh,myinfo->basilisks.issued,pending);
//printf("%f > %f (%d) clear pending.%p numresults.%d %p\n",startmilli,pending->expiration+timepad,timepad,pending,pending->numresults,pending->retstr);
for (i=0; i<pending->numresults; i++)
if ( (item= pending->results[i]) != 0 )
free_json(item);
if ( pending->retstr != 0 )
free(pending->retstr);
memset(pending,0,sizeof(*pending)); memset(pending,0,sizeof(*pending));
free(pending); free(pending);
n++; n++;
@ -911,11 +923,11 @@ void basilisk_iteration(struct supernet_info *myinfo)
} }
}*/ }*/
} }
else if ( myinfo->expiration != 0 ) /*else
{ {
if ( myinfo->IAMLP != 0 || myinfo->DEXactive > now ) if ( myinfo->expiration != 0 && (myinfo->IAMLP != 0 || myinfo->DEXactive > now) )
basilisk_requests_poll(myinfo); basilisk_requests_poll(myinfo);
} }*/
} }
void basilisks_loop(void *arg) void basilisks_loop(void *arg)
@ -967,9 +979,9 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
if ( jobj(vals,"history") == 0 ) if ( jobj(vals,"history") == 0 )
jaddnum(vals,"history",3); jaddnum(vals,"history",3);
if ( jobj(vals,"fanout") == 0 ) if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(vals,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
if ( jobj(vals,"numrequired") == 0 ) if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",juint(vals,"fanout")); jaddnum(vals,"numrequired",MIN(juint(vals,"fanout")/2,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)));
if ( jobj(vals,"addresses") == 0 ) if ( jobj(vals,"addresses") == 0 )
{ {
jadd(vals,"addresses",iguana_getaddressesbyaccount(myinfo,coin,"*")); jadd(vals,"addresses",iguana_getaddressesbyaccount(myinfo,coin,"*"));
@ -978,7 +990,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
if ( (basilisktag= juint(vals,"basilisktag")) == 0 ) if ( (basilisktag= juint(vals,"basilisktag")) == 0 )
basilisktag = rand(); basilisktag = rand();
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 ) if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )
timeoutmillis = 3000; timeoutmillis = BASILISK_TIMEOUT;
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 ) if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
@ -986,7 +998,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
if ( (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) if ( (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 )
{ {
retstr = ptr->retstr, ptr->retstr = 0; retstr = ptr->retstr, ptr->retstr = 0;
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
return(retstr); return(retstr);
} }
return(clonestr("{\"error\":\"no result\"}")); return(clonestr("{\"error\":\"no result\"}"));

6
basilisk/basilisk.h

@ -20,7 +20,7 @@
#include "../iguana/iguana777.h" #include "../iguana/iguana777.h"
#define BASILISK_TIMEOUT 5000 #define BASILISK_TIMEOUT 15000
#define BASILISK_MINFANOUT 8 #define BASILISK_MINFANOUT 8
#define BASILISK_MAXFANOUT 64 #define BASILISK_MAXFANOUT 64
#define BASILISK_DEFAULTDIFF 0x1effffff #define BASILISK_DEFAULTDIFF 0x1effffff
@ -76,8 +76,8 @@ struct basilisk_value { bits256 txid; int64_t value; int32_t height; int16_t vou
struct basilisk_item struct basilisk_item
{ {
struct queueitem DL; UT_hash_handle hh; struct queueitem DL; UT_hash_handle hh;
double expiration; cJSON *retarray; double expiration,finished; cJSON *results[64];
uint32_t submit,finished,basilisktag,numresults,numsent,numrequired,nBits; uint32_t submit,basilisktag,numresults,numsent,numrequired,nBits,duration;
char symbol[32],CMD[4],remoteaddr[64],*retstr; char symbol[32],CMD[4],remoteaddr[64],*retstr;
}; };

8
basilisk/basilisk_CMD.c

@ -206,7 +206,7 @@ char *basilisk_respond_VPNmessage(struct supernet_info *myinfo,char *CMD,void *a
if ( coin != 0 && (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 ) if ( coin != 0 && (ptr= basilisk_bitcoinrawtx(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 )
{ {
retstr = ptr->retstr; retstr = ptr->retstr;
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
} else retstr = clonestr("{\"error\":\"no coin specified or error bitcoinrawtx\"}"); } else retstr = clonestr("{\"error\":\"no coin specified or error bitcoinrawtx\"}");
return(retstr); return(retstr);
}*/ }*/
@ -220,7 +220,7 @@ char *basilisk_respond_value(struct supernet_info *myinfo,char *CMD,void *addr,c
if ( coin != 0 && (ptr= basilisk_bitcoinvalue(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 ) if ( coin != 0 && (ptr= basilisk_bitcoinvalue(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 )
{ {
retstr = ptr->retstr; retstr = ptr->retstr;
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
} else retstr = clonestr("{\"error\":\"no coin specified or error bitcoin value\"}"); } else retstr = clonestr("{\"error\":\"no coin specified or error bitcoin value\"}");
return(retstr); return(retstr);
} }
@ -234,7 +234,7 @@ char *basilisk_respond_balances(struct supernet_info *myinfo,char *CMD,void *add
if ( coin != 0 && (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 ) if ( coin != 0 && (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 )
{ {
retstr = ptr->retstr; retstr = ptr->retstr;
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
} else retstr = clonestr("{\"error\":\"no coin specified or error bitcoin balances\"}"); } else retstr = clonestr("{\"error\":\"no coin specified or error bitcoin balances\"}");
return(retstr); return(retstr);
} }
@ -249,7 +249,7 @@ char *basilisk_respond_getinfo(struct supernet_info *myinfo,char *CMD,void *addr
if ( coin != 0 && (ptr= basilisk_getinfo(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 ) if ( coin != 0 && (ptr= basilisk_getinfo(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,valsobj)) != 0 )
{ {
retstr = ptr->retstr; retstr = ptr->retstr;
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
} else retstr = clonestr("{\"error\":\"no coin specified or error bitcoin getinfo\"}"); } else retstr = clonestr("{\"error\":\"no coin specified or error bitcoin getinfo\"}");
return(retstr); return(retstr);
} }

2
basilisk/basilisk_MSG.c

@ -341,7 +341,7 @@ cJSON *basilisk_channelget(struct supernet_info *myinfo,bits256 srchash,bits256
msgid = (uint32_t)time(NULL); msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"msgid",msgid); jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"width",width); jaddnum(valsobj,"width",width);
jaddnum(valsobj,"timeout",3000); jaddnum(valsobj,"timeout",BASILISK_TIMEOUT);
jaddnum(valsobj,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(valsobj,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
jaddnum(valsobj,"numrequired",1); jaddnum(valsobj,"numrequired",1);
jaddbits256(valsobj,"srchash",srchash); jaddbits256(valsobj,"srchash",srchash);

4
basilisk/basilisk_bitcoin.c

@ -842,7 +842,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
if ( coin->FULLNODE != 0 && (ptr= basilisk_bitcoinvalue(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 ) if ( coin->FULLNODE != 0 && (ptr= basilisk_bitcoinvalue(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 )
{ {
retstr = ptr->retstr, ptr->retstr = 0; retstr = ptr->retstr, ptr->retstr = 0;
ptr->finished = (uint32_t)time(NULL); ptr->finished = OS_milliseconds() + 10000;
return(retstr); return(retstr);
} }
} }
@ -862,7 +862,7 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
if ( jobj(vals,"numrequired") == 0 ) if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",MIN(3,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(vals,"numrequired",MIN(3,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
if ( jobj(vals,"fanout") == 0 ) if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",MIN(3,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(vals,"fanout",MAX(3,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
if ( coin != 0 ) if ( coin != 0 )
{ {
//if ( juint(vals,"burn") == 0 ) //if ( juint(vals,"burn") == 0 )

2
basilisk/basilisk_tradebot.c

@ -251,7 +251,7 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req
if ( (hexdata= get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr)) != 0 ) if ( (hexdata= get_dataptr(0,&allocptr,&hexlen,hexspace,sizeof(hexspace),hexstr)) != 0 )
{ {
basilisk_rwDEXquote(0,hexdata,&R); basilisk_rwDEXquote(0,hexdata,&R);
printf("[%d].(%s)\n",i,jprint(basilisk_requestjson(&R),1)); //printf("[%d].(%s)\n",i,jprint(basilisk_requestjson(&R),1));
} }
} else basilisk_parsejson(&R,item); } else basilisk_parsejson(&R,item);
if ( nonz != 0 ) if ( nonz != 0 )

5
iguana/iguana777.c

@ -854,6 +854,11 @@ void iguana_coinloop(void *arg)
{ {
if ( (coin= coins[i]) != 0 ) if ( (coin= coins[i]) != 0 )
{ {
if ( strcmp(coin->symbol,"NOTARY") == 0 )
{
if ( myinfo->expiration != 0 && (myinfo->IAMLP != 0 || myinfo->DEXactive > now) )
basilisk_requests_poll(myinfo);
}
if ( n > 1 && coin->RTheight > 0 && (rand() % 10) != 0 ) if ( n > 1 && coin->RTheight > 0 && (rand() % 10) != 0 )
continue; continue;
if ( coin->peers == 0 ) if ( coin->peers == 0 )

4
iguana/iguana_unspents.c

@ -1039,8 +1039,8 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi
jaddstr(vals,"coin",coin->symbol); jaddstr(vals,"coin",coin->symbol);
jaddnum(vals,"history",1); jaddnum(vals,"history",1);
jaddnum(vals,"firstheight",0); jaddnum(vals,"firstheight",0);
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(vals,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
jaddnum(vals,"numrequired",MAX(5,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1)); jaddnum(vals,"numrequired",MIN(4,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+1));
jadd(vals,"addresses",jduplicate(argarray)); jadd(vals,"addresses",jduplicate(argarray));
if ( (retstr= basilisk_standardservice("BAL",myinfo,0,hash,vals,"",1)) != 0 ) if ( (retstr= basilisk_standardservice("BAL",myinfo,0,hash,vals,"",1)) != 0 )
{ {

4
iguana/iguana_wallet.c

@ -1196,12 +1196,12 @@ ZERO_ARGS(bitcoinrpc,getinfo)
} }
else else
{ {
free(ptr->retstr); ptr->finished = OS_milliseconds();
return(jprint(array,1)); return(jprint(array,1));
} }
free_json(array); free_json(array);
} }
free(ptr->retstr); ptr->finished = OS_milliseconds();
if ( getinfoobj != 0 ) if ( getinfoobj != 0 )
return(jprint(getinfoobj,1)); return(jprint(getinfoobj,1));
} }

12
iguana/pnacl/Release/iguana.nmf

@ -0,0 +1,12 @@
{
"program": {
"portable": {
"pnacl-translate": {
"url": "iguana.pexe"
},
"pnacl-debug": {
"url": "iguana_unstripped.bc"
}
}
}
}

1
includes/iguana_funcs.h

@ -565,6 +565,7 @@ int32_t iguana_opreturn(struct supernet_info *myinfo,int32_t ordered,struct igua
int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen); int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen);
struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits); struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]); int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
void basilisk_requests_poll(struct supernet_info *myinfo);
void iguana_RTreset(struct iguana_info *coin); void iguana_RTreset(struct iguana_info *coin);
void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight); void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight);

Loading…
Cancel
Save