|
@ -171,7 +171,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr) |
|
|
|
|
|
|
|
|
int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen) |
|
|
int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen) |
|
|
{ |
|
|
{ |
|
|
char *retstr,*hexstr,strbuf[16384],*ptr = 0; int32_t retval = -1; cJSON *retjson,*valsobj; |
|
|
char *retstr,*hexstr,strbuf[16384],*ptr = 0; int32_t retval = -1; cJSON *retarray,*item,*valsobj; |
|
|
if ( (hexstr= basilisk_addhexstr(&ptr,0,strbuf,sizeof(strbuf),data,datalen)) != 0 ) |
|
|
if ( (hexstr= basilisk_addhexstr(&ptr,0,strbuf,sizeof(strbuf),data,datalen)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
valsobj = cJSON_CreateObject(); |
|
|
valsobj = cJSON_CreateObject(); |
|
@ -179,11 +179,14 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t |
|
|
jaddnum(valsobj,"msgid",msgid); |
|
|
jaddnum(valsobj,"msgid",msgid); |
|
|
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 ) |
|
|
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
if ( (retjson= cJSON_Parse(retstr)) != 0 ) |
|
|
if ( (retarray= cJSON_Parse(retstr)) != 0 ) |
|
|
{ |
|
|
{ |
|
|
if ( jobj(retjson,"error") == 0 ) |
|
|
if ( is_cJSON_Array(retarray) != 0 ) |
|
|
|
|
|
item = jitem(retarray,0); |
|
|
|
|
|
else item = retarray; |
|
|
|
|
|
if ( jobj(item,"error") == 0 ) |
|
|
retval = 0; |
|
|
retval = 0; |
|
|
free_json(retjson); |
|
|
free_json(retarray); |
|
|
} |
|
|
} |
|
|
free(retstr); |
|
|
free(retstr); |
|
|
} |
|
|
} |
|
|