|
|
@ -389,7 +389,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,struct iguana_peer *addr,struct bitcoin_swapinfo *swap) |
|
|
|
{ |
|
|
|
cJSON *sendjson; char *reqstr; struct instantdex_msghdr *msg; bits256 orderhash,tmphash; int32_t i,j,len,dir=0,serflag,olen,slen,datalen; uint8_t *buf,*allocptr,space[4096],serialized[sizeof(*offer) + sizeof(struct iguana_msghdr) + 4096 + INSTANTDEX_DECKSIZE*33]; uint64_t x,nxt64bits; |
|
|
|
cJSON *sendjson; char *reqstr; struct instantdex_msghdr *msg; bits256 orderhash,tmphash; int32_t i,j,len,serflag,olen,slen,datalen; uint8_t *buf,*allocptr,space[4096],serialized[sizeof(*offer) + sizeof(struct iguana_msghdr) + 4096 + INSTANTDEX_DECKSIZE*33]; uint64_t x,nxt64bits; |
|
|
|
orderhash = instantdex_rwoffer(1,&olen,serialized,offer); |
|
|
|
if ( 1 ) |
|
|
|
{ |
|
|
@ -466,7 +466,7 @@ char *instantdex_sendcmd(struct supernet_info *myinfo,struct instantdex_offer *o |
|
|
|
jaddstr(sendjson,"handle",myinfo->handle); |
|
|
|
jaddbits256(sendjson,"traderpub",myinfo->myaddr.persistent); |
|
|
|
data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,swap->mine.offer.base,sendjson,basilisktag); |
|
|
|
basilisk_sendcmd(myinfo,addr->ipaddr,dir > 0 ? "BID" : "ASK",&basilisktag,encryptflag,delaymillis,data,datalen,1,BASILISK_DEFAULTDIFF); |
|
|
|
basilisk_sendcmd(myinfo,addr->ipaddr,"DEX",&basilisktag,encryptflag,delaymillis,data,datalen,1,BASILISK_DEFAULTDIFF); |
|
|
|
free_json(sendjson); |
|
|
|
if ( allocptr != 0 ) |
|
|
|
free(allocptr); |
|
|
@ -1069,14 +1069,15 @@ int32_t instantdex_quotep2p(struct supernet_info *myinfo,struct iguana_info *coi |
|
|
|
void instantdex_propagate(struct supernet_info *myinfo,struct exchange_info *exchange,struct instantdex_accept *ap) |
|
|
|
{ |
|
|
|
bits256 orderhash; uint8_t serialized[8192]; int32_t i,len; struct iguana_peer *addr; struct iguana_info *coin; |
|
|
|
orderhash = instantdex_rwoffer(1,&len,&serialized[sizeof(struct iguana_msghdr)],&ap->offer); |
|
|
|
orderhash = instantdex_rwoffer(1,&len,&serialized[64+sizeof(struct iguana_msghdr)],&ap->offer); |
|
|
|
if ( (coin= iguana_coinfind("BTCD")) != 0 && coin->peers != 0 && coin->peers->numranked > 0 ) |
|
|
|
{ |
|
|
|
for (i=0; i<coin->peers->numranked; i++) |
|
|
|
if ( (addr= coin->peers->ranked[i]) != 0 && addr->supernet != 0 && addr->usock >= 0 && GETBIT(ap->peerhas,addr->addrind) == 0 && strcmp("0.0.0.0",addr->ipaddr) != 0 && strcmp("127.0.0.1",addr->ipaddr) != 0 ) |
|
|
|
{ |
|
|
|
char str[65]; printf("send quote.(%s) <- [%d] %s %llx\n",addr->ipaddr,len,bits256_str(str,orderhash),(long long)orderhash.txid); |
|
|
|
iguana_queue_send(addr,0,serialized,"quote",len); |
|
|
|
basilisk_sendcmd(myinfo,addr->ipaddr,"DEX",0,0,0,&serialized[64+sizeof(struct iguana_msghdr)],len,1,BASILISK_DEFAULTDIFF); |
|
|
|
//iguana_queue_send(addr,0,serialized,"quote",len);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|