Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
0a80721012
  1. 45
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk.h
  3. 32
      basilisk/basilisk_CMD.c
  4. 6
      basilisk/basilisk_bitcoin.c
  5. 2
      gecko/gecko.c
  6. 4
      gecko/gecko_blocks.c
  7. 2
      gecko/gecko_headers.c
  8. 2
      gecko/gecko_miner.c
  9. 2
      includes/iguana_funcs.h

45
basilisk/basilisk.c

@ -269,7 +269,7 @@ void basilisk_sendback(struct supernet_info *myinfo,char *origCMD,char *symbol,c
}
}
struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t *numsentp,char *CMD,char *symbol,int32_t blockflag,cJSON *valsobj,int32_t fanout,int32_t minresults,uint32_t basilisktag,int32_t timeoutmillis,void *_metricfunc,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 minresults,uint32_t basilisktag,int32_t timeoutmillis,void *_metricfunc,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;
pending = basilisk_itemcreate(myinfo,CMD,symbol,basilisktag,minresults,valsobj,timeoutmillis,0);
@ -283,7 +283,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t
else
{
data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag);
*numsentp = pending->numsent = basilisk_sendcmd(myinfo,0,CMD,&pending->basilisktag,encryptflag,delaymillis,data,datalen,1,pending->nBits);
*numsentp = pending->numsent = basilisk_sendcmd(myinfo,addr != 0 ? addr->ipaddr : 0,CMD,&pending->basilisktag,encryptflag,delaymillis,data,datalen,1,pending->nBits);
if ( blockflag != 0 )
{
portable_mutex_lock(&myinfo->basilisk_mutex);
@ -316,7 +316,7 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t
return(pending);
}
struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char *CMD,int32_t blockflag,cJSON *valsobj,bits256 hash,uint8_t *data,int32_t datalen,uint32_t nBits)
struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struct iguana_peer *addr,char *CMD,int32_t blockflag,cJSON *valsobj,bits256 hash,uint8_t *data,int32_t datalen,uint32_t nBits)
{
int32_t minresults,timeoutmillis,numsent,delaymillis,encryptflag,fanout; struct basilisk_item *ptr; char buf[4096],*symbol,*str = 0; struct iguana_info *virt;
basilisk_addhexstr(&str,valsobj,buf,sizeof(buf),data,datalen);
@ -346,15 +346,15 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char
symbol = "BTCD";
encryptflag = jint(valsobj,"encrypt");
delaymillis = jint(valsobj,"delay");
ptr = basilisk_issueremote(myinfo,&numsent,CMD,symbol,blockflag,valsobj,fanout,minresults,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits);
ptr = basilisk_issueremote(myinfo,addr,&numsent,CMD,symbol,blockflag,valsobj,fanout,minresults,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits);
return(ptr);
}
char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,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[8192],*allocptr=0,*data = 0; struct basilisk_item *ptr; int32_t datalen = 0; cJSON *retjson; char *retstr=0;
data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr);
ptr = basilisk_requestservice(myinfo,CMD,blockflag,valsobj,hash,data,datalen,nBits);
ptr = basilisk_requestservice(myinfo,_addr,CMD,blockflag,valsobj,hash,data,datalen,nBits);
if ( allocptr != 0 )
free(allocptr);
if ( ptr != 0 )
@ -436,7 +436,7 @@ int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *vi
{
vals = cJSON_CreateObject();
jaddstr(vals,"symbol",virt->symbol);
if ( (retstr= basilisk_standardservice(CMD,myinfo,hash,vals,hexstr,0)) != 0 )
if ( (retstr= basilisk_standardservice(CMD,myinfo,addr,hash,vals,hexstr,0)) != 0 )
free(retstr);
free_json(vals);
if ( allocptr != 0 )
@ -589,9 +589,25 @@ int32_t basilisk_relays_ping(struct supernet_info *myinfo,uint8_t *data,int32_t
return(datalen);
}
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; char str[65],strbuf[8192],*blockstr,*allocptr = 0;
hash2 = iguana_blockhash(virt,height);
if ( (blocklen= iguana_peerblockrequest(virt,virt->blockspace,IGUANA_MAXPACKETSIZE,0,hash2,0)) > 0 )
{
printf("RELAYID.%d send block.%d -> (%s)\n",myinfo->RELAYID,blocklen,addr->ipaddr);
blockstr = basilisk_addhexstr(&allocptr,0,strbuf,sizeof(strbuf),&virt->blockspace[sizeof(struct iguana_msghdr)],blocklen);
basilisk_blocksubmit(myinfo,btcd,virt,addr,blockstr,virt->blocks.hwmchain.RO.hash2,height);
if ( allocptr != 0 )
free(allocptr);
return(0);
} else printf("blocklen.%d for hwm.%d height.%d %s\n",blocklen,virt->blocks.hwmchain.height,height,bits256_str(str,virt->blocks.hwmchain.RO.hash2));
return(-1);
}
void basilisk_respond_ping(struct supernet_info *myinfo,struct iguana_peer *addr,uint32_t senderipbits,uint8_t *data,int32_t datalen)
{
int32_t diff,i,n,blocklen,len = 0; struct iguana_info *btcd,*virt; char ipbuf[64],symbol[7],str[65]; struct basilisk_relay *rp; uint8_t numrelays; uint32_t numvirts,height,now = (uint32_t)time(NULL);
int32_t diff,i,n,len = 0; struct iguana_info *btcd,*virt; char ipbuf[64],symbol[7]; struct basilisk_relay *rp; uint8_t numrelays; uint32_t numvirts,height,now = (uint32_t)time(NULL);
expand_ipbits(ipbuf,senderipbits);
btcd = iguana_coinfind("BTCD");
for (i=0; i<myinfo->numrelays; i++)
@ -617,17 +633,10 @@ void basilisk_respond_ping(struct supernet_info *myinfo,struct iguana_peer *addr
memcpy(symbol,&data[len],6), len += 6;
len += iguana_rwvarint32(0,&data[len],&height);
printf("(%s %d).%p ",symbol,height,addr);
if ( myinfo->numrelays > 0 && addr != 0 && (virt= iguana_coinfind(symbol)) != 0 && virt->blocks.hwmchain.height > height && (height % myinfo->numrelays) == myinfo->RELAYID )
if ( myinfo->numrelays > 0 && addr != 0 && (virt= iguana_coinfind(symbol)) != 0 )
{
if ( (blocklen= iguana_peerblockrequest(virt,virt->blockspace,IGUANA_MAXPACKETSIZE,0,virt->blocks.hwmchain.RO.hash2,0)) > 0 )
{
char strbuf[8192],*blockstr,*allocptr = 0;
printf("RELAYID.%d send block.%d -> (%s)\n",myinfo->RELAYID,blocklen,addr->ipaddr);
blockstr = basilisk_addhexstr(&allocptr,0,strbuf,sizeof(strbuf),&virt->blockspace[sizeof(struct iguana_msghdr)],blocklen);
basilisk_blocksubmit(myinfo,btcd,virt,blockstr,virt->blocks.hwmchain.RO.hash2,height);
if ( allocptr != 0 )
free(allocptr);
} else printf("blocklen.%d for hwm.%d height.%d %s\n",blocklen,virt->blocks.hwmchain.height,height,bits256_str(str,virt->blocks.hwmchain.RO.hash2));
if ( virt->blocks.hwmchain.height > height && (height % myinfo->numrelays) == myinfo->RELAYID )
basilisk_blocksend(myinfo,btcd,virt,addr,height);
}
}
for (i=0; i<datalen; i++)

2
basilisk/basilisk.h

@ -69,7 +69,7 @@ uint8_t *SuperNET_ciphercalc(void **ptrp,int32_t *cipherlenp,bits256 *privkeyp,b
void *SuperNET_deciphercalc(void **ptrp,int32_t *msglenp,bits256 privkey,bits256 srcpubkey,uint8_t *cipher,int32_t cipherlen,uint8_t *buf,int32_t bufsize);
uint8_t *get_dataptr(int32_t hdroffset,uint8_t **ptrp,int32_t *datalenp,uint8_t *space,int32_t spacesize,char *hexstr);
char *basilisk_addhexstr(char **ptrp,cJSON *valsobj,char *strbuf,int32_t strsize,uint8_t *data,int32_t datalen);
char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,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
char *basilisk_respond_mempool(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_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint32_t ipbits,bits256 pubkey);

32
basilisk/basilisk_CMD.c

@ -120,7 +120,7 @@ void basilisk_request_goodbye(struct supernet_info *myinfo)
{
cJSON *valsobj = cJSON_CreateObject();
jaddnum(valsobj,"timeout",-1);
basilisk_requestservice(myinfo,"BYE",0,valsobj,GENESIS_PUBKEY,0,0,0);
basilisk_requestservice(myinfo,0,"BYE",0,valsobj,GENESIS_PUBKEY,0,0,0);
free_json(valsobj);
}
@ -212,13 +212,13 @@ char *basilisk_respond_balances(struct supernet_info *myinfo,char *CMD,void *add
HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
{
return(basilisk_standardservice("BAL",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("BAL",myinfo,0,hash,vals,hexstr,1));
//return(basilisk_standardcmd(myinfo,"BAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_balances,coin->basilisk_balancesmetric));
}
HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr)
{
return(basilisk_standardservice("VAL",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("VAL",myinfo,0,hash,vals,hexstr,1));
//return(basilisk_standardcmd(myinfo,"VAL",activecoin,remoteaddr,basilisktag,vals,coin->basilisk_value,coin->basilisk_valuemetric));
}
@ -247,67 +247,67 @@ HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr)
HASH_ARRAY_STRING(basilisk,addrelay,hash,vals,hexstr)
{
return(basilisk_standardservice("ADD",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("ADD",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,relays,hash,vals,hexstr)
{
return(basilisk_standardservice("RLY",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("RLY",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,dispatch,hash,vals,hexstr)
{
return(basilisk_standardservice("RUN",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("RUN",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,publish,hash,vals,hexstr)
{
return(basilisk_standardservice("PUB",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("PUB",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,subscribe,hash,vals,hexstr)
{
return(basilisk_standardservice("SUB",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("SUB",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,forward,hash,vals,hexstr)
{
return(basilisk_standardservice("HOP",myinfo,hash,vals,hexstr,0));
return(basilisk_standardservice("HOP",myinfo,0,hash,vals,hexstr,0));
}
HASH_ARRAY_STRING(basilisk,mailbox,hash,vals,hexstr)
{
return(basilisk_standardservice("BOX",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("BOX",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,VPNcreate,hash,vals,hexstr)
{
return(basilisk_standardservice("VPN",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("VPN",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,VPNjoin,hash,vals,hexstr)
{
return(basilisk_standardservice("ARC",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("ARC",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,VPNmessage,hash,vals,hexstr)
{
return(basilisk_standardservice("GAB",myinfo,hash,vals,hexstr,0));
return(basilisk_standardservice("GAB",myinfo,0,hash,vals,hexstr,0));
}
HASH_ARRAY_STRING(basilisk,VPNbroadcast,hash,vals,hexstr)
{
return(basilisk_standardservice("SAY",myinfo,hash,vals,hexstr,0));
return(basilisk_standardservice("SAY",myinfo,0,hash,vals,hexstr,0));
}
HASH_ARRAY_STRING(basilisk,VPNreceive,hash,vals,hexstr)
{
return(basilisk_standardservice("EAR",myinfo,hash,vals,hexstr,1));
return(basilisk_standardservice("EAR",myinfo,0,hash,vals,hexstr,1));
}
HASH_ARRAY_STRING(basilisk,VPNlogout,hash,vals,hexstr)
{
return(basilisk_standardservice("END",myinfo,hash,vals,hexstr,0));
return(basilisk_standardservice("END",myinfo,0,hash,vals,hexstr,0));
}
uint16_t basilisk_portavailable(struct supernet_info *myinfo,uint16_t port)

6
basilisk/basilisk_bitcoin.c

@ -360,14 +360,14 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
if ( v->vout == vout && bits256_cmp(txid,v->txid) == 0 && strcmp(v->coinaddr,coinaddr) == 0 )
{
printf("bitcoinvalue local ht.%d %s %.8f\n",v->height,v->coinaddr,dstr(v->value));
ptr = basilisk_issueremote(myinfo,&numsent,"VAL",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,basilisk_valuestr(coin,v->coinaddr,v->value,v->height,txid,vout),0,0,BASILISK_DEFAULTDIFF);
ptr = basilisk_issueremote(myinfo,0,&numsent,"VAL",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,basilisk_valuestr(coin,v->coinaddr,v->value,v->height,txid,vout),0,0,BASILISK_DEFAULTDIFF);
//queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0);
return(ptr);
}
}
}
printf("bitcoinvalue issue remote tag.%u\n",basilisktag);
ptr = basilisk_issueremote(myinfo,&numsent,"VAL",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,0,0,0,BASILISK_DEFAULTDIFF);
ptr = basilisk_issueremote(myinfo,0,&numsent,"VAL",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,0,0,0,BASILISK_DEFAULTDIFF);
//queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0);
return(ptr);
}
@ -644,6 +644,6 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi
Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx\"}");
return(Lptr);
}
return(basilisk_issueremote(myinfo,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_rawtxmetric,0,0,0,BASILISK_DEFAULTDIFF));
return(basilisk_issueremote(myinfo,0,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_rawtxmetric,0,0,0,BASILISK_DEFAULTDIFF));
}

2
gecko/gecko.c

@ -282,7 +282,7 @@ char *gecko_sendrawtransaction(struct supernet_info *myinfo,char *symbol,uint8_t
retstr = basilisk_respond_geckotx(myinfo,"GTX",0,0,0,vals,data,datalen,txid,0);
}
if ( retstr == 0 )
retstr = basilisk_standardservice("GTX",myinfo,txid,vals,signedtx,1);
retstr = basilisk_standardservice("GTX",myinfo,0,txid,vals,signedtx,1);
return(retstr);
}

4
gecko/gecko_blocks.c

@ -305,7 +305,7 @@ char *basilisk_respond_geckoblock(struct supernet_info *myinfo,char *CMD,void *a
return(0);
}
int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2,int32_t height)
int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,struct iguana_peer *addr,char *blockstr,bits256 hash2,int32_t height)
{
int32_t i,datalen,num,numerrs,numresults=0; uint8_t *data,space[16384],*allocptr; cJSON *valsobj=0,*retjson,*retarray,*item; char *str,*str2,*othercoin; bits256 othertip;
//printf("blocksubmit.(%s)\n",blockstr);
@ -323,7 +323,7 @@ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *bt
jaddnum(valsobj,"fanout",-1);
jaddnum(valsobj,"height",height);
jaddstr(valsobj,"symbol",virt->symbol);
if ( (str2= basilisk_standardservice("BLK",myinfo,hash2,valsobj,blockstr,0)) != 0 )
if ( (str2= basilisk_standardservice("BLK",myinfo,addr,hash2,valsobj,blockstr,0)) != 0 )
{
if ( 0 && (retarray= cJSON_Parse(str2)) != 0 )
{

2
gecko/gecko_headers.c

@ -96,7 +96,7 @@ void gecko_requesthdrs(struct supernet_info *myinfo,struct iguana_info *virt,int
memset(zero.bytes,0,sizeof(zero));
jaddstr(vals,"symbol",virt->symbol);
jaddstr(vals,"type","HDR");
if ( (retstr= basilisk_standardservice("GET",myinfo,bp->hashes[0],vals,0,0)) != 0 )
if ( (retstr= basilisk_standardservice("GET",myinfo,0,bp->hashes[0],vals,0,0)) != 0 )
free(retstr);
free_json(vals);
} else printf("dont have bundle needed\n");

2
gecko/gecko_miner.c

@ -320,7 +320,7 @@ int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,
//printf("submit.(%s)\n",blockstr);
if ( (peers= virt->peers) == 0 || (numranked= peers->numranked) <= 0 )
{
if ( basilisk_blocksubmit(myinfo,btcd,virt,blockstr,hash2,height) < 0 )//(myinfo->numrelays >> 1) )
if ( basilisk_blocksubmit(myinfo,btcd,virt,0,blockstr,hash2,height) < 0 )//(myinfo->numrelays >> 1) )
return(-1);
}
else // physical node for geckochain

2
includes/iguana_funcs.h

@ -490,7 +490,7 @@ void iguana_blockzcopy(uint8_t zcash,struct iguana_block *dest,struct iguana_blo
int32_t iguana_blocksizecheck(char *debugstr,uint8_t zcash,struct iguana_block *block);
void basilisk_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,char *mineraddr);
int32_t bitcoin_pubkeyspend(uint8_t *script,int32_t n,uint8_t pubkey[66]);
int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2,int32_t height);
int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,struct iguana_peer *addr,char *blockstr,bits256 hash2,int32_t height);
struct supernet_info *SuperNET_MYINFO(char *passphrase);
bits256 calc_categoryhashes(bits256 *subhashp,char *category,char *subcategory);
struct gecko_chain *category_find(bits256 categoryhash,bits256 subhash);

Loading…
Cancel
Save