Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
1c4bbf282e
  1. 1
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_DEX.c
  3. 10
      basilisk/basilisk_MSG.c
  4. 1
      iguana/tests/send

1
basilisk/basilisk.c

@ -744,6 +744,7 @@ void basilisks_loop(void *arg)
//for (i=0; i<IGUANA_MAXCOINS; i++) //for (i=0; i<IGUANA_MAXCOINS; i++)
// if ( (coin= Coins[i]) != 0 && coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 ) // if ( (coin= Coins[i]) != 0 && coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 && coin->active != 0 && coin->chain->userpass[0] != 0 && coin->MAXPEERS == 1 )
// basilisk_bitcoinscan(coin,blockspace,&RAWMEM); // basilisk_bitcoinscan(coin,blockspace,&RAWMEM);
if ( (rand() % 10) == 0 )
basilisk_requests_poll(myinfo); basilisk_requests_poll(myinfo);
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
portable_mutex_lock(&myinfo->messagemutex); portable_mutex_lock(&myinfo->messagemutex);

2
basilisk/basilisk_DEX.c

@ -327,7 +327,7 @@ char *basilisk_respond_requests(struct supernet_info *myinfo,bits256 hash,uint32
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
rp = &requests[i]; rp = &requests[i];
if ( rp->requestid == requestid && (quoteid == 0 || quoteid == rp->quoteid) && (bits256_cmp(hash,rp->hash) == 0 || bits256_cmp(hash,rp->desthash) == 0) ) if ( (requestid == 0 || rp->requestid == requestid) && (quoteid == 0 || quoteid == rp->quoteid) && (bits256_cmp(hash,rp->hash) == 0 || bits256_cmp(hash,rp->desthash) == 0) )
jaddi(array,basilisk_requestjson(rp->relaybits,rp)); jaddi(array,basilisk_requestjson(rp->relaybits,rp));
} }
} }

10
basilisk/basilisk_MSG.c

@ -38,12 +38,18 @@ int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipb
int32_t i,msglen,len=0; uint8_t num,keylen,*msg,*key; int32_t i,msglen,len=0; uint8_t num,keylen,*msg,*key;
if ( (num= data[len++]) > 0 ) if ( (num= data[len++]) > 0 )
{ {
printf("processMSG num.%d datalen.%d\n",num,datalen);
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
keylen = data[len++]; keylen = data[len++];
key = &data[len], len += keylen; key = &data[len], len += keylen;
if ( len+sizeof(msglen) > datalen )
return(0);
len += iguana_rwnum(0,&data[len],sizeof(msglen),&msglen); len += iguana_rwnum(0,&data[len],sizeof(msglen),&msglen);
msg = &data[len], len += msglen; msg = &data[len], len += msglen;
if ( msglen <= 0 || len > datalen )
return(0);
printf("i.%d: keylen.%d msglen.%d\n",i,keylen,msglen);
basilisk_respond_sendmessage(myinfo,key,keylen,msg,msglen,0); basilisk_respond_sendmessage(myinfo,key,keylen,msg,msglen,0);
} }
} }
@ -60,7 +66,10 @@ int32_t basilisk_ping_genMSG(struct supernet_info *myinfo,uint8_t *data,int32_t
memcpy(&data[datalen],msg->key,msg->keylen), datalen += msg->keylen; memcpy(&data[datalen],msg->key,msg->keylen), datalen += msg->keylen;
iguana_rwnum(1,data,sizeof(msg->datalen),&msg->datalen); iguana_rwnum(1,data,sizeof(msg->datalen),&msg->datalen);
if ( maxlen > 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; memcpy(&data[datalen],msg->data,msg->datalen), datalen += msg->datalen;
}
else else
{ {
printf("basilisk_ping_genMSG message doesnt fit %d vs %d\n",maxlen,datalen+msg->datalen); printf("basilisk_ping_genMSG message doesnt fit %d vs %d\n",maxlen,datalen+msg->datalen);
@ -103,6 +112,7 @@ char *basilisk_respond_OUT(struct supernet_info *myinfo,char *CMD,void *addr,cha
{ {
int32_t keylen; uint8_t key[64]; int32_t keylen; uint8_t key[64];
keylen = basilisk_messagekey(key,hash,valsobj); keylen = basilisk_messagekey(key,hash,valsobj);
printf("keylen.%d datalen.%d\n",keylen,datalen);
return(basilisk_respond_sendmessage(myinfo,key,keylen,data,datalen,1)); return(basilisk_respond_sendmessage(myinfo,key,keylen,data,datalen,1));
} }

1
iguana/tests/send

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"basilisk\",\"method\":\"sendmessage\",\"vals\":{\"channel\":12345,\"msgid\":1},\"hexstr\":\"deadbeef\"}"
Loading…
Cancel
Save