Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
e56a1a886f
  1. 7
      basilisk/basilisk.c
  2. 21
      basilisk/basilisk_MSG.c
  3. 4
      iguana/iguana_rpc.c

7
basilisk/basilisk.c

@ -276,6 +276,7 @@ void basilisk_sendback(struct supernet_info *myinfo,char *origCMD,char *symbol,c
jaddstr(valsobj,"symbol",symbol); jaddstr(valsobj,"symbol",symbol);
if ( myinfo->ipaddr[0] != 0 ) if ( myinfo->ipaddr[0] != 0 )
jaddstr(valsobj,"relay",myinfo->ipaddr); jaddstr(valsobj,"relay",myinfo->ipaddr);
jaddnum(valsobj,"timestamp",(uint32_t)time(NULL));
if ( (virt= iguana_coinfind(symbol)) != 0 ) if ( (virt= iguana_coinfind(symbol)) != 0 )
{ {
jaddnum(valsobj,"hwm",virt->blocks.hwmchain.height); jaddnum(valsobj,"hwm",virt->blocks.hwmchain.height);
@ -355,7 +356,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,struc
jaddbits256(valsobj,"hash",hash); jaddbits256(valsobj,"hash",hash);
} }
if ( (numrequired= jint(valsobj,"numrequired")) <= 0 ) if ( (numrequired= jint(valsobj,"numrequired")) <= 0 )
numrequired = 1; numrequired = sqrt(NUMRELAYS);
if ( (timeoutmillis= jint(valsobj,"timeout")) == 0 ) if ( (timeoutmillis= jint(valsobj,"timeout")) == 0 )
timeoutmillis = BASILISK_TIMEOUT; timeoutmillis = BASILISK_TIMEOUT;
minfanout = sqrt(NUMRELAYS)+1; minfanout = sqrt(NUMRELAYS)+1;
@ -686,7 +687,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
hash = jbits256(valsobj,"hash"); hash = jbits256(valsobj,"hash");
timeoutmillis = jint(valsobj,"timeout"); timeoutmillis = jint(valsobj,"timeout");
if ( (numrequired= jint(valsobj,"numrequired")) == 0 ) if ( (numrequired= jint(valsobj,"numrequired")) == 0 )
numrequired = 1; numrequired = sqrt(NUMRELAYS);
if ( senderipbits != 0 ) if ( senderipbits != 0 )
expand_ipbits(remoteaddr,senderipbits); expand_ipbits(remoteaddr,senderipbits);
else remoteaddr[0] = 0; else remoteaddr[0] = 0;
@ -889,7 +890,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
if ( jobj(vals,"fanout") == 0 ) if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+1); jaddnum(vals,"fanout",(int32_t)sqrt(NUMRELAYS)+1);
if ( jobj(vals,"numrequired") == 0 ) if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",NUMRELAYS); jaddnum(vals,"numrequired",sqrt(NUMRELAYS));
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( jobj(vals,"addresses") == 0 ) if ( jobj(vals,"addresses") == 0 )

21
basilisk/basilisk_MSG.c

@ -49,7 +49,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
cJSON *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=0,*msgjson; struct basilisk_message *msg; char *ptr = 0,strbuf[32768]; cJSON *msgjson; struct basilisk_message *msg; char *ptr = 0,strbuf[32768];
portable_mutex_lock(&myinfo->messagemutex); portable_mutex_lock(&myinfo->messagemutex);
HASH_FIND(hh,myinfo->messagetable,key,keylen,msg); HASH_FIND(hh,myinfo->messagetable,key,keylen,msg);
if ( msg != 0 ) if ( msg != 0 )
@ -57,11 +57,10 @@ cJSON *basilisk_respond_getmessage(struct supernet_info *myinfo,uint8_t *key,int
msgjson = cJSON_CreateObject(); msgjson = cJSON_CreateObject();
if ( basilisk_addhexstr(&ptr,msgjson,strbuf,sizeof(strbuf),msg->data,msg->datalen) != 0 ) if ( basilisk_addhexstr(&ptr,msgjson,strbuf,sizeof(strbuf),msg->data,msg->datalen) != 0 )
{ {
retjson = cJSON_CreateObject(); //retjson = cJSON_CreateObject();
jadd(retjson,"message",msgjson); jaddnum(msgjson,"expiration",msg->expiration);
jaddnum(retjson,"expiration",msg->expiration); jaddnum(msgjson,"duration",msg->duration);
jaddnum(retjson,"duration",msg->duration); //jadd(retjson,"message",msgjson);
jaddstr(retjson,"result","success");
printf("havemessage len.%d\n",msg->datalen); printf("havemessage len.%d\n",msg->datalen);
} }
else else
@ -69,10 +68,11 @@ cJSON *basilisk_respond_getmessage(struct supernet_info *myinfo,uint8_t *key,int
//jaddstr(retjson,"error","couldnt add message"); //jaddstr(retjson,"error","couldnt add message");
printf("couldnt add message\n"); printf("couldnt add message\n");
free_json(msgjson); free_json(msgjson);
msgjson = 0;
} }
} }
portable_mutex_unlock(&myinfo->messagemutex); portable_mutex_unlock(&myinfo->messagemutex);
return(retjson); return(msgjson);
} }
// respond to incoming OUT, MSG // respond to incoming OUT, MSG
@ -163,10 +163,15 @@ char *basilisk_respond_MSG(struct supernet_info *myinfo,char *CMD,void *addr,cha
HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr) HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr)
{ {
uint32_t msgid,width,channel; uint32_t msgid,width,channel;
if ( (msgid= juint(vals,"msgid")) == 0 )
{
msgid = (uint32_t)time(NULL);
jdelete(vals,"msgid");
jaddnum(vals,"msgid",msgid);
}
if ( RELAYID >= 0 ) if ( RELAYID >= 0 )
{ {
channel = juint(vals,"channel"); channel = juint(vals,"channel");
msgid = juint(vals,"msgid");
width = juint(vals,"width"); width = juint(vals,"width");
return(basilisk_iterate_MSG(myinfo,channel,msgid,hash,myinfo->myaddr.persistent,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)); } else return(basilisk_standardservice("MSG",myinfo,0,myinfo->myaddr.persistent,vals,hexstr,1));

4
iguana/iguana_rpc.c

@ -844,7 +844,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz
n += i; n += i;
j = i = 0; j = i = 0;
filetype[0] = 0; filetype[0] = 0;
printf("url.(%s) method.(%s)\n",&url[i],urlmethod); //printf("url.(%s) method.(%s)\n",&url[i],urlmethod);
#ifdef __PNACL__ #ifdef __PNACL__
snprintf(furl,sizeof(furl),"%s/%s",GLOBAL_DBDIR,url+1); snprintf(furl,sizeof(furl),"%s/%s",GLOBAL_DBDIR,url+1);
#else #else
@ -1180,7 +1180,7 @@ void iguana_rpcloop(void *args)
if ( retstr != 0 ) if ( retstr != 0 )
{ {
char *response,hdrs[1024]; char *response,hdrs[1024];
printf("RETURN.(%s)\n",retstr); //printf("RETURN.(%s)\n",retstr);
if ( jsonflag != 0 || postflag != 0 ) if ( jsonflag != 0 || postflag != 0 )
{ {
response = malloc(strlen(retstr)+1024+1+1); response = malloc(strlen(retstr)+1024+1+1);

Loading…
Cancel
Save