diff --git a/iguana/SuperNET.c b/iguana/SuperNET.c index d086b69ce..431c5ddf2 100755 --- a/iguana/SuperNET.c +++ b/iguana/SuperNET.c @@ -475,7 +475,7 @@ int32_t iguana_send_supernet(struct iguana_info *coin,struct iguana_peer *addr,c iguana_setkeys(myinfo,addr,&privkey,&pubkey,&destpub,&nextprivkey,&nextpubkey,&nextdestpub); if ( juint(json,"plaintext") == 0 && juint(json,"broadcast") == 0 && memcmp(destpub.bytes,GENESIS_PUBKEY.bytes,sizeof(pubkey)) == 0 ) { - printf("reject broadcasting non-plaintext! (%s)\n",jsonstr); getchar(); + printf("reject broadcasting non-plaintext! (%s)\n",jsonstr); //getchar(); free_json(json); return(-1); } diff --git a/iguana/iguana_instantdex.c b/iguana/iguana_instantdex.c index fdc6d3030..cf24d0a41 100755 --- a/iguana/iguana_instantdex.c +++ b/iguana/iguana_instantdex.c @@ -320,8 +320,7 @@ bits256 instantdex_rwoffer(int32_t rwflag,int32_t *lenp,uint8_t *serialized,stru char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *offer,cJSON *argjson,char *cmdstr,bits256 desthash,int32_t hops,void *extraser,int32_t extralen) { - char *reqstr,*hexstr,*retstr; struct instantdex_msghdr *msg; bits256 orderhash; - int32_t i,olen,slen,datalen; uint8_t serialized[sizeof(*offer) + 2]; uint64_t nxt64bits; + char *reqstr,*retstr; struct instantdex_msghdr *msg; bits256 orderhash; struct iguana_info *coin; struct iguana_peer *addr; int32_t i,j,r,olen,slen,datalen,max; uint8_t serialized[sizeof(*offer) + sizeof(struct iguana_msghdr) + 4096]; uint64_t nxt64bits; category_subscribe(myinfo,myinfo->instantdex_category,GENESIS_PUBKEY); jaddstr(argjson,"cmd",cmdstr); jaddstr(argjson,"agent","SuperNET"); @@ -359,11 +358,26 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o if ( instantdex_msgcreate(myinfo,msg,datalen) != 0 ) { printf(">>>>>>>>>>>> instantdex send.(%s) datalen.%d allocsize.%d crc.%x\n",cmdstr,datalen,msg->sig.allocsize,calc_crc32(0,(void *)((long)msg + 8),datalen-8)); - hexstr = malloc(msg->sig.allocsize*2 + 1); - init_hexbytes_noT(hexstr,(uint8_t *)msg,msg->sig.allocsize); - retstr = SuperNET_categorymulticast(myinfo,0,myinfo->instantdex_category,desthash,hexstr,0,hops,1,argjson,0); - free_json(argjson), free(hexstr), free(msg); - return(retstr); + //hexstr = malloc(msg->sig.allocsize*2 + 1); + //init_hexbytes_noT(hexstr,(uint8_t *)msg,msg->sig.allocsize); + //retstr = SuperNET_categorymulticast(myinfo,0,myinfo->instantdex_category,desthash,hexstr,0,hops,1,argjson,0); + memcpy(&serialized[sizeof(struct iguana_msghdr)],(uint8_t *)msg,msg->sig.allocsize); + if ( (coin= iguana_coinfind("BTCD")) != 0 && (max= coin->peers.numranked) > 0 ) + { + r = (rand() % max); + for (i=0; ipeers.ranked[j]) != 0 && addr->supernet != 0 && addr->usock >= 0 ) + { + iguana_queue_send(coin,addr,0,serialized,"InstantDEX",msg->sig.allocsize,0,0); + if ( --hops <= 0 ) + break; + } + } + } + free(msg); //free(hexstr), + return(jprint(argjson,1)); } else { diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 7173f6b56..bec9ca870 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -600,7 +600,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc else if ( strcmp(H->command,"InstantDEX") == 0 ) { init_hexbytes_noT(addr->TXDATA.ptr,data,recvlen); - printf("peer InstantDEX message\n"); + printf("peer InstantDEX message datalen.%d\n",recvlen); SuperNET_hexmsgadd(myinfo,myinfo->instantdex_category,GENESIS_PUBKEY,addr->TXDATA.ptr,tai_now(),addr->ipaddr); return(0); } diff --git a/iguana/main.c b/iguana/main.c index a520cd5ac..79c792115 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -237,7 +237,7 @@ int32_t iguana_jsonQ() { if ( ptr->expired != 0 ) { - if ( ptr->retjsonstrp != 0 && *ptr->retjsonstrp != 0 ) + if ( ptr->retjsonstrp != 0 && *ptr->retjsonstrp != 0 && *ptr->retjsonstrp[0] != 0 ) free(*ptr->retjsonstrp); // *ptr->retjsonstrp = clonestr("{\"error\":\"request timeout\"}"); printf("garbage collection: expired.(%s)\n",ptr->jsonstr); myfree(ptr,ptr->allocsize);