jl777 8 years ago
parent
commit
5fa9b71eea
  1. 8
      basilisk/basilisk.c
  2. 22
      basilisk/basilisk_MSG.c

8
basilisk/basilisk.c

@ -169,7 +169,9 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
{
printf("return after locally basilisk_msgprocess\n");
hash = GENESIS_PUBKEY;
portable_mutex_lock(&myinfo->messagemutex);
basilisk_msgprocess(myinfo,0,0,type,*basilisktagp,data,datalen);
portable_mutex_unlock(&myinfo->messagemutex);
return(0);
}
}
@ -795,10 +797,12 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t
len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag);
//int32_t i; for (i=0; i<datalen-len; i++)
// printf("%02x",data[len+i]);
if ( myinfo->IAMLP == 0 )
if ( 0 && myinfo->IAMLP == 0 )
printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,datalen,type,senderip!=0?senderip:"?",basilisktag);
portable_mutex_lock(&myinfo->messagemutex);
basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len);
if ( myinfo->IAMLP == 0 )
portable_mutex_unlock(&myinfo->messagemutex);
if ( 0 && myinfo->IAMLP == 0 )
printf("processed.%s from %s\n",type,senderip!=0?senderip:"?");
}
if ( ptr != 0 )

22
basilisk/basilisk_MSG.c

@ -20,7 +20,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
struct basilisk_message *msg; int32_t i; bits256 desthash;
if ( keylen != BASILISK_KEYSIZE )
return(0);
portable_mutex_lock(&myinfo->messagemutex);
//portable_mutex_lock(&myinfo->messagemutex);
HASH_FIND(hh,myinfo->messagetable,key,keylen,msg);
if ( msg == 0 || msg->datalen != datalen )
{
@ -53,7 +53,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
QUEUEITEMS++;
if ( sendping != 0 )
queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0);
portable_mutex_unlock(&myinfo->messagemutex);
//portable_mutex_unlock(&myinfo->messagemutex);
return(clonestr("{\"result\":\"message added to hashtable\"}"));
}
@ -80,11 +80,11 @@ cJSON *basilisk_msgjson(struct basilisk_message *msg,uint8_t *key,int32_t keylen
cJSON *basilisk_respond_getmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen)
{
cJSON *msgjson = 0; struct basilisk_message *msg;
portable_mutex_lock(&myinfo->messagemutex);
// portable_mutex_lock(&myinfo->messagemutex);
HASH_FIND(hh,myinfo->messagetable,key,keylen,msg);
if ( msg != 0 && msg->broadcast == 0 )
msgjson = basilisk_msgjson(msg,key,keylen);
portable_mutex_unlock(&myinfo->messagemutex);
//portable_mutex_unlock(&myinfo->messagemutex);
return(msgjson);
}
@ -149,7 +149,7 @@ int32_t basilisk_msgcmp(struct basilisk_message *msg,int32_t width,uint32_t chan
char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash,int32_t origwidth)
{
uint8_t key[BASILISK_KEYSIZE]; int32_t allflag,i,keylen,width; cJSON *item,*retjson,*array; bits256 zero; //struct basilisk_message *msg,*tmpmsg;
uint8_t key[BASILISK_KEYSIZE]; int32_t allflag,i,keylen,width; cJSON *item,*retjson,*array; bits256 zero; struct basilisk_message *msg,*tmpmsg;
memset(zero.bytes,0,sizeof(zero));
if ( (width= origwidth) > 3600 )
width = 3600;
@ -157,14 +157,14 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
width = 1;
allflag = (bits256_nonz(srchash) == 0 && bits256_nonz(desthash) == 0);
array = cJSON_CreateArray();
/*portable_mutex_lock(&myinfo->messagemutex);
//portable_mutex_lock(&myinfo->messagemutex);
HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg)
{
if ( allflag != 0 || (msg->broadcast != 0 && basilisk_msgcmp(msg,origwidth,channel,msgid,zero,zero) == 0) )
jaddi(array,basilisk_msgjson(msg,msg->key,msg->keylen));
}
portable_mutex_unlock(&myinfo->messagemutex);*/
printf("iterate_MSG allflag.%d width.%d channel.%d msgid.%d src.%llx -> %llx\n",allflag,origwidth,channel,msgid,(long long)srchash.txid,(long long)desthash.txid);
//portable_mutex_unlock(&myinfo->messagemutex);
//printf("iterate_MSG allflag.%d width.%d channel.%d msgid.%d src.%llx -> %llx\n",allflag,origwidth,channel,msgid,(long long)srchash.txid,(long long)desthash.txid);
for (i=0; i<width; i++)
{
if ( allflag != 0 )
@ -220,9 +220,9 @@ char *basilisk_respond_MSG(struct supernet_info *myinfo,char *CMD,void *addr,cha
width = juint(valsobj,"width");
msgid = juint(valsobj,"msgid");
channel = juint(valsobj,"channel");
char str[65],str2[65]; printf("%s -> %s channel.%u msgid.%x width.%d\n",bits256_str(str,jbits256(valsobj,"sender")),bits256_str(str2,jbits256(valsobj,"desthash")),juint(valsobj,"channel"),msgid,width);
//char str[65],str2[65]; printf("%s -> %s channel.%u msgid.%x width.%d\n",bits256_str(str,jbits256(valsobj,"sender")),bits256_str(str2,jbits256(valsobj,"desthash")),juint(valsobj,"channel"),msgid,width);
retstr = basilisk_iterate_MSG(myinfo,channel,msgid,jbits256(valsobj,"srchash"),jbits256(valsobj,"desthash"),width);
printf("iterate_MSG.(%s)\n",retstr);
//printf("iterate_MSG.(%s)\n",retstr);
return(retstr);
}
@ -285,7 +285,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 srchash,bits25
jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"srchash",srchash);
jaddbits256(valsobj,"desthash",desthash);
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d:%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS,juint(valsobj,"fanout"));
//char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d:%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS,juint(valsobj,"fanout"));
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,desthash,valsobj,hexstr)) != 0 )
free(retstr);
free_json(valsobj);

Loading…
Cancel
Save