From 6b787d9150b6b356c26c4920b5d4b77251e033c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 25 Dec 2016 11:03:23 +0200 Subject: [PATCH] test --- basilisk/basilisk.c | 4 ++-- basilisk/basilisk_MSG.c | 4 ++-- iguana/dPoW.h | 2 +- iguana/dpow/dpow_network.c | 4 +++- iguana/iguana_notary.c | 6 ++++-- includes/iguana_apideclares.h | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 3d18f3b8f..c76a94f0e 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -900,8 +900,8 @@ void basilisks_loop(void *arg) endmilli = startmilli + 1000; else endmilli = startmilli + 2000; } - //if ( myinfo->expiration != 0 && (myinfo->IAMLP != 0 || myinfo->DEXactive > time(NULL)) ) - // basilisk_requests_poll(myinfo); + if ( myinfo->expiration != 0 && (myinfo->dexsock >= 0 || myinfo->IAMLP != 0 || myinfo->DEXactive > time(NULL)) ) + basilisk_requests_poll(myinfo); //printf("RELAYID.%d endmilli %f vs now %f\n",myinfo->NOTARY.RELAYID,endmilli,OS_milliseconds()); while ( OS_milliseconds() < endmilli ) usleep(10000); diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index 1d192e2ed..7b2eedf3c 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -277,7 +277,7 @@ HASH_ARRAY_STRING(basilisk,getmessage,hash,vals,hexstr) jdelete(vals,"msgid"); jaddnum(vals,"msgid",msgid); } - if ( myinfo->NOTARY.RELAYID >= 0 ) + if ( myinfo->NOTARY.RELAYID >= 0 || myinfo->dexsock >= 0 ) { channel = juint(vals,"channel"); width = juint(vals,"width"); @@ -308,7 +308,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr) if ( vals != 0 && juint(vals,"fanout") == 0 ) jaddnum(vals,"fanout",MAX(8,(int32_t)sqrt(myinfo->NOTARY.NUMRELAYS)+2)); if ( data != 0 && datalen != 0 ) - dex_reqsend(myinfo,space,datalen+BASILISK_KEYSIZE); + dex_reqsend(myinfo,"DEX",space,datalen+BASILISK_KEYSIZE); return(basilisk_standardservice("OUT",myinfo,0,jbits256(vals,"desthash"),vals,hexstr,0)); } #include "../includes/iguana_apiundefs.h" diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 5b81f23e3..2a12f5e82 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -141,7 +141,7 @@ struct dpow_info uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp); int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp); void dex_updateclient(struct supernet_info *myinfo); -int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen); +int32_t dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen); char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration); char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 0925ef575..09bfa6f0b 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -19,6 +19,7 @@ struct dex_nanomsghdr { uint32_t crc32,size,datalen,timestamp; + char handler[8]; uint8_t version0,version1,packet[]; } PACKED; @@ -67,7 +68,7 @@ void dex_packet(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp,int32_t } } -int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen) +int32_t dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen) { struct dex_nanomsghdr *dexp; char ipaddr[64],str[128]; int32_t retval=0,timeout,i,n,size,recvbytes,sentbytes = 0,reqsock,subsock; uint32_t *retptr,ipbits; portable_mutex_lock(&myinfo->dexmutex); @@ -115,6 +116,7 @@ int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen) { size = (int32_t)(sizeof(*dexp) + datalen); dexp = calloc(1,size); // endian dependent! + safecopy(dexp->handler,handler,sizeof(dexp->handler)); dexp->size = size; dexp->datalen = datalen; dexp->timestamp = (uint32_t)time(NULL); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 8f8b8fd7d..ebb52cd3f 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -345,14 +345,16 @@ THREE_STRINGS(iguana,passthru,asset,function,hex) } -STRING_ARG(dex,send,hex) +TWO_STRINGS(dex,send,hex,handler) { uint8_t data[8192]; int32_t datalen,retval; if ( hex != 0 && (datalen= is_hexstr(hex,0)) > 0 && (datalen>>1) < sizeof(data) ) { datalen >>= 1; decode_hex(data,datalen,hex); - if ( (retval= dex_reqsend(myinfo,data,datalen)) == 0 ) + if ( handler == 0 || handler[0] == 0 ) + handler = "DEX"; + if ( (retval= dex_reqsend(myinfo,handler,data,datalen)) == 0 ) return(clonestr("{\"result\":\"success\"}")); else return(clonestr("{\"error\":\"dex send: retval error\"}")); } else return(clonestr("{\"error\":\"dex send: invalid hex\"}")); diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 075b70ce8..b5e083a5c 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -20,7 +20,7 @@ TWOINTS_AND_ARRAY(dpow,ratify,minsigs,timestamp,ratified); ZERO_ARGS(dpow,cancelratify); THREE_STRINGS(iguana,passthru,asset,function,hex); STRING_ARG(dpow,bindaddr,ipaddr); -STRING_ARG(dex,send,hex); +TWO_STRINGS(dex,send,hex,handler); TWO_STRINGS(zcash,passthru,function,hex); TWO_STRINGS(komodo,passthru,function,hex);