jl777 8 years ago
parent
commit
443e8e4f1c
  1. 2
      basilisk/basilisk.c
  2. 8
      basilisk/basilisk_DEX.c
  3. 10
      basilisk/basilisk_MSG.c

2
basilisk/basilisk.c

@ -844,7 +844,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
//printf("Call incoming\n"); //printf("Call incoming\n");
if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 ) if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 )
{ {
//printf("poll.(%s)\n",retstr); printf("poll.(%s)\n",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
{ {
if ( (outerarray= jarray(&n,retjson,"responses")) != 0 ) if ( (outerarray= jarray(&n,retjson,"responses")) != 0 )

8
basilisk/basilisk_DEX.c

@ -495,10 +495,10 @@ INT_ARG(InstantDEX,automatched,requestid)
int32_t InstantDEX_incoming_func(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen) int32_t InstantDEX_incoming_func(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)
{ {
int32_t i; //int32_t i;
for (i=0; i<datalen; i++) //for (i=0; i<datalen; i++)
printf("%02x",data[i]); // printf("%02x",data[i]);
printf(" <- incoming\n"); //printf(" <- incoming\n");
return(0); return(0);
} }

10
basilisk/basilisk_MSG.c

@ -93,6 +93,7 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
width = 1; width = 1;
allflag = (bits256_nonz(srchash) == 0 && bits256_nonz(desthash) == 0); allflag = (bits256_nonz(srchash) == 0 && bits256_nonz(desthash) == 0);
array = cJSON_CreateArray(); array = cJSON_CreateArray();
fprintf(stderr,"{");
portable_mutex_lock(&myinfo->messagemutex); portable_mutex_lock(&myinfo->messagemutex);
HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg) HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg)
{ {
@ -110,6 +111,7 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
} }
} }
//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); //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);
fprintf(stderr,"[");
for (i=0; i<width; i++) for (i=0; i<width; i++)
{ {
if ( allflag != 0 ) if ( allflag != 0 )
@ -149,7 +151,9 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
} }
msgid--; msgid--;
} }
fprintf(stderr,"]");
portable_mutex_unlock(&myinfo->messagemutex); portable_mutex_unlock(&myinfo->messagemutex);
fprintf(stderr,"}");
if ( cJSON_GetArraySize(array) > 0 ) if ( cJSON_GetArraySize(array) > 0 )
{ {
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
@ -174,7 +178,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
duration = INSTANTDEX_LOCKTIME*2; duration = INSTANTDEX_LOCKTIME*2;
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 || msg->datalen != datalen ) if ( msg == 0 )//|| msg->datalen != datalen )
{ {
if ( msg != 0 ) if ( msg != 0 )
{ {
@ -195,13 +199,13 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
msg->expiration = (uint32_t)time(NULL) + duration; msg->expiration = (uint32_t)time(NULL) + duration;
HASH_ADD_KEYPTR(hh,myinfo->messagetable,msg->key,msg->keylen,msg); HASH_ADD_KEYPTR(hh,myinfo->messagetable,msg->key,msg->keylen,msg);
QUEUEITEMS++; QUEUEITEMS++;
} else memcpy(msg->data,data,datalen);
portable_mutex_unlock(&myinfo->messagemutex);
for (i=0; i<BASILISK_KEYSIZE; i++) for (i=0; i<BASILISK_KEYSIZE; i++)
printf("%02x",key[i]); printf("%02x",key[i]);
printf(" <- ADDMSG.[%d] exp %u %p (%p %p)\n",QUEUEITEMS,msg->expiration,msg,msg->hh.next,msg->hh.prev); printf(" <- ADDMSG.[%d] exp %u %p (%p %p)\n",QUEUEITEMS,msg->expiration,msg,msg->hh.next,msg->hh.prev);
if ( sendping != 0 ) if ( sendping != 0 )
queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0); queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0);
} //else memcpy(msg->data,data,datalen);
portable_mutex_unlock(&myinfo->messagemutex);
return(clonestr("{\"result\":\"message added to hashtable\"}")); return(clonestr("{\"result\":\"message added to hashtable\"}"));
} }

Loading…
Cancel
Save