Browse Source

Test

etomic
jl777 7 years ago
parent
commit
18aafde22d
  1. 19
      iguana/exchanges/LP_rpc.c
  2. 18
      iguana/exchanges/LP_socket.c

19
iguana/exchanges/LP_rpc.c

@ -820,11 +820,21 @@ int32_t LP_importaddress(char *symbol,char *address)
double _LP_getestimatedrate(struct iguana_info *coin)
{
char buf[512],*retstr; cJSON *errjson; double rate = 0.00000020;
char buf[512],*retstr=0; int32_t numblocks; cJSON *errjson,*retjson; double rate = 0.00000020;
if ( coin->rate < 0. || time(NULL) > coin->ratetime+30 )
{
sprintf(buf,"[%d]",strcmp(coin->symbol,"BTC") == 0 ? 6 : 2);
if ( (retstr= LP_apicall(coin,coin->electrum==0?"estimatefee" : "blockchain.estimatefee",buf)) != 0 )
numblocks = strcmp(coin->symbol,"BTC") == 0 ? 6 : 2;
if ( coin->electrum == 0 )
{
sprintf(buf,"[%d]",numblocks);
retstr = LP_apicall(coin,"estimatefee",buf);
}
else
{
if ( (retjson= electrum_estimatefee(coin->symbol,coin->electrum,&retjson,numblocks)) != 0 )
retstr = jprint(retjson,1);
}
if ( retstr != 0 )
{
if ( retstr[0] == '{' && (errjson= cJSON_Parse(retstr)) != 0 )
{
@ -845,8 +855,7 @@ double _LP_getestimatedrate(struct iguana_info *coin)
coin->rate = rate;
coin->ratetime = (uint32_t)time(NULL);
}
if ( coin->electrum == 0 )
free(retstr);
free(retstr);
} else rate = coin->rate;
} else rate = coin->rate;
return(rate);

18
iguana/exchanges/LP_socket.c

@ -892,26 +892,15 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len)
portable_mutex_lock(&ep->pendingQ.mutex);
if ( ep->pendingQ.list != 0 )
{
cJSON *tmpjson; char *tmpstr;
DL_FOREACH_SAFE(ep->pendingQ.list,item,tmp)
{
stritem = (struct stritem *)item;
if ( item->type == idnum )
{
DL_DELETE(ep->pendingQ.list,item);
if ( resultjson != 0 )
{
tmpstr = jprint(resultjson,0);
if ( (tmpstr[0] != '[' && tmpstr[0] != '{') || (tmpjson= cJSON_Parse(tmpstr)) == 0 )
{
tmpjson = cJSON_CreateObject();
jadd(tmpjson,"result",jduplicate(resultjson));
}
free(tmpstr);
} else tmpjson = cJSON_CreateObject();
//*((cJSON **)stritem->retptrp) = (resultjson != 0 ? jduplicate(resultjson) : jduplicate(strjson));
*((cJSON **)stritem->retptrp) = tmpjson;
printf("matched idnum.%d result.(%s)\n",idnum,jprint(tmpjson,0));
*((cJSON **)stritem->retptrp) = (resultjson != 0 ? jduplicate(resultjson) : jduplicate(strjson));
resultjson = strjson = 0;
printf("matched idnum.%d result.%p\n",idnum,resultjson);
free(item);
break;
}
@ -927,7 +916,6 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len)
*((cJSON **)stritem->retptrp) = errjson;
}
free(item);
item = 0;
}
}
}

Loading…
Cancel
Save