From 6b4ff037b6585b0c0c788215a63e805b885fd0b0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 24 May 2017 18:52:10 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_unspents.c | 53 ++++++++++++++++++++++------------ iguana/exchanges/mm.c | 22 -------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/iguana/exchanges/LP_unspents.c b/iguana/exchanges/LP_unspents.c index 1c71539f7..e884c28d0 100644 --- a/iguana/exchanges/LP_unspents.c +++ b/iguana/exchanges/LP_unspents.c @@ -242,6 +242,38 @@ int32_t LP_utxosparse(char *destipaddr,uint16_t destport,char *retstr,uint32_t n return(n); } +char *issue_LP_getpeers(char *destip,uint16_t destport,char *ipaddr,uint16_t port,double profitmargin,int32_t numpeers,int32_t numutxos) +{ + char url[512]; + sprintf(url,"http://%s:%u/api/stats/getpeers?ipaddr=%s&port=%u&profit=%.6f&numpeers=%d&numutxos=%d",destip,destport,ipaddr,port,profitmargin,numpeers,numutxos); + return(issue_curl(url)); +} + +char *issue_LP_getutxos(char *destip,uint16_t destport,char *coin,int32_t lastn,char *ipaddr,uint16_t port,double profitmargin,int32_t numpeers,int32_t numutxos) +{ + char url[512]; + sprintf(url,"http://%s:%u/api/stats/getutxos?coin=%s&lastn=%d&ipaddr=%s&port=%u&profit=%.6f&numpeers=%d&numutxos=%d",destip,destport,coin,lastn,ipaddr,port,profitmargin,numpeers,numutxos); + return(issue_curl(url)); +} + +char *issue_LP_notify(char *destip,uint16_t destport,char *ipaddr,uint16_t port,double profitmargin,int32_t numpeers,int32_t numutxos) +{ + char url[512]; + sprintf(url,"http://%s:%u/api/stats/notify?ipaddr=%s&port=%u&profit=%.6f&numpeers=%d&numutxos=%d",destip,destport,ipaddr,port,profitmargin,numpeers,numutxos); + return(issue_curl(url)); +} + +char *issue_LP_notifyutxo(char *destip,uint16_t destport,struct LP_utxoinfo *utxo) +{ + char url[4096],str[65],str2[65],*retstr; + sprintf(url,"http://%s:%u/api/stats/notifyutxo?ipaddr=%s&port=%u&profit=%.6f&coin=%s&txid=%s&vout=%d&value=%.8f&deposit=%s&dvout=%d&dvalue=%.8f&script=%s&address=%s",destip,destport,utxo->ipaddr,utxo->port,utxo->profitmargin,utxo->coin,bits256_str(str,utxo->txid),utxo->vout,dstr(utxo->satoshis),bits256_str(str2,utxo->deposittxid),utxo->depositvout,dstr(utxo->depositsatoshis),utxo->spendscript,utxo->coinaddr); + //if ( strlen(url) > 1024 ) + printf("WARNING long url.(%s)\n",url); + retstr = issue_curl(url); + printf("(%s)\n",retstr); + return(retstr); +} + void LP_peersquery(char *destipaddr,uint16_t destport,char *myipaddr,uint16_t myport,double myprofit) { char *retstr; struct LP_peerinfo *peer,*tmp; uint32_t now,flag = 0; @@ -269,15 +301,6 @@ void LP_peersquery(char *destipaddr,uint16_t destport,char *myipaddr,uint16_t my peer->errors++; } -char *issue_LP_notifyutxo(char *destip,uint16_t destport,struct LP_utxoinfo *utxo) -{ - char url[4096],str[65],str2[65]; - sprintf(url,"http://%s:%u/api/stats/notifyutxo?ipaddr=%s&port=%u&profit=%.6f&coin=%s&txid=%s&vout=%d&value=%.8f&deposit=%s&dvout=%d&dvalue=%.8f&script=%s&address=%s",destip,destport,utxo->ipaddr,utxo->port,utxo->profitmargin,utxo->coin,bits256_str(str,utxo->txid),utxo->vout,dstr(utxo->satoshis),bits256_str(str2,utxo->deposittxid),utxo->depositvout,dstr(utxo->depositsatoshis),utxo->spendscript,utxo->coinaddr); - if ( strlen(url) > 1024 ) - printf("WARNING long url.(%s)\n",url); - return(issue_curl(url)); -} - void LP_utxosquery(char *destipaddr,uint16_t destport,char *coin,int32_t lastn,char *myipaddr,uint16_t myport,double myprofit) { char *retstr; struct LP_utxoinfo *utxo,*tmp; struct LP_peerinfo *peer; int32_t i,firsti; uint32_t now,flag = 0; @@ -422,15 +445,9 @@ char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) if ( (peer= LP_peerfind((uint32_t)calc_ipbits(ipaddr),argport)) != 0 ) { if ( (otherpeers= jint(argjson,"numpeers")) > 0 ) - { - if ( peer->numpeers < otherpeers ) - peer->numpeers = otherpeers; - } + peer->numpeers = otherpeers; if ( (othernumutxos= jint(argjson,"numutxos")) > 0 ) - { - if ( peer->numutxos < othernumutxos ) - peer->numutxos = othernumutxos; - } + peer->numutxos = othernumutxos; } else LP_addpeer(ipaddr,argport,jdouble(argjson,"profit")); if ( strcmp(method,"getpeers") == 0 ) retstr = LP_peers(); @@ -438,7 +455,7 @@ char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) retstr = LP_utxos(coin,jint(argjson,"lastn")); else if ( strcmp(method,"notify") == 0 ) retstr = clonestr("{\"result\":\"success\",\"notify\":\"received\"}"); - else if ( strcmp(method,"utxonotify") == 0 ) + else if ( strcmp(method,"notifyutxo") == 0 ) { printf("utxonotify.(%s)\n",jprint(argjson,0)); LP_addutxo(jstr(argjson,"coin"),jbits256(argjson,"txid"),jint(argjson,"vout"),j64bits(argjson,"value"),jbits256(argjson,"deposit"),jint(argjson,"dvout"),j64bits(argjson,"dvalue"),jstr(argjson,"script"),jstr(argjson,"address"),ipaddr,argport,jdouble(argjson,"profit")); diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index 2146b6d30..5642cd9df 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -167,28 +167,6 @@ char *iguana_listunspent(char *coin,char *coinaddr) return(issue_curl(url)); }*/ -char *issue_LP_getpeers(char *destip,uint16_t destport,char *ipaddr,uint16_t port,double profitmargin,int32_t numpeers,int32_t numutxos) -{ - char url[512]; - sprintf(url,"http://%s:%u/api/stats/getpeers?ipaddr=%s&port=%u&profit=%.6f&numpeers=%d&numutxos=%d",destip,destport,ipaddr,port,profitmargin,numpeers,numutxos); - return(issue_curl(url)); -} - - -char *issue_LP_getutxos(char *destip,uint16_t destport,char *coin,int32_t lastn,char *ipaddr,uint16_t port,double profitmargin,int32_t numpeers,int32_t numutxos) -{ - char url[512]; - sprintf(url,"http://%s:%u/api/stats/getutxos?coin=%s&lastn=%d&ipaddr=%s&port=%u&profit=%.6f&numpeers=%d&numutxos=%d",destip,destport,coin,lastn,ipaddr,port,profitmargin,numpeers,numutxos); - return(issue_curl(url)); -} - -char *issue_LP_notify(char *destip,uint16_t destport,char *ipaddr,uint16_t port,double profitmargin,int32_t numpeers,int32_t numutxos) -{ - char url[512]; - sprintf(url,"http://%s:%u/api/stats/notify?ipaddr=%s&port=%u&profit=%.6f&numpeers=%d&numutxos=%d",destip,destport,ipaddr,port,profitmargin,numpeers,numutxos); - return(issue_curl(url)); -} - // // http://127.0.0.1:7779/api/stats/getpeers