From a3ca15bcda04d279f2c6687dce73cffef010d8b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 27 Mar 2017 15:02:30 +0300 Subject: [PATCH] Remove 7778 and IGUANA_PORT hardcodes --- iguana/iguana_accept.c | 2 +- iguana/iguana_json.c | 10 +++++----- iguana/iguana_rpc.c | 2 +- iguana/main.c | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index e86c74bcf..2463a09a8 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -115,7 +115,7 @@ void iguana_acceptloop(void *args) printf("another daemon running, no need to have iguana accept connections\n"); return; } - //if ( port != IGUANA_RPCPORT ) + //if ( port != myinfo->rpcport ) // return; sleep(5); } diff --git a/iguana/iguana_json.c b/iguana/iguana_json.c index 7e38b1ad7..99d851641 100755 --- a/iguana/iguana_json.c +++ b/iguana/iguana_json.c @@ -18,7 +18,7 @@ cJSON *helpjson(cJSON *json,cJSON *array,cJSON *agents,char *agentstr,char *method,cJSON *methodargs) { - cJSON *methodobj,*item; int32_t i,n; char url[2048],curl[2048]; + cJSON *methodobj,*item; int32_t i,n; char url[2048],curl[2048]; struct supernet_info *myinfo = SuperNET_MYINFO(0); /*if ( *agentstrp == 0 || strcmp(*agentstrp,agentstr) != 0 ) { if ( array != 0 ) @@ -43,8 +43,8 @@ cJSON *helpjson(cJSON *json,cJSON *array,cJSON *agents,char *agentstr,char *meth methodobj = cJSON_CreateObject(); jaddstr(methodobj,"agent",agentstr); jaddstr(methodobj,"method",method); - sprintf(url,"http://127.0.0.1:7778/api/%s/%s",agentstr,method); - sprintf(curl,"curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"%s\\\",\\\"method\\\":\\\"%s\\\"",agentstr,method); + sprintf(url,"http://127.0.0.1:%u/api/%s/%s",myinfo->rpcport,agentstr,method); + sprintf(curl,"curl --url \"http://127.0.0.1:%u\" --data \"{\\\"agent\\\":\\\"%s\\\",\\\"method\\\":\\\"%s\\\"",myinfo->rpcport,agentstr,method); if ( methodargs != 0 && (n= cJSON_GetArraySize(methodargs)) > 0 ) { //printf("method.%s n.%d %s\n",method,n,jprint(methodargs,0)); @@ -203,7 +203,7 @@ cJSON *SuperNET_helpjson() int32_t agentform(FILE *fp,char *form,int32_t max,char *agent,cJSON *methoditem) { - cJSON *item,*fieldsarray; int32_t j,m,width=1,size = 0; + cJSON *item,*fieldsarray; int32_t j,m,width=1,size = 0; struct supernet_info *myinfo = SuperNET_MYINFO(0); char *methodstr,*typestr,outstr[2048],outstr2[2048],fields[8192],str[2],agent_method[256],*fieldname; form[0] = 0; if ( (methodstr= jstr(methoditem,"method")) == 0 ) @@ -252,7 +252,7 @@ int32_t agentform(FILE *fp,char *form,int32_t max,char *agent,cJSON *methoditem) //printf("fields[%d] (%s)\n",j,fields); } } else sprintf(fields+strlen(fields),"%s ",agent_method); - sprintf(&form[size],"
%s
",agent,methodstr,outstr,fields,outstr2,methodstr); + sprintf(&form[size],"
%s
",myinfo->rpcport,agent,methodstr,outstr,fields,outstr2,methodstr); if ( fp != 0 ) fprintf(fp,"%s\n",&form[size]); //printf("%s\n",&form[size]); diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 19d546676..20ad9aa78 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -759,7 +759,7 @@ char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,ch //printf("add params[%d] of %d <- (%s) %p.(%p %p)\n",i,n,jprint(params[i],0),params[i],params[i]->next,params[i]->prev); } } - retstr = iguana_bitcoinrpc(myinfo,IGUANA_RPCPORT,coin,method,params,n,json,remoteaddr,array); + retstr = iguana_bitcoinrpc(myinfo,myinfo->rpcport,coin,method,params,n,json,remoteaddr,array); if ( n > 0 ) for (i=0; irpcport) ) { if ( coin != 0 ) { @@ -2051,7 +2051,7 @@ FOUR_STRINGS(SuperNET,login,handle,password,permanentfile,passphrase) void komodo_ICO_batch(cJSON *array,int32_t batchid) { - int32_t i,n,iter; cJSON *item; uint64_t kmdamount,revsamount; char *coinaddr,cmd[512]; double totalKMD,totalREVS; + int32_t i,n,iter; cJSON *item; uint64_t kmdamount,revsamount; char *coinaddr,cmd[512]; double totalKMD,totalREVS; struct supernet_info *myinfo = SuperNET_MYINFO(0); if ( (n= cJSON_GetArraySize(array)) > 0 ) { totalKMD = totalREVS = 0; @@ -2070,7 +2070,7 @@ void komodo_ICO_batch(cJSON *array,int32_t batchid) { if ( dstr(revsamount) >= 1. && (iter & 1) == 0 ) { - printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"REVS\\\"}\" # %.8f\n",coinaddr,dstr(revsamount)); + printf("curl --url \"http://127.0.0.1:%u\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"REVS\\\"}\" # %.8f\n",myinfo->rpcport,coinaddr,dstr(revsamount)); printf("sleep 3\n"); } else printf("sleep 1\n"); if ( (iter & 1) != 0 ) @@ -2093,9 +2093,9 @@ void komodo_ICO_batch(cJSON *array,int32_t batchid) { if ( (0) ) { - printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\" # %.8f\n",coinaddr,dstr(kmdamount)); + printf("curl --url \"http://127.0.0.1:%u\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\" # %.8f\n",myinfo->rpcport,coinaddr,dstr(kmdamount)); printf("sleep 3\n"); - } else printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"listunspent\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\"\n",coinaddr); + } else printf("curl --url \"http://127.0.0.1:%u\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"listunspent\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\"\n",myinfo->rpcport,coinaddr); } else { @@ -2114,7 +2114,7 @@ void komodo_ICO_batch(cJSON *array,int32_t batchid) void komodo_REVS_merge(char *str,char *str2) { - char line[1024],line2[1024],*coinaddr; int32_t i,n=0,m=0,k=0; + char line[1024],line2[1024],*coinaddr; int32_t i,n=0,m=0,k=0; struct supernet_info *myinfo = SuperNET_MYINFO(0); while ( 1 ) { if ( str[n] == 0 || str2[m] == 0 ) @@ -2136,7 +2136,7 @@ void komodo_REVS_merge(char *str,char *str2) coinaddr[i] = 0; if ( atof(&coinaddr[i+1]) > 1 ) { - printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"REVS\\\"}\" # %.8f\n",coinaddr,atof(coinaddr+i+1)); + printf("curl --url \"http://127.0.0.1:%u\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"REVS\\\"}\" # %.8f\n",myinfo->rpcport,coinaddr,atof(coinaddr+i+1)); printf("sleep 3\n"); } k++;