Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
62aadf9c03
  1. 64
      basilisk/basilisk.c
  2. 10
      basilisk/basilisk.h
  3. 181
      basilisk/basilisk_DEX.c
  4. 238
      basilisk/basilisk_MSG.c
  5. 8
      basilisk/basilisk_bitcoin.c
  6. 92
      basilisk/basilisk_ping.c
  7. 56
      basilisk/basilisk_swap.c
  8. 63
      deprecated/obsolete.h
  9. 6
      gecko/gecko.c
  10. 2
      gecko/gecko_blocks.c
  11. 6
      gecko/gecko_delayedPoW.c
  12. 2
      gecko/gecko_mempool.c
  13. 2
      iguana/coins/genbtc
  14. 12
      iguana/iguana777.c
  15. 2
      iguana/iguana777.h
  16. 4
      iguana/iguana_accept.c
  17. 6
      iguana/iguana_init.c
  18. 6
      iguana/iguana_msg.c
  19. 4
      iguana/iguana_payments.c
  20. 2
      iguana/iguana_peers.c
  21. 2
      iguana/iguana_spendvectors.c
  22. 2
      iguana/iguana_unspents.c
  23. 2
      includes/iguana_apideclares.h
  24. 2
      includes/iguana_structs.h

64
basilisk/basilisk.c

@ -19,17 +19,18 @@ typedef char *basilisk_servicefunc(struct supernet_info *myinfo,char *CMD,void *
int32_t basilisk_specialcmd(char *cmd)
{
if ( strcmp(cmd,"PIN") != 0 && strcmp(cmd,"DEX") != 0 && strcmp(cmd,"ACC") != 0 && strcmp(cmd,"RID") != 0 && strcmp(cmd,"OUT") != 0 && strcmp(cmd,"MSG") != 0 )
//&& strcmp(cmd,"DEX") != 0 && strcmp(cmd,"ACC") != 0 && strcmp(cmd,"RID") != 0 &&
if ( strcmp(cmd,"PIN") != 0 && strcmp(cmd,"OUT") != 0 && strcmp(cmd,"MSG") != 0 )
return(0);
else return(1);
}
int32_t basilisk_specialrelay_CMD(char *CMD)
/*int32_t basilisk_specialrelay_CMD(char *CMD)
{
if ( strcmp(CMD,"OUT") == 0 || strcmp(CMD,"MSG") == 0 || strcmp(CMD,"BLK") == 0 || strcmp(CMD,"MEM") == 0 || strcmp(CMD,"GTX") == 0 || strcmp(CMD,"RID") == 0 )
return(1);
else return(0);
}
}*/
uint32_t basilisk_calcnonce(struct supernet_info *myinfo,uint8_t *data,int32_t datalen,uint32_t nBits)
{
@ -187,7 +188,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
{
if ( coin->peers == 0 )
continue;
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
cmd[0] = 's';
else cmd[0] = 'S';
r = rand() % (coin->peers->numranked+1);
@ -568,27 +569,13 @@ void basilisk_wait(struct supernet_info *myinfo,struct iguana_info *coin)
void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t senderipbits,char *type,uint32_t basilisktag,uint8_t *data,int32_t datalen)
{
cJSON *valsobj; char *symbol,*retstr=0,remoteaddr[64],CMD[4],cmd[4],origcmd[4]; int32_t height,origlen,from_basilisk,i,timeoutmillis,flag,numrequired,jsonlen; uint8_t *origdata; struct iguana_info *coin=0; bits256 hash; struct iguana_peer *addr = _addr;
cJSON *valsobj; char *symbol,*retstr=0,remoteaddr[64],CMD[4],cmd[4]; int32_t height,origlen,from_basilisk,i,timeoutmillis,flag,numrequired,jsonlen; uint8_t *origdata; struct iguana_info *coin=0; bits256 hash; struct iguana_peer *addr = _addr;
static basilisk_servicefunc *basilisk_services[][2] =
{
{ (void *)"OUT", &basilisk_respond_OUT }, // send MSG to hash/id/num
{ (void *)"MSG", &basilisk_respond_MSG }, // get MSG (hash, id, num)
{ (void *)"DEX", &basilisk_respond_DEX },
{ (void *)"RID", &basilisk_respond_RID },
{ (void *)"ACC", &basilisk_respond_ACC },
{ (void *)"BYE", &basilisk_respond_goodbye }, // disconnect
// gecko chains
{ (void *)"GET", &basilisk_respond_geckoget }, // requests headers, block or tx
{ (void *)"HDR", &basilisk_respond_geckoheaders }, // reports headers
{ (void *)"BLK", &basilisk_respond_geckoblock }, // reports virtchain block
{ (void *)"MEM", &basilisk_respond_mempool }, // reports virtchain mempool
{ (void *)"GTX", &basilisk_respond_geckotx }, // reports virtchain tx
{ (void *)"ADD", &basilisk_respond_addrelay }, // relays register with each other bus
{ (void *)"OUT", &basilisk_respond_OUT }, // send MSG to hash/id/num
{ (void *)"MSG", &basilisk_respond_MSG }, // get MSG (hash, id, num)
{ (void *)"ADD", &basilisk_respond_addrelay }, // relays register with each other bus
//{ (void *)"PIN", &basilisk_respond_PIN },
// encrypted data for jumblr
{ (void *)"HOP", &basilisk_respond_forward }, // message forwarding
{ (void *)"BOX", &basilisk_respond_mailbox }, // create/send/check mailbox pubkey
@ -601,6 +588,18 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{ (void *)"EAR", &basilisk_respond_VPNreceive }, // network receive (via poll)
{ (void *)"END", &basilisk_respond_VPNlogout }, // logout
//{ (void *)"DEX", &basilisk_respond_DEX },
//{ (void *)"RID", &basilisk_respond_RID },
//{ (void *)"ACC", &basilisk_respond_ACC },
{ (void *)"BYE", &basilisk_respond_goodbye }, // disconnect
// gecko chains
{ (void *)"GET", &basilisk_respond_geckoget }, // requests headers, block or tx
{ (void *)"HDR", &basilisk_respond_geckoheaders }, // reports headers
{ (void *)"BLK", &basilisk_respond_geckoblock }, // reports virtchain block
{ (void *)"MEM", &basilisk_respond_mempool }, // reports virtchain mempool
{ (void *)"GTX", &basilisk_respond_geckotx }, // reports virtchain tx
// coin services
{ (void *)"VAL", &basilisk_respond_value },
{ (void *)"BAL", &basilisk_respond_balances },
@ -616,18 +615,12 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
CMD[i] = toupper((int32_t)CMD[i]);
cmd[i] = tolower((int32_t)CMD[i]);
}
origcmd[0] = 0;
//origcmd[0] = 0;
if ( myinfo->RELAYID >= 0 )
{
printf("MSGPROCESS %s.(%s) tag.%d\n",CMD,(char *)data,basilisktag);
if ( basilisk_specialcmd(CMD) == 0 )
return;
else if ( strcmp(CMD,"OUT") != 0 && strcmp(CMD,"MSG") != 0 )
{
printf("origcmd.(%s)\n",CMD);
strcpy(origcmd,CMD);
strcpy(CMD,"OUT");
}
}
symbol = "BTCD";
if ( senderipbits == 0 )
@ -635,8 +628,8 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
else expand_ipbits(remoteaddr,senderipbits);
if ( (valsobj= cJSON_Parse((char *)data)) != 0 )
{
if ( origcmd[0] != 0 )
jaddstr(valsobj,"origcmd",origcmd);
//if ( origcmd[0] != 0 )
// jaddstr(valsobj,"origcmd",origcmd);
//printf("MSGVALS.(%s)\n",(char *)data);
if ( jobj(valsobj,"coin") != 0 )
coin = iguana_coinfind(jstr(valsobj,"coin"));
@ -696,7 +689,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{
if ( strcmp((char *)basilisk_services[i][0],type) == 0 )
{
//if ( coin->RELAYNODE != 0 ) // iguana node
if ( coin->FULLNODE != 0 ) // iguana node
{
//printf("services %s\n",type);
if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 )
@ -708,8 +701,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
free(retstr);
break;
} else printf("services null return\n");
}
//else printf("non-relay got unhandled.(%s)\n",type);
} else printf("non-relay got unhandled.(%s)\n",type);
}
}
free_json(valsobj);
@ -903,7 +895,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
basilisktag = rand();
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )
timeoutmillis = BASILISK_TIMEOUT;
if ( (coin->RELAYNODE != 0 || coin->VALIDATENODE != 0) && (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 )
if ( (coin->FULLNODE != 0 || coin->VALIDATENODE != 0) && (ptr= basilisk_bitcoinbalances(&Lptr,myinfo,coin,remoteaddr,basilisktag,timeoutmillis,vals)) != 0 )
{
retstr = ptr->retstr, ptr->retstr = 0;
ptr->finished = (uint32_t)time(NULL);

10
basilisk/basilisk.h

@ -26,6 +26,7 @@
#define BASILISK_DEFAULTDIFF 0x1effffff
#define BASILISK_MAXRELAYS 64
#define BASILISK_DEXDURATION 180
#define BASILISK_MSGDURATION 60
#define BASILISK_MAXFUTUREBLOCK 60
//#define BASILISK_MAXBLOCKLAG 600
@ -92,7 +93,14 @@ struct basilisk_item
char symbol[32],CMD[4],remoteaddr[64],*retstr;
};
struct basilisk_message { struct queueitem DL; UT_hash_handle hh; uint32_t datalen,expiration; uint8_t key[63],keylen; uint8_t data[]; };
#define BASILISK_KEYSIZE ((int32_t)(2*sizeof(bits256)+sizeof(uint32_t)*2))
struct basilisk_message
{
struct queueitem DL; UT_hash_handle hh;
uint32_t datalen,expiration,duration;
uint8_t key[BASILISK_KEYSIZE],keylen;
uint8_t data[];
};
struct basilisk_info
{

181
basilisk/basilisk_DEX.c

@ -17,6 +17,82 @@
// requestid is invariant for a specific request
// quoteid is invariant for a specific request after dest fields are set
#ifdef ENABLE_DEXPING
int32_t basilisk_ping_processDEX(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen)
{
int32_t i,n,len=0; struct basilisk_relay *relay; struct basilisk_request R; uint8_t clen,serialized[256]; uint16_t sn; uint32_t crc;
portable_mutex_lock(&myinfo->DEX_reqmutex);
len += iguana_rwnum(0,&data[len],sizeof(sn),&sn);
if ( (relay= basilisk_request_ensure(myinfo,senderipbits,sn)) != 0 )
{
relay->numrequests = 0;
for (i=0; i<sn; i++)
{
clen = data[len++];
if ( len+clen <= datalen )
{
if ( relay->numrequests < relay->maxrequests )
{
memcpy(serialized,&data[len],clen);
//printf("ping processDEX\n");
n = basilisk_rwDEXquote(0,serialized,&R);
if ( n != clen )
printf("n.%d clen.%d\n",n,clen);
len += clen;
crc = basilisk_requestid(&R);
if ( crc == R.requestid )
{
relay->requests[relay->numrequests++] = R;
//printf("[(%s %.8f) -> (%s %.8f) r.%u q.%u] ",R.src,dstr(R.srcamount),R.dest,dstr(R.destamount),R.requestid,R.quoteid);
} else printf("crc.%u error vs %u\n",crc,R.requestid);
} else printf("relay num.%d >= max.%d\n",relay->numrequests,relay->maxrequests);
} else len += clen;
}
}
else
{
for (i=0; i<sn; i++)
{
if ( len+clen <= datalen )
{
clen = data[len++];
len += clen;
}
}
}
portable_mutex_unlock(&myinfo->DEX_reqmutex);
return(len);
}
int32_t basilisk_ping_genDEX(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen)
{
struct queueitem *item,*tmp; uint8_t clen; int32_t i,datalen = 0; uint16_t sn; uint32_t timestamp,now;
datalen += sizeof(uint16_t);
i = 0;
now = (uint32_t)time(NULL);
portable_mutex_lock(&myinfo->DEX_mutex);
DL_FOREACH_SAFE(myinfo->DEX_quotes,item,tmp)
{
memcpy(&clen,&item[1],sizeof(clen));
if ( datalen+clen < maxlen )
{
memcpy(&data[datalen],&item[1],clen+1), datalen += (clen + 1);
i++;
}
iguana_rwnum(0,(void *)((long)&item[1] + 1 + sizeof(uint32_t)),sizeof(timestamp),&timestamp);
if ( now > timestamp + BASILISK_DEXDURATION )
{
DL_DELETE(myinfo->DEX_quotes,item);
free(item);
} //else printf("now.%u vs timestamp.%u, lag.%d\n",now,timestamp,now-timestamp);
}
portable_mutex_unlock(&myinfo->DEX_mutex);
sn = i;
iguana_rwnum(1,data,sizeof(sn),&sn); // fill in at beginning
return(datalen);
}
#endif
int32_t basilisk_rwDEXquote(int32_t rwflag,uint8_t *serialized,struct basilisk_request *rp)
{
int32_t len = 0;
@ -181,80 +257,6 @@ struct basilisk_relay *basilisk_request_ensure(struct supernet_info *myinfo,uint
return(relay);
}
int32_t basilisk_ping_processDEX(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen)
{
int32_t i,n,len=0; struct basilisk_relay *relay; struct basilisk_request R; uint8_t clen,serialized[256]; uint16_t sn; uint32_t crc;
portable_mutex_lock(&myinfo->DEX_reqmutex);
len += iguana_rwnum(0,&data[len],sizeof(sn),&sn);
if ( (relay= basilisk_request_ensure(myinfo,senderipbits,sn)) != 0 )
{
relay->numrequests = 0;
for (i=0; i<sn; i++)
{
clen = data[len++];
if ( len+clen <= datalen )
{
if ( relay->numrequests < relay->maxrequests )
{
memcpy(serialized,&data[len],clen);
//printf("ping processDEX\n");
n = basilisk_rwDEXquote(0,serialized,&R);
if ( n != clen )
printf("n.%d clen.%d\n",n,clen);
len += clen;
crc = basilisk_requestid(&R);
if ( crc == R.requestid )
{
relay->requests[relay->numrequests++] = R;
//printf("[(%s %.8f) -> (%s %.8f) r.%u q.%u] ",R.src,dstr(R.srcamount),R.dest,dstr(R.destamount),R.requestid,R.quoteid);
} else printf("crc.%u error vs %u\n",crc,R.requestid);
} else printf("relay num.%d >= max.%d\n",relay->numrequests,relay->maxrequests);
} else len += clen;
}
}
else
{
for (i=0; i<sn; i++)
{
if ( len+clen <= datalen )
{
clen = data[len++];
len += clen;
}
}
}
portable_mutex_unlock(&myinfo->DEX_reqmutex);
return(len);
}
int32_t basilisk_ping_genDEX(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen)
{
struct queueitem *item,*tmp; uint8_t clen; int32_t i,datalen = 0; uint16_t sn; uint32_t timestamp,now;
datalen += sizeof(uint16_t);
i = 0;
now = (uint32_t)time(NULL);
portable_mutex_lock(&myinfo->DEX_mutex);
DL_FOREACH_SAFE(myinfo->DEX_quotes,item,tmp)
{
memcpy(&clen,&item[1],sizeof(clen));
if ( datalen+clen < maxlen )
{
memcpy(&data[datalen],&item[1],clen+1), datalen += (clen + 1);
i++;
}
iguana_rwnum(0,(void *)((long)&item[1] + 1 + sizeof(uint32_t)),sizeof(timestamp),&timestamp);
if ( now > timestamp + BASILISK_DEXDURATION )
{
DL_DELETE(myinfo->DEX_quotes,item);
free(item);
} //else printf("now.%u vs timestamp.%u, lag.%d\n",now,timestamp,now-timestamp);
}
portable_mutex_unlock(&myinfo->DEX_mutex);
sn = i;
iguana_rwnum(1,data,sizeof(sn),&sn); // fill in at beginning
return(datalen);
}
static int _cmp_requests(const void *a,const void *b)
{
#define uint32_a (*(struct basilisk_request *)a).requestid
@ -311,14 +313,14 @@ struct basilisk_request *_basilisk_requests_uniq(struct supernet_info *myinfo,in
return(requests);
}
char *basilisk_respond_swapstatus(struct supernet_info *myinfo,bits256 hash,uint32_t requestid,uint32_t quoteid)
/*char *basilisk_respond_swapstatus(struct supernet_info *myinfo,bits256 hash,uint32_t requestid,uint32_t quoteid)
{
cJSON *array,*retjson;
array = cJSON_CreateArray();
retjson = cJSON_CreateObject();
jadd(retjson,"result",array);
return(jprint(retjson,1));
}
}*/
char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32_t requestid,uint32_t quoteid)
{
@ -373,14 +375,14 @@ char *basilisk_respond_accept(struct supernet_info *myinfo,uint32_t requestid,ui
// respond to incoming RID, ACC, DEX, QST
char *basilisk_respond_RID(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
/*char *basilisk_respond_RID(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
return(basilisk_respond_requests(myinfo,hash,juint(valsobj,"requestid"),0));
}
char *basilisk_respond_SWP(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
return(basilisk_respond_swapstatus(myinfo,hash,juint(valsobj,"requestid"),juint(valsobj,"quoteid")));
return(basilisk_respond_swapstatus(myinfo,hash,juint(valsobj,"requestid"),juint(valsobj,"quoteid")));
}
char *basilisk_respond_ACC(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
@ -404,7 +406,7 @@ char *basilisk_respond_DEX(struct supernet_info *myinfo,char *CMD,void *addr,cha
} else retstr = clonestr("{\"error\":\"DEX quote couldnt be created\"}");
} else retstr = clonestr("{\"error\":\"missing or invalid fields\"}");
return(retstr);
}
}*/
#include "../includes/iguana_apidefs.h"
#include "../includes/iguana_apideclares.h"
@ -432,7 +434,7 @@ ZERO_ARGS(InstantDEX,allcoins)
{
if ( coin->virtualchain != 0 )
jaddistr(virtual,coin->symbol);
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
jaddistr(full,coin->symbol);
else jaddistr(basilisk,coin->symbol);
}
@ -454,6 +456,7 @@ STRING_ARG(InstantDEX,available,source)
HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
{
uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson; uint32_t datalen=0,DEX_channel;
myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME;
jadd64bits(vals,"minamount",jdouble(vals,"minprice") * jdouble(vals,"amount") * SATOSHIDEN);
if ( jobj(vals,"desthash") == 0 )
@ -464,7 +467,6 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
hash = myinfo->myaddr.persistent;
printf("service.(%s)\n",jprint(vals,0));
{
uint8_t serialized[512]; struct basilisk_request R; cJSON *reqjson;
memset(&R,0,sizeof(R));
if ( basilisk_request_create(&R,vals,hash,juint(vals,"timestamp")) == 0 )
{
@ -474,11 +476,20 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
if ( (reqjson= basilisk_requestjson(&R)) != 0 )
free_json(reqjson);
printf("R.requestid.%u vs calc %u, q.%u\n",R.requestid,basilisk_requestid(&R),R.quoteid);
basilisk_rwDEXquote(1,serialized,&R);
datalen = basilisk_rwDEXquote(1,serialized,&R);
basilisk_rwDEXquote(0,serialized,&R);
} else printf("error creating request\n");
}
return(basilisk_standardservice("DEX",myinfo,0,myinfo->myaddr.persistent,vals,"",1));
free_json(vals);
if ( datalen > 0 )
{
memset(hash.bytes,0,sizeof(hash));
DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);
if ( basilisk_channelsend(myinfo,hash,DEX_channel,(uint32_t)time(NULL),serialized,datalen,30) > 0 )
return(clonestr("{\"result\":\"DEX message sent\"}"));
}
return(clonestr("{\"error\":\"DEX message not sent\"}"));
//return(basilisk_standardservice("DEX",myinfo,0,myinfo->myaddr.persistent,vals,"",1));
}
INT_ARG(InstantDEX,automatched,requestid)
@ -505,7 +516,7 @@ INT_ARG(InstantDEX,incoming,requestid)
}
}
TWO_INTS(InstantDEX,swapstatus,requestid,quoteid)
/*TWO_INTS(InstantDEX,swapstatus,requestid,quoteid)
{
cJSON *vals; char *retstr;
myinfo->DEXactive = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME;
@ -521,7 +532,7 @@ TWO_INTS(InstantDEX,swapstatus,requestid,quoteid)
free_json(vals);
return(retstr);
}
}
}*/
TWO_INTS(InstantDEX,accept,requestid,quoteid)
{

238
basilisk/basilisk_MSG.c

@ -15,13 +15,18 @@
// included from basilisk.c
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping)
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration)
{
struct basilisk_message *msg;
if ( keylen == sizeof(bits256)+sizeof(uint32_t)*2 )
if ( keylen == BASILISK_KEYSIZE )
{
msg = calloc(1,sizeof(*msg) + datalen);
msg->expiration = (uint32_t)time(NULL) + INSTANTDEX_LOCKTIME*2;
if ( duration == 0 )
duration = BASILISK_MSGDURATION;
else if ( duration > INSTANTDEX_LOCKTIME*2 )
duration = INSTANTDEX_LOCKTIME*2;
msg->duration = duration;
msg->expiration = (uint32_t)time(NULL) + duration;
msg->keylen = keylen;
memcpy(msg->key,key,keylen);
msg->datalen = datalen;
@ -37,69 +42,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
} else return(0);
}
int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen)
{
int32_t i,msglen,len=0; uint8_t num,keylen,*msg,*key;
if ( (num= data[len++]) > 0 )
{
printf("processMSG num.%d datalen.%d\n",num,datalen);
for (i=0; i<num; i++)
{
keylen = data[len++];
if ( keylen != sizeof(bits256)+sizeof(uint32_t)*2 )
{
printf("invalid keylen.%d != %d\n",keylen,(int32_t)(sizeof(bits256)+sizeof(uint32_t)*2));
return(0);
}
key = &data[len], len += keylen;
if ( len+sizeof(msglen) > datalen )
{
printf("processMSG overflow len.%d msglen.%d %d > %d\n",len,msglen,(int32_t)(len+sizeof(msglen)),datalen);
return(0);
}
len += iguana_rwnum(0,&data[len],sizeof(msglen),&msglen);
msg = &data[len], len += msglen;
if ( msglen <= 0 || len > datalen )
{
printf("illegal msglen.%d or len.%d > %d\n",msglen,len,datalen);
return(0);
}
printf("i.%d: keylen.%d msglen.%d\n",i,keylen,msglen);
basilisk_respond_addmessage(myinfo,key,keylen,msg,msglen,0);
}
}
return(len);
}
int32_t basilisk_ping_genMSG(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen)
{
struct basilisk_message *msg; int32_t datalen = 0;
if ( maxlen > sizeof(msg->key) && (msg= queue_dequeue(&myinfo->msgQ,0)) != 0 ) // oneshot ping
{
data[datalen++] = 1;
data[datalen++] = msg->keylen;
memcpy(&data[datalen],msg->key,msg->keylen), datalen += msg->keylen;
datalen += iguana_rwnum(1,&data[datalen],sizeof(msg->datalen),&msg->datalen);
if ( maxlen > datalen+msg->datalen )
{
printf("SEND keylen.%d msglen.%d\n",msg->keylen,msg->datalen);
memcpy(&data[datalen],msg->data,msg->datalen), datalen += msg->datalen;
}
else
{
printf("basilisk_ping_genMSG message doesnt fit %d vs %d\n",maxlen,datalen+msg->datalen);
datalen = 0;
}
//printf("\n-> ");
//int32_t i;
//for (i=0; i<datalen; i++)
// printf("%02x",data[i]);
//printf(" <- genMSG\n");
} else data[datalen++] = 0;
return(datalen);
}
char *basilisk_respond_getmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen)
cJSON *basilisk_respond_getmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen)
{
cJSON *retjson,*msgjson; struct basilisk_message *msg; char *ptr = 0,strbuf[32768];
retjson = cJSON_CreateObject();
@ -111,64 +54,90 @@ char *basilisk_respond_getmessage(struct supernet_info *myinfo,uint8_t *key,int3
if ( basilisk_addhexstr(&ptr,msgjson,strbuf,sizeof(strbuf),msg->data,msg->datalen) != 0 )
{
jadd(retjson,"message",msgjson);
jaddnum(retjson,"expiration",msg->expiration);
jaddnum(retjson,"duration",msg->duration);
jaddstr(retjson,"result","success");
printf("havemessage len.%d\n",msg->datalen);
} else jaddstr(retjson,"error","couldnt add message");
} else jaddstr(retjson,"error","no message");
portable_mutex_unlock(&myinfo->messagemutex);
return(jprint(retjson,1));
return(retjson);
}
// respond to incoming OUT, MSG
int32_t basilisk_messagekey(uint8_t *key,bits256 hash,cJSON *valsobj)
int32_t basilisk_messagekey(uint8_t *key,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash)
{
uint32_t channel,msgid; int32_t keylen = 0;
channel = juint(valsobj,"channel");
msgid = juint(valsobj,"msgid");
keylen += iguana_rwbignum(1,&key[keylen],sizeof(hash),hash.bytes);
int32_t keylen = 0;
keylen += iguana_rwnum(1,&key[keylen],sizeof(uint32_t),&channel);
keylen += iguana_rwnum(1,&key[keylen],sizeof(uint32_t),&msgid);
keylen += iguana_rwbignum(1,&key[keylen],sizeof(srchash),srchash.bytes);
keylen += iguana_rwbignum(1,&key[keylen],sizeof(desthash),desthash.bytes);
return(keylen);
}
uint32_t basilisk_msgid(struct supernet_info *myinfo,uint32_t channel,bits256 hash,uint8_t *data,int32_t datalen)
char *basilisk_respond_OUT(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
bits256 msghash; int32_t msgid = 0;
vcalc_sha256(0,msghash.bytes,data,datalen);
if ( bits256_nonz(hash) == 0 ) // broadcast
{
// find msghash and return its ind, or allocate new one
}
else
{
// check against most recent small n for hash, return ind or allocate new one
}
return(msgid);
int32_t keylen,duration; uint8_t key[BASILISK_KEYSIZE]; bits256 senderhash;
senderhash = jbits256(valsobj,"sender");
duration = juint(valsobj,"duration");
keylen = basilisk_messagekey(key,juint(valsobj,"channel"),juint(valsobj,"msgid"),senderhash,hash);
if( bits256_nonz(senderhash) == 0 && bits256_nonz(hash) == 0 && duration > BASILISK_MSGDURATION )
duration = BASILISK_MSGDURATION;
printf("OUT keylen.%d datalen.%d\n",keylen,datalen);
//char str[65]; printf("add message.[%d] channel.%u msgid.%x %s\n",datalen,juint(valsobj,"channel"),juint(valsobj,"msgid"),bits256_str(str,hash));
return(basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,1,duration));
}
char *basilisk_respond_OUT(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash,int32_t width)
{
int32_t keylen; uint8_t key[64]; char *origcmd; uint32_t channel,msgid;
if ( (origcmd= jstr(valsobj,"origcmd")) != 0 && strlen(origcmd) == 3 )
uint8_t key[BASILISK_KEYSIZE]; int32_t i,keylen; cJSON *item,*array; bits256 zero;
memset(zero.bytes,0,sizeof(zero));
array = cJSON_CreateArray();
if ( width > 3600 )
width = 3600;
else if ( width < 1 )
width = 1;
for (i=0; i<width; i++)
{
channel = origcmd[0] + ((uint32_t)origcmd[1] << 8) + ((uint32_t)origcmd[2] << 16);
msgid = basilisk_msgid(myinfo,channel,hash,data,datalen);
jaddnum(valsobj,"channel",channel);
jaddnum(valsobj,"msgid",msgid);
} else origcmd = "";
keylen = basilisk_messagekey(key,hash,valsobj);
printf("OUT orig.(%s) keylen.%d datalen.%d\n",origcmd,keylen,datalen);
//char str[65]; printf("add message.[%d] channel.%u msgid.%x %s\n",datalen,juint(valsobj,"channel"),juint(valsobj,"msgid"),bits256_str(str,hash));
return(basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,1));
keylen = basilisk_messagekey(key,channel,msgid,srchash,desthash);
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
if ( width > 0 )
{
if ( bits256_nonz(srchash) != 0 )
{
keylen = basilisk_messagekey(key,channel,msgid,zero,desthash);
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
}
if ( bits256_nonz(desthash) != 0 )
{
keylen = basilisk_messagekey(key,channel,msgid,srchash,zero);
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
}
if ( bits256_nonz(srchash) != 0 || bits256_nonz(desthash) != 0 )
{
keylen = basilisk_messagekey(key,channel,msgid,zero,zero);
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item);
}
}
msgid--;
iguana_rwnum(1,&key[0],sizeof(uint32_t),&msgid);
}
return(jprint(array,1));
}
char *basilisk_respond_MSG(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
int32_t keylen; uint8_t key[64];
keylen = basilisk_messagekey(key,hash,valsobj);
//char str[65]; printf("%s channel.%u msgid.%x datalen.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),juint(valsobj,"msgid"),datalen);
return(basilisk_respond_getmessage(myinfo,key,keylen));
int32_t width; uint32_t msgid,channel;
width = juint(valsobj,"width");
msgid = juint(valsobj,"msgid");
channel = juint(valsobj,"channel");
char str[65]; printf("%s channel.%u msgid.%x datalen.%d width.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),msgid,datalen,width);
return(basilisk_iterate_MSG(myinfo,channel,msgid,jbits256(valsobj,"sender"),hash,width));
}
#include "../includes/iguana_apidefs.h"
@ -176,22 +145,24 @@ char *basilisk_respond_MSG(struct supernet_info *myinfo,char *CMD,void *addr,cha
HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr)
{
int32_t keylen; uint8_t key[64];
uint32_t msgid,width,channel;
if ( myinfo->RELAYID >= 0 )
{
keylen = basilisk_messagekey(key,hash,vals);
return(basilisk_respond_getmessage(myinfo,key,keylen));
channel = juint(vals,"channel");
msgid = juint(vals,"msgid");
width = juint(vals,"width");
return(basilisk_iterate_MSG(myinfo,channel,msgid,hash,myinfo->myaddr.persistent,width));
} else return(basilisk_standardservice("MSG",myinfo,0,myinfo->myaddr.persistent,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
{
int32_t keylen,datalen; uint8_t key[64],space[16384],*data,*ptr = 0; char *retstr=0;
int32_t keylen,datalen; uint8_t key[BASILISK_KEYSIZE],space[16384],*data,*ptr = 0; char *retstr=0;
if ( myinfo->RELAYID >= 0 )
{
keylen = basilisk_messagekey(key,hash,vals);
keylen = basilisk_messagekey(key,juint(vals,"channel"),juint(vals,"msgid"),jbits256(vals,"sender"),hash);
if ( (data= get_dataptr(BASILISK_HDROFFSET,&ptr,&datalen,space,sizeof(space),hexstr)) != 0 )
retstr = basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,0);
retstr = basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,0,juint(vals,"duration"));
if ( ptr != 0 )
free(ptr);
if ( retstr != 0 )
@ -203,14 +174,18 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
}
#include "../includes/iguana_apiundefs.h"
int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen)
int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen,uint32_t duration)
{
char *retstr,*hexstr,strbuf[4096],*ptr = 0; int32_t retval = -1; cJSON *valsobj;
if ( (hexstr= basilisk_addhexstr(&ptr,0,strbuf,sizeof(strbuf),data,datalen)) != 0 )
{
valsobj = cJSON_CreateObject();
jaddnum(valsobj,"channel",channel);
if ( msgid == 0 )
msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"sender",myinfo->myaddr.persistent);
//char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s\n",datalen,channel,msgid,bits256_str(str,hash));
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 )
free(retstr);
@ -241,31 +216,52 @@ int32_t basilisk_message_returned(uint8_t *data,int32_t maxlen,cJSON *item)
return(retval);
}
int32_t basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t maxlen)
cJSON *basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,int32_t width)
{
char *retstr; cJSON *valsobj,*retarray,*item; int32_t i,datalen=0;
char *retstr; cJSON *valsobj,*retarray=0,*item;
valsobj = cJSON_CreateObject();
jaddnum(valsobj,"channel",channel);
if ( msgid == 0 )
msgid = (uint32_t)time(NULL);
jaddnum(valsobj,"msgid",msgid);
jaddnum(valsobj,"width",width);
jaddnum(valsobj,"fanout",1);
if ( (retstr= basilisk_getmessage(myinfo,0,0,0,hash,valsobj,0)) != 0 )
{
//printf("channel.%u msgid.%u gotmessage.(%s)\n",channel,msgid,retstr);
if ( (retarray= cJSON_Parse(retstr)) != 0 )
{
if ( is_cJSON_Array(retarray) != 0 )
if ( is_cJSON_Array(retarray) == 0 )
{
for (i=0; i<cJSON_GetArraySize(retarray); i++)
{
item = jitem(retarray,i);
if ( (datalen= basilisk_message_returned(data,maxlen,item)) > 0 )
break;
}
} else datalen = basilisk_message_returned(data,maxlen,retarray);
free_json(retarray);
} else printf("cant parse message\n");
item = cJSON_CreateArray();
jaddi(item,retarray);
retarray = item;
}
}
free(retstr);
} else printf("null getmessage\n");
}
free_json(valsobj);
return(datalen);
return(retarray);
}
int32_t basilisk_process_retarray(struct supernet_info *myinfo,void *ptr,int32_t (*process_func)(struct supernet_info *myinfo,void *ptr,int32_t (*internal_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen),uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen,uint32_t expiration,uint32_t duration),uint8_t *data,int32_t maxlen,uint32_t channel,uint32_t msgid,cJSON *retarray,int32_t (*internal_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen))
{
cJSON *item; uint32_t duration,expiration; int32_t i,n,datalen,errs = 0;
if ( (n= cJSON_GetArraySize(retarray)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(retarray,i);
if ( (datalen= basilisk_message_returned(data,maxlen,item)) > 0 )
{
duration = juint(item,"duration");
expiration = juint(item,"expiration");
if ( (*process_func)(myinfo,ptr,internal_func,channel,msgid,data,datalen,expiration,duration) < 0 )
errs++;
}
}
}
if ( errs > 0 )
return(-errs);
else return(n);
}

8
basilisk/basilisk_bitcoin.c

@ -290,7 +290,7 @@ int32_t basilisk_bitcoinscan(struct iguana_info *coin,uint8_t origblockspace[IGU
int32_t basilisk_bitcoinavail(struct iguana_info *coin)
{
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 )
if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
return(1);
//else if ( coin->chain->serverport[0] != 0 )
// return(1);
@ -381,7 +381,7 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
vout = jint(valsobj,"vout");
if ( coin != 0 && basilisk_bitcoinavail(coin) != 0 )
{
if ( (coin->VALIDATENODE != 0 || coin->RELAYNODE != 0) )//&& coinaddr != 0 && coinaddr[0] != 0 )
if ( (coin->VALIDATENODE != 0 || coin->FULLNODE != 0) )//&& coinaddr != 0 && coinaddr[0] != 0 )
{
if ( iguana_RTunspentindfind(myinfo,coin,coinaddr,0,0,&value,&height,txid,vout,coin->bundlescount,0) > 0 )
{
@ -798,7 +798,7 @@ HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
basilisktag = rand();
if ( (timeoutmillis= juint(vals,"timeout")) <= 0 )
timeoutmillis = BASILISK_TIMEOUT;
if ( coin->RELAYNODE != 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;
ptr->finished = (uint32_t)time(NULL);
@ -1086,7 +1086,7 @@ void basilisk_relay_unspentsprocess(struct supernet_info *myinfo,struct iguana_i
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin)
{
char *retstr; cJSON *retarray,*vals; int32_t oldest,i,n,RTheight;
//if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
//if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
{
vals = cJSON_CreateObject();
for (i=oldest=0; i<BASILISK_MAXRELAYS; i++)

92
basilisk/basilisk_ping.c

@ -15,15 +15,7 @@
// included from basilisk.c
int32_t baslisk_relay_report(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen,struct basilisk_relaystatus *reported,uint8_t pingdelay)
{
if ( reported != 0 )
{
reported->pingdelay = pingdelay;
}
return(0);
}
#ifdef ENABLE_VIRTPING
int32_t basilisk_blocksend(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,struct iguana_peer *addr,int32_t height)
{
int32_t blocklen; bits256 hash2; uint8_t *data = 0; char str[65],strbuf[4096],*blockstr,*allocptr = 0; struct iguana_block *block;
@ -111,6 +103,71 @@ int32_t basilisk_ping_genvirts(struct supernet_info *myinfo,uint8_t *data,int32_
}
return(datalen);
}
#endif
int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen)
{
int32_t i,msglen,len=0; uint8_t num,keylen,*msg,*key; uint32_t duration;
if ( (num= data[len++]) > 0 )
{
printf("processMSG num.%d datalen.%d\n",num,datalen);
for (i=0; i<num; i++)
{
keylen = data[len++];
if ( keylen != sizeof(bits256)+sizeof(uint32_t)*2 )
{
printf("invalid keylen.%d != %d\n",keylen,(int32_t)(sizeof(bits256)+sizeof(uint32_t)*2));
return(0);
}
key = &data[len], len += keylen;
if ( len+sizeof(msglen) > datalen )
{
printf("processMSG overflow len.%d msglen.%d %d > %d\n",len,msglen,(int32_t)(len+sizeof(msglen)),datalen);
return(0);
}
len += iguana_rwnum(0,&data[len],sizeof(msglen),&msglen);
len += iguana_rwnum(0,&data[len],sizeof(duration),&duration);
msg = &data[len], len += msglen;
if ( msglen <= 0 || len > datalen )
{
printf("illegal msglen.%d or len.%d > %d\n",msglen,len,datalen);
return(0);
}
printf("i.%d: keylen.%d msglen.%d\n",i,keylen,msglen);
basilisk_respond_addmessage(myinfo,key,keylen,msg,msglen,0,duration);
}
}
return(len);
}
int32_t basilisk_ping_genMSG(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen)
{
struct basilisk_message *msg; int32_t datalen = 0;
if ( maxlen > sizeof(msg->key) && (msg= queue_dequeue(&myinfo->msgQ,0)) != 0 ) // oneshot ping
{
data[datalen++] = 1;
data[datalen++] = msg->keylen;
memcpy(&data[datalen],msg->key,msg->keylen), datalen += msg->keylen;
datalen += iguana_rwnum(1,&data[datalen],sizeof(msg->datalen),&msg->datalen);
datalen += iguana_rwnum(1,&data[datalen],sizeof(msg->duration),&msg->duration);
if ( maxlen > datalen+msg->datalen )
{
printf("SEND keylen.%d msglen.%d\n",msg->keylen,msg->datalen);
memcpy(&data[datalen],msg->data,msg->datalen), datalen += msg->datalen;
}
else
{
printf("basilisk_ping_genMSG message doesnt fit %d vs %d\n",maxlen,datalen+msg->datalen);
datalen = 0;
}
//printf("\n-> ");
//int32_t i;
//for (i=0; i<datalen; i++)
// printf("%02x",data[i]);
//printf(" <- genMSG\n");
} else data[datalen++] = 0;
return(datalen);
}
int32_t basilisk_ping_genrelay(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen,struct basilisk_relay *rp)
{
@ -120,6 +177,15 @@ int32_t basilisk_ping_genrelay(struct supernet_info *myinfo,uint8_t *data,int32_
return(datalen);
}
int32_t baslisk_relay_report(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen,struct basilisk_relaystatus *reported,uint8_t pingdelay)
{
if ( reported != 0 )
{
reported->pingdelay = pingdelay;
}
return(0);
}
int32_t basilisk_ping_processrelay(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen,struct basilisk_relay *rp,int32_t i)
{
uint8_t pingdelay; int32_t j,datalen = 0; uint32_t ipbits;
@ -162,7 +228,7 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr
}
}
numrelays = data[len++];
len += basilisk_ping_processvirts(myinfo,btcd,addr,&data[len],datalen - len);
//len += basilisk_ping_processvirts(myinfo,btcd,addr,&data[len],datalen - len);
for (i=0; i<numrelays; i++)
{
if ( len > datalen )
@ -173,7 +239,7 @@ void basilisk_ping_process(struct supernet_info *myinfo,struct iguana_peer *addr
}
if ( len <= datalen-sizeof(sn) )
{
len += basilisk_ping_processDEX(myinfo,senderipbits,&data[len],datalen-len);
//len += basilisk_ping_processDEX(myinfo,senderipbits,&data[len],datalen-len);
len += basilisk_ping_processMSG(myinfo,senderipbits,&data[len],datalen-len);
}
if ( len != datalen )
@ -188,10 +254,10 @@ int32_t basilisk_ping_gen(struct supernet_info *myinfo,uint8_t *data,int32_t max
{
int32_t i,datalen = 0;
data[datalen++] = myinfo->numrelays;
datalen += basilisk_ping_genvirts(myinfo,&data[datalen],maxlen - datalen);
//datalen += basilisk_ping_genvirts(myinfo,&data[datalen],maxlen - datalen);
for (i=0; i<myinfo->numrelays; i++)
datalen += basilisk_ping_genrelay(myinfo,&data[datalen],maxlen - datalen,&myinfo->relays[i]);
datalen += basilisk_ping_genDEX(myinfo,&data[datalen],maxlen - datalen);
//datalen += basilisk_ping_genDEX(myinfo,&data[datalen],maxlen - datalen);
datalen += basilisk_ping_genMSG(myinfo,&data[datalen],maxlen - datalen);
//for (i=0; i<datalen; i++)
// printf("%02x",data[i]);

56
basilisk/basilisk_swap.c

@ -268,8 +268,9 @@ struct basilisk_rawtx *basilisk_swapdata_rawtx(struct supernet_info *myinfo,stru
return(0);
}
int32_t basilisk_verify_otherfee(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_otherfee(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
struct basilisk_swap *swap = ptr;
// add verification
swap->otherfee.txbytes = calloc(1,datalen);
memcpy(swap->otherfee.txbytes,data,datalen);
@ -341,9 +342,9 @@ int32_t basilisk_swapuserdata(uint8_t *userdata,int32_t pushpriv,bits256 privkey
OP_HASH160 <hash(bob_privN)> OP_EQUALVERIFY <bob_pubB0> OP_CHECKSIG
OP_ENDIF*/
int32_t basilisk_verify_bobdeposit(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_bobdeposit(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
uint8_t userdata[512]; int32_t len = 0;
uint8_t userdata[512]; int32_t len = 0; struct basilisk_swap *swap = ptr;
if ( basilisk_rawtx_spendscript(myinfo,swap->bobcoin->blocks.hwmchain.height,&swap->bobdeposit,0,data,datalen,0) == 0 )
{
//len = basilisk_swapuserdata(userdata,0,GENESIS_PRIVKEY,0x02,swap->pubA0,1);
@ -378,9 +379,9 @@ int32_t basilisk_bobpayment_reclaim(struct supernet_info *myinfo,struct basilisk
return(basilisk_rawtx_sign(myinfo,swap->bobcoin->blocks.hwmchain.height,swap,&swap->bobreclaim,&swap->bobpayment,swap->myprivs[1],0,userdata,len));
}
int32_t basilisk_verify_bobpaid(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_bobpaid(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
uint8_t userdata[512]; int32_t len = 0;
uint8_t userdata[512]; int32_t len = 0; struct basilisk_swap *swap = ptr;
if ( basilisk_rawtx_spendscript(myinfo,swap->bobcoin->blocks.hwmchain.height,&swap->bobpayment,0,data,datalen,0) == 0 )
{
len = basilisk_swapuserdata(userdata,1,swap->privAm,0x02,swap->pubA0,0);
@ -395,8 +396,9 @@ int32_t basilisk_alicepayment_spend(struct supernet_info *myinfo,struct basilisk
return(basilisk_rawtx_sign(myinfo,swap->alicecoin->blocks.hwmchain.height,swap,dest,&swap->alicepayment,swap->privAm,&swap->privBn,0,0));
}
int32_t basilisk_verify_alicepaid(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_alicepaid(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
struct basilisk_swap *swap = ptr;
if ( basilisk_rawtx_spendscript(myinfo,swap->alicecoin->blocks.hwmchain.height,&swap->alicepayment,0,data,datalen,0) == 0 )
return(0);
else return(-1);
@ -435,9 +437,9 @@ int32_t basilisk_verify_pubpair(int32_t *wrongfirstbytep,struct basilisk_swap *s
return(0);
}
int32_t basilisk_verify_privi(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
int32_t j,wrongfirstbyte,len = 0; bits256 privkey,pubi; uint8_t secret160[20],pubkey33[33]; uint64_t txid;
int32_t j,wrongfirstbyte,len = 0; bits256 privkey,pubi; uint8_t secret160[20],pubkey33[33]; uint64_t txid; struct basilisk_swap *swap = ptr;
if ( datalen == sizeof(bits256) )
{
for (j=0; j<32; j++)
@ -457,12 +459,23 @@ int32_t basilisk_verify_privi(struct supernet_info *myinfo,struct basilisk_swap
return(-1);
}
int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,int32_t (*basilisk_verify_func)(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen))
int32_t basilisk_process_swapget(struct supernet_info *myinfo,void *ptr,int32_t (*internal_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen),uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen,uint32_t expiration,uint32_t duration)
{
int32_t datalen;
if ( (datalen= basilisk_channelget(myinfo,myinfo->myaddr.persistent,swap->req.quoteid,msgbits,data,maxlen)) > 0 )
return((*basilisk_verify_func)(myinfo,swap,data,datalen));
else return(-1);
struct basilisk_swap *swap = ptr;
return((*internal_func)(myinfo,swap,data,datalen));
}
int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,int32_t (*basilisk_verify_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen))
{
int32_t retval; cJSON *retarray;
if ( (retarray= basilisk_channelget(myinfo,myinfo->myaddr.persistent,swap->req.quoteid,msgbits,0)) != 0 )
{
retval = basilisk_process_retarray(myinfo,swap,basilisk_process_swapget,data,maxlen,swap->req.quoteid,msgbits,retarray,basilisk_verify_func);
if ( retval > 0 )
return(0);
//return((*basilisk_verify_func)(myinfo,swap,data,datalen));
}
return(-1);
}
int32_t basilisk_privBn_extract(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t maxlen)
@ -843,16 +856,17 @@ void basilisk_swap_purge(struct supernet_info *myinfo,struct basilisk_swap *swap
portable_mutex_unlock(&myinfo->DEX_swapmutex);
}
int32_t basilisk_verify_otherstatebits(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_otherstatebits(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
struct basilisk_swap *swap = ptr;
if ( datalen == sizeof(swap->otherstatebits) )
return(iguana_rwnum(0,data,sizeof(swap->otherstatebits),&swap->otherstatebits));
else return(-1);
}
int32_t basilisk_verify_choosei(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_choosei(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
int32_t otherchoosei=-1,i,len = 0;
int32_t otherchoosei=-1,i,len = 0; struct basilisk_swap *swap = ptr;
if ( datalen == sizeof(otherchoosei)+sizeof(bits256)*2 )
{
len += iguana_rwnum(0,data,sizeof(otherchoosei),&otherchoosei);
@ -890,17 +904,17 @@ int32_t basilisk_swapdata_deck(struct supernet_info *myinfo,struct basilisk_swap
return(datalen);
}
int32_t basilisk_verify_otherdeck(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_otherdeck(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
int32_t i,len = 0;
int32_t i,len = 0; struct basilisk_swap *swap = ptr;
for (i=0; i<sizeof(swap->otherdeck)/sizeof(swap->otherdeck[0][0]); i++)
len += iguana_rwnum(0,&data[len],sizeof(swap->otherdeck[i>>1][i&1]),&swap->otherdeck[i>>1][i&1]);
return(0);
}
int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,struct basilisk_swap *swap,uint8_t *data,int32_t datalen)
int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{
int32_t i,j,wrongfirstbyte=0,errs=0,len = 0; bits256 otherpriv,pubi; uint8_t secret160[20],otherpubkey[33]; uint64_t txid;
int32_t i,j,wrongfirstbyte=0,errs=0,len = 0; bits256 otherpriv,pubi; uint8_t secret160[20],otherpubkey[33]; uint64_t txid; struct basilisk_swap *swap = ptr;
printf("verify privkeys choosei.%d otherchoosei.%d datalen.%d vs %d\n",swap->choosei,swap->otherchoosei,datalen,(int32_t)sizeof(swap->privkeys)+20+32);
if ( swap->cutverified == 0 && swap->otherchoosei >= 0 && datalen == sizeof(swap->privkeys)+20+32 )
{
@ -941,7 +955,7 @@ int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,struct basilisk_sw
uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t nextbits)
{
if ( basilisk_channelsend(myinfo,swap->otherhash,swap->req.quoteid,msgbits,data,datalen) == 0 )
if ( basilisk_channelsend(myinfo,swap->otherhash,swap->req.quoteid,msgbits,data,datalen,INSTANTDEX_LOCKTIME*2) == 0 )
return(nextbits);
printf("ERROR basilisk_channelsend\n");
return(0);

63
deprecated/obsolete.h

@ -17181,7 +17181,7 @@ len = 0;
for (i=0; i<n; i++)
{
coinaddr = jstri(addresses,i);
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 )
if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
balancestr = iguana_balance(myinfo,coin,0,remoteaddr,coin->symbol,coinaddr,lastheight,minconf);
//else balancestr = bitcoin_balance(coin,coinaddr,lastheight,minconf);
if ( balancestr != 0 )
@ -17269,7 +17269,7 @@ len = 0;
coin = iguana_coinfind(jstr(valsobj,"coin"));
if ( (method= jstr(valsobj,"method")) != 0 && coin != 0 )
{
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) // iguana node
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 ) // iguana node
{
if ( strcmp(method,"rawtx") == 0 )
retstr = basilisk_rawtx(myinfo,coin,0,remoteaddr,basilisktag,valsobj,coin->symbol);
@ -18009,7 +18009,7 @@ len = 0;
if ( (argjson= gecko_genesisjson(myinfo,btcd,isPoS,symbol,chainname,vals,magicstr,juint(vals,"blocktime"))) != 0 )
{
argvals = gecko_genesisissue(symbol,chainname,chainstr,argjson);
if ( btcd->RELAYNODE != 0 || btcd->VALIDATENODE != 0 )
if ( btcd->FULLNODE != 0 || btcd->VALIDATENODE != 0 )
{
basilisk_wait(myinfo,0);
retstr = basilisk_respond_newgeckochain(myinfo,"NEW",0,0,0,argvals,0,0,GENESIS_PUBKEY,0);
@ -18046,7 +18046,7 @@ len = 0;
arrayB = cJSON_Parse(retstr);
free(retstr);
}
if ( btcd->RELAYNODE != 0 || btcd->VALIDATENODE != 0 )
if ( btcd->FULLNODE != 0 || btcd->VALIDATENODE != 0 )
{
if ( (retstr= OS_filestr(&filesize,"genesis/list")) != 0 )
{
@ -18599,5 +18599,60 @@ len = 0;
free(retstr);
}*/
uint32_t basilisk_msgid(struct supernet_info *myinfo,uint32_t channel,bits256 hash,uint8_t *data,int32_t datalen)
{
struct message_info *mp; bits256 msghash; uint32_t now; int32_t i,j,firstj,firsti = -1;
vcalc_sha256(0,msghash.bytes,data,datalen);
//msghash.bytes[0] = channel & 0xff;
//msghash.bytes[1] = (channel >> 8) & 0xff;
//msghash.bytes[2] = (channel >> 16) & 0xff;
now = (uint32_t)time(NULL);
for (i=0; i<sizeof(myinfo->msgids)/sizeof(*myinfo->msgids); i++)
{
mp = &myinfo->msgids[i];
if ( mp->msgcount != 0 )
{
if ( bits256_cmp(hash,mp->refhash) == 0 )
{
firstj = -1;
for (j=0; j<mp->msgcount; j++)
{
if ( mp->timestamps[j] != 0 )
{
if ( now > mp->timestamps[j]+30 )
memset(mp,0,sizeof(*mp));
else if ( bits256_cmp(msghash,mp->msghashes[j]) == 0 )
return(j + 1);
}
if ( firstj < 0 && mp->timestamps[j] == 0 )
firstj = j;
}
if ( firstj >= 0 )
{
mp->msghashes[firstj] = msghash;
mp->timestamps[firstj] = (uint32_t)time(NULL);
return(firstj + 1);
}
if ( mp->msgcount < sizeof(mp->msghashes)/sizeof(*mp->msghashes) )
{
j = mp->msgcount++;
mp->msghashes[j] = msghash;
mp->timestamps[j] = (uint32_t)time(NULL);
return(j + 1);
} else return(0);
}
} else if ( firsti < 0 )
firsti = i;
}
if ( firsti >= 0 )
{
mp = &myinfo->msgids[firsti];
mp->msghashes[0] = msghash;
mp->timestamps[0] = (uint32_t)time(NULL);
mp->msgcount = 1;
mp->refhash = hash;
return(1);
} else return(0);
}
#endif
#endif

6
gecko/gecko.c

@ -62,7 +62,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
virt->hdrstime = (uint32_t)time(NULL);
}
}
if ( 0 && btcd->RELAYNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
if ( 0 && btcd->FULLNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
{
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);
@ -192,7 +192,7 @@ struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbo
iguana_meminit(&virt->TXMEM,virt->name,0,IGUANA_MAXPACKETSIZE * 2,0);
virt->chain->genesis_hex = clonestr(hexstr);
virt->MAXPEERS = 0;
virt->RELAYNODE = 1;
virt->FULLNODE = 1;
virt->virtualchain = 1;
addr = &virt->internaladdr;
strcpy(virt->VALIDATEDIR,GLOBAL_VALIDATEDIR);
@ -278,7 +278,7 @@ char *gecko_sendrawtransaction(struct supernet_info *myinfo,char *symbol,uint8_t
{
char *retstr = 0; struct iguana_info *virt,*btcd = iguana_coinfind("BTCD");
virt = iguana_coinfind(symbol);
if ( btcd != 0 && (btcd->RELAYNODE != 0 || btcd->VALIDATENODE != 0) )
if ( btcd != 0 && (btcd->FULLNODE != 0 || btcd->VALIDATENODE != 0) )
{
basilisk_wait(myinfo,virt);
retstr = basilisk_respond_geckotx(myinfo,"GTX",0,0,0,vals,data,datalen,txid,0);

2
gecko/gecko_blocks.c

@ -29,7 +29,7 @@ void gecko_txidpurge(struct iguana_info *virt,bits256 txid)
}
}
}
if ( virt->RELAYNODE != 0 )
if ( virt->FULLNODE != 0 )
{
for (i=0; i<BASILISK_MAXRELAYS; i++)
{

6
gecko/gecko_delayedPoW.c

@ -120,7 +120,7 @@ int32_t gecko_hashstampsupdate(struct iguana_info *coin,struct gecko_sequence *s
int32_t gecko_sequpdate(struct supernet_info *myinfo,char *symbol,uint32_t reftimestamp)
{
struct gecko_sequence *seq=0; int32_t max=0,firstpossible=0; struct iguana_info *coin; struct iguana_block *block;
if ( (coin= iguana_coinfind(symbol)) != 0 && (coin->RELAYNODE != 0 || coin->VALIDATENODE != 0) )
if ( (coin= iguana_coinfind(symbol)) != 0 && (coin->FULLNODE != 0 || coin->VALIDATENODE != 0) )
{
if ( strcmp(symbol,"BTCD") == 0 )
{
@ -234,7 +234,7 @@ char *basilisk_respond_hashstamps(struct supernet_info *myinfo,char *CMD,void *a
/*
done = 3;
if ( btcd->RELAYNODE != 0 || btcd->VALIDATENODE != 0 )
if ( btcd->FULLNODE != 0 || btcd->VALIDATENODE != 0 )
{
if ( (now= (uint32_t)time(NULL)) > myinfo->dPOW.SEQ.BTCD.lastupdate+10 )
{
@ -252,7 +252,7 @@ if ( (now= (uint32_t)time(NULL)) > myinfo->dPOW.SEQ.BTC.lastupdate+30 )
if ( done != 3 )
{
valsobj = cJSON_CreateObject();
if ( btcd->RELAYNODE == 0 && btcd->VALIDATENODE == 0 )
if ( btcd->FULLNODE == 0 && btcd->VALIDATENODE == 0 )
{
//fprintf(stderr,"e");
jaddnum(valsobj,"BTCD",myinfo->dPOW.SEQ.BTCD.numstamps+GECKO_FIRSTPOSSIBLEBTCD);

2
gecko/gecko_mempool.c

@ -274,7 +274,7 @@ char *gecko_txarrived(struct supernet_info *myinfo,struct iguana_info *virt,char
char str[65]; printf("add tx.%s to mempool i.%d numtx.%d\n",bits256_str(str,memtx->txid),i,pool->numtx);
for (i=0; i<pool->numtx; i++)
pool->txids[i] = pool->txs[i]->txid;
if ( (btcd= iguana_coinfind("BTCD")) != 0 && btcd->RELAYNODE != 0 && myinfo->IAMRELAY != 0 )
if ( (btcd= iguana_coinfind("BTCD")) != 0 && btcd->FULLNODE != 0 && myinfo->IAMRELAY != 0 )
gecko_mempool_sync(myinfo,virt,pool->txids,pool->numtx);
}
else

2
iguana/coins/genbtc

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}"
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":1,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":12,\"endpend\":1,\"services\":128,\"maxpeers\":512,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":8333}"

12
iguana/iguana777.c

@ -833,7 +833,7 @@ void iguana_coinloop(void *arg)
{
coin->peers->lastmetrics = iguana_updatemetrics(myinfo,coin); // ranks peers
}
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 || coin->MAXPEERS == 1 )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 || coin->MAXPEERS == 1 )
{
portable_mutex_lock(&coin->allcoins_mutex);
flag += iguana_processrecv(myinfo,coin);
@ -970,15 +970,15 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
return(0);
}
if ( jobj(json,"RELAY") != 0 )
coin->RELAYNODE = juint(json,"RELAY");
else coin->RELAYNODE = (strcmp(coin->symbol,"BTCD") == 0);
coin->FULLNODE = juint(json,"RELAY");
else coin->FULLNODE = (strcmp(coin->symbol,"BTCD") == 0);
if ( jobj(json,"VALIDATE") != 0 )
coin->VALIDATENODE = juint(json,"VALIDATE");
else coin->VALIDATENODE = (strcmp(coin->symbol,"BTCD") == 0);
if ( coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 )
if ( coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
SuperNET_MYINFO(0)->IAMRELAY++;
#ifdef __PNACL
coin->VALIDATENODE = coin->RELAYNODE = 0;
coin->VALIDATENODE = coin->FULLNODE = 0;
#endif
if ( jobj(json,"validatedir") != 0 )
safecopy(coin->VALIDATEDIR,jstr(json,"validatedir"),sizeof(coin->VALIDATEDIR));
@ -994,7 +994,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
}
char str[65];
if ( coin->virtualchain == 0 )
printf("pend.(%d -> %d) MAXMEM.%s enablecache.%d VALIDATEDIR.(%s) VALIDATE.%d RELAY.%d\n",coin->startPEND,coin->endPEND,mbstr(str,coin->MAXMEM),coin->enableCACHE,coin->VALIDATEDIR,coin->VALIDATENODE,coin->RELAYNODE);
printf("pend.(%d -> %d) MAXMEM.%s enablecache.%d VALIDATEDIR.(%s) VALIDATE.%d RELAY.%d\n",coin->startPEND,coin->endPEND,mbstr(str,coin->MAXMEM),coin->enableCACHE,coin->VALIDATEDIR,coin->VALIDATENODE,coin->FULLNODE);
return(coin);
}

2
iguana/iguana777.h

@ -55,6 +55,7 @@ struct supernet_address
};
struct liquidity_info { char base[64],rel[64]; double profit,refprice; };
struct message_info { int32_t msgcount; bits256 refhash,msghashes[64]; uint32_t timestamps[64]; };
struct supernet_info
{
@ -85,6 +86,7 @@ struct supernet_info
// compatibility
bits256 pangea_category,instantdex_category;
uint8_t logs[256],exps[510];
struct message_info msgids[8192];
};
#endif

4
iguana/iguana_accept.c

@ -196,7 +196,7 @@ int32_t iguana_process_msgrequestQ(struct supernet_info *myinfo,struct iguana_in
//char str[65]; printf("send type.%d %s -> (%s)\n",msg->type,bits256_str(str,msg->hash2),msg->addr->ipaddr);
if ( msg->type == MSG_BLOCK )
{
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
{
if ( (addr= msg->addr) != 0 && (len= iguana_peerblockrequest(coin,coin->blockspace,(int32_t)(coin->blockspacesize - sizeof(struct iguana_msghdr)),0,msg->hash2,0)) > 0 )
{
@ -207,7 +207,7 @@ int32_t iguana_process_msgrequestQ(struct supernet_info *myinfo,struct iguana_in
}
else if ( msg->type == MSG_TX )
{
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE )
{
if ( (tx= iguana_txidfind(coin,&height,&T,msg->hash2,coin->bundlescount-1)) != 0 )
{

6
iguana/iguana_init.c

@ -248,7 +248,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3
{
int32_t j,k,m,c,flag,bundlei,lastheight,height = -1; char checkstr[1024],line[1024];
struct iguana_peer *addr; struct iguana_bundle *bp; bits256 allhash,hash2,hash1,zero,lastbundle;
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 && iter > 0 )
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 && iter > 0 )
return;
memset(&zero,0,sizeof(zero));
lastbundle = zero;
@ -518,7 +518,7 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
printf("%s MYSERVICES.%llx\n",coin->symbol,(long long)coin->myservices);
if ( coin->virtualchain == 0 && coin->peers != 0 )
{
if ( (coin->myservices & NODE_NETWORK) != 0 || (coin->RELAYNODE != 0 || coin->VALIDATENODE != 0) )
if ( (coin->myservices & NODE_NETWORK) != 0 || (coin->FULLNODE != 0 || coin->VALIDATENODE != 0) )
{
if ( coin->peers->acceptloop == 0 && coin->peers->localaddr == 0 )
{
@ -531,7 +531,7 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
}
}
}
if ( coin->RELAYNODE != 0 && coin->rpcloop == 0 )
if ( coin->FULLNODE != 0 && coin->rpcloop == 0 )
{
myinfo->argport = coin->chain->rpcport;
coin->rpcloop = malloc(sizeof(pthread_t));

6
iguana/iguana_msg.c

@ -354,7 +354,7 @@ int32_t iguana_send_version(struct iguana_info *coin,struct iguana_peer *addr,ui
msg.nServices = (myservices & NODE_NETWORK);
msg.nTime = (int64_t)time(NULL);
msg.nonce = coin->instance_nonce;
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
sprintf(msg.strSubVer,"/iguana 0.00/");
else sprintf(msg.strSubVer,"/basilisk 0.00/");
//printf("SEND.(%s) -> (%s)\n",msg.strSubVer,addr->ipaddr);
@ -373,7 +373,7 @@ int32_t iguana_send_VPNversion(struct iguana_info *coin,struct iguana_peer *addr
msg.nServices = (myservices & NODE_NETWORK);
msg.nTime = (int64_t)time(NULL);
msg.nonce = 0;//coin->instance_nonce;
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
sprintf(msg.strSubVer,"/iguana 0.00/");
else sprintf(msg.strSubVer,"/basilisk 0.00/");
msg.nStartingHeight = coin->blocks.hwmchain.height;
@ -385,7 +385,7 @@ void iguana_supernet_ping(struct supernet_info *myinfo,struct iguana_info *coin,
{
if ( addr->supernet != 0 || addr->basilisk != 0 )
{
//if ( coin->RELAYNODE != 0 )
//if ( coin->FULLNODE != 0 )
// basilisk_relays_send(myinfo,addr);
//printf("send getpeers to %s\n",addr->ipaddr);
//printf("maybe send basilisk ping here?\n");

4
iguana/iguana_payments.c

@ -235,7 +235,7 @@ cJSON *iguana_RTinputsjson(struct supernet_info *myinfo,struct iguana_info *coin
else ind = belowi;
outpt = unspents[ind];
memset(&unspents[ind],0,sizeof(unspents[ind]));
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 )
{
if ( (spendlen= basilisk_unspentfind(myinfo,coin,&txid,&vout,spendscript,outpt,outpt.value)) > 0 )
{
@ -431,7 +431,7 @@ char *iguana_calcrawtx(struct supernet_info *myinfo,struct iguana_info *coin,cJS
void iguana_RTunspentslock(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *vins)
{
struct iguana_outpoint spentpt; char coinaddr[64]; int32_t i,RTspentflag,num,spentheight,lockedflag;
if ( coin->MAXPEERS == 1 || coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
if ( coin->MAXPEERS == 1 || coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
{
num = cJSON_GetArraySize(vins);
for (i=0; i<num; i++)

2
iguana/iguana_peers.c

@ -1133,7 +1133,7 @@ int32_t iguana_peerslotinit(struct iguana_info *coin,struct iguana_peer *addr,in
printf("iguana_peerslotinit cant create.(%s)\n",fname);
return(-1);
}
if ( coin->MAXPEERS == 1 || coin->VALIDATENODE != 0 || coin->RELAYNODE != 0 )
if ( coin->MAXPEERS == 1 || coin->VALIDATENODE != 0 || coin->FULLNODE != 0 )
{
iguana_vinsfname(coin,0,fname,addr->addrind);
if ( (addr->vinsfp= fopen(fname,"rb+")) != 0 )

2
iguana/iguana_spendvectors.c

@ -1096,7 +1096,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp,
static int32_t totalerrs,totalvalidated;
FILE *fp; char fname[1024]; uint8_t *blockspace; //uint32_t now = (uint32_t)time(NULL);
int32_t i,max,len,errs = 0; struct sha256_vstate vstate; bits256 validatehash; int64_t total = 0;
if ( (coin->MAXPEERS > 1 && coin->VALIDATENODE == 0 && coin->RELAYNODE == 0) || bp->ramchain.from_ro != 0 || bp == coin->current )
if ( (coin->MAXPEERS > 1 && coin->VALIDATENODE == 0 && coin->FULLNODE == 0) || bp->ramchain.from_ro != 0 || bp == coin->current )
{
bp->validated = (uint32_t)time(NULL);
return(bp->n);

2
iguana/iguana_unspents.c

@ -832,7 +832,7 @@ int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *
if ( (coinaddr= jstri(addresses,i)) != 0 )
{
//printf("i.%d coinaddr.(%s) minconf.%d longest.%d diff.%d\n",i,coinaddr,minconf,coin->longestchain,coin->blocks.hwmchain.height - minconf);
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
{
numunspents += iguana_RTaddr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,remoteaddr,coin->blocks.hwmchain.height - minconf,0);
}

2
includes/iguana_apideclares.h

@ -32,7 +32,7 @@ INT_ARG(InstantDEX,incoming,requestid);
INT_ARG(InstantDEX,automatched,requestid);
TWO_INTS(InstantDEX,accept,requestid,quoteid);
TWO_INTS(InstantDEX,swapstatus,requestid,quoteid);
//TWO_INTS(InstantDEX,swapstatus,requestid,quoteid);
HASH_ARRAY_STRING(basilisk,genesis_opreturn,hash,vals,hexstr);
HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr);

2
includes/iguana_structs.h

@ -431,7 +431,7 @@ struct iguana_info
uint32_t fastfind; FILE *fastfps[0x100]; uint8_t *fast[0x100]; int32_t *fasttables[0x100]; long fastsizes[0x100];
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles;
int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad;
int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,FULLNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad;
bits256 balancehash,allbundles;
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats,lastinv2,symbolcrc,spendvalidated; char VALIDATEDIR[512];
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy,stuckiters,virtualchain,RTheight;

Loading…
Cancel
Save