Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
d549127b06
  1. 11
      basilisk/basilisk_MSG.c
  2. 4
      basilisk/basilisk_swap.c

11
basilisk/basilisk_MSG.c

@ -195,16 +195,19 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
int32_t basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t maxlen)
{
char *retstr,*hexstr=0; cJSON *valsobj,*retjson,*msgobj; int32_t datalen=0,retval = -1;
char *retstr,*hexstr=0; cJSON *valsobj,*retarray,*item,*msgobj; int32_t datalen=0,retval = -1;
valsobj = cJSON_CreateObject();
jaddnum(valsobj,"channel",channel);
jaddnum(valsobj,"msgid",msgid);
if ( (retstr= basilisk_getmessage(myinfo,0,0,0,hash,valsobj,0)) != 0 )
{
//printf("getmessage.(%s)\n",retstr);
if ( (retjson= cJSON_Parse(retstr)) != 0 )
if ( (retarray= cJSON_Parse(retstr)) != 0 )
{
if ( (msgobj= jobj(retjson,"message")) != 0 )
if ( is_cJSON_Array(retarray) != 0 )
item = jitem(retarray,0);
else item = retarray;
if ( (msgobj= jobj(item,"message")) != 0 )
{
if ( (hexstr= jstr(msgobj,"data")) != 0 && (datalen= is_hexstr(hexstr,0)) > 0 )
{
@ -215,7 +218,7 @@ int32_t basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t c
} else printf("datalen.%d < maxlen.%d\n",datalen,maxlen);
} else printf("no hexstr.%p or datalen.%d\n",hexstr,datalen);
} else printf("no message object.(%s)\n",retstr);
free_json(retjson);
free_json(retarray);
} else printf("cant parse message\n");
free(retstr);
} else printf("null getmessage\n");

4
basilisk/basilisk_swap.c

@ -537,7 +537,7 @@ void basilisk_swaploop(void *_swap)
}
else if ( (swap->statebits & 0x02) == 0 ) // send pubkeys
{
printf("send deck again\n");
//printf("send deck again\n");
datalen = basilisk_swapdata_deck(myinfo,swap,data,maxlen);
basilisk_swapsend(myinfo,swap,0x02,data,datalen,0x01);
if ( basilisk_swapget(myinfo,swap,0x02,data,maxlen,basilisk_verify_otherdeck) == 0 )
@ -551,6 +551,8 @@ void basilisk_swaploop(void *_swap)
}
else if ( (swap->statebits & 0x08) == 0 ) // wait for choosei
{
iguana_rwnum(1,data,sizeof(swap->choosei),&swap->choosei);
basilisk_swapsend(myinfo,swap,0x08,data,datalen,0x04);
if ( basilisk_swapget(myinfo,swap,0x08,data,maxlen,basilisk_verify_choosei) == 0 )
swap->statebits |= 0x08;
}

Loading…
Cancel
Save