Browse Source

Test

etomic
jl777 7 years ago
parent
commit
4f0446b564
  1. 2
      iguana/exchanges/LP_include.h
  2. 45
      iguana/exchanges/LP_nativeDEX.c
  3. 8
      iguana/exchanges/LP_rpc.c
  4. 3
      iguana/exchanges/LP_socket.c

2
iguana/exchanges/LP_include.h

@ -255,7 +255,7 @@ struct iguana_info
portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses; portable_mutex_t txmutex,addrmutex; struct LP_transaction *transactions; struct LP_address *addresses;
uint64_t txfee; uint64_t txfee;
int32_t numutxos,longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport; int32_t numutxos,longestchain,firstrefht,firstscanht,lastscanht,bussock,height; uint16_t busport;
uint32_t lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime; uint32_t electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime;
uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms; uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms;
char symbol[16],smartaddr[64],userpass[1024],serverport[128]; char symbol[16],smartaddr[64],userpass[1024],serverport[128];
// portfolio // portfolio

45
iguana/exchanges/LP_nativeDEX.c

@ -620,13 +620,6 @@ void LP_coinsloop(void *_coins)
} }
} }
} }
if ( time(NULL) > coin->lastunspent+30 )
{
//printf("call electrum listunspent.%s\n",coin->symbol);
if ( (retjson= electrum_address_listunspent(coin->symbol,ep,&retjson,coin->smartaddr,2)) != 0 )
free_json(retjson);
coin->lastunspent = (uint32_t)time(NULL);
}
while ( ep != 0 ) while ( ep != 0 )
{ {
if ( time(NULL) > ep->keepalive+LP_ELECTRUM_KEEPALIVE ) if ( time(NULL) > ep->keepalive+LP_ELECTRUM_KEEPALIVE )
@ -836,13 +829,23 @@ void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint
void LP_pubkeysloop(void *ctx) void LP_pubkeysloop(void *ctx)
{ {
static uint32_t lasttime; static uint32_t lasttime; cJSON *retjson; struct iguana_info *coin,*tmp;
strcpy(LP_pubkeysloop_stats.name,"LP_pubkeysloop"); strcpy(LP_pubkeysloop_stats.name,"LP_pubkeysloop");
LP_pubkeysloop_stats.threshold = 5000.; LP_pubkeysloop_stats.threshold = 5000.;
sleep(10); sleep(10);
while ( 1 ) while ( 1 )
{ {
LP_millistats_update(&LP_pubkeysloop_stats); LP_millistats_update(&LP_pubkeysloop_stats);
HASH_ITER(hh,LP_coins,coin,tmp) // firstrefht,firstscanht,lastscanht
{
if ( coin->electrum != 0 && time(NULL) > coin->lastunspent+30 )
{
//printf("call electrum listunspent.%s\n",coin->symbol);
if ( (retjson= electrum_address_listunspent(coin->symbol,coin->electrum,&retjson,coin->smartaddr,2)) != 0 )
free_json(retjson);
coin->lastunspent = (uint32_t)time(NULL);
}
}
if ( time(NULL) > lasttime+60 ) if ( time(NULL) > lasttime+60 )
{ {
//printf("LP_pubkeysloop %u\n",(uint32_t)time(NULL)); //printf("LP_pubkeysloop %u\n",(uint32_t)time(NULL));
@ -1179,13 +1182,27 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
usleep(1000); usleep(1000);
else if ( IAMLP == 0 ) else if ( IAMLP == 0 )
usleep(1000); usleep(1000);
/*if ( (rand() % 10000) == 0 ) if ( (rand() % 10000) == 0 )
{ {
int32_t sock = LP_bindsock; char *hellostr,*retstr; cJSON *retjson; int32_t allgood,sock = LP_bindsock;
printf("bindsock reset test\n"); allgood = 0;
LP_bindsock = -1; if ( (retstr= issue_hello(myport)) != 0 )
closesocket(sock); {
}*/ if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (hellostr= jstr(retjson,"status")) != 0 && strcmp(hellostr,"") == 0 )
allgood = 1, printf("allgood.(%s)\n",retstr);
free_json(retjson);
} else printf("couldnt parse hello return.(%s)\n",retstr);
free(retstr);
} else printf("issue_hello NULL return\n");
if ( allgood == 0 )
{
printf("RPC port got stuck, kick it\n");
LP_bindsock = -1;
closesocket(sock);
}
}
} }
#endif #endif
} }

8
iguana/exchanges/LP_rpc.c

@ -93,6 +93,14 @@ char *issue_LP_getprices(char *destip,uint16_t destport)
//return(issue_curlt(url,LP_HTTP_TIMEOUT)); //return(issue_curlt(url,LP_HTTP_TIMEOUT));
} }
char *issue_hello(uint16_t port)
{
char url[512];
sprintf(url,"http://127.0.0.1:%u/api/stats/getprices",port);
//printf("getutxo.(%s)\n",url);
return(LP_issue_curl("hello","127.0.0.1",port,url));
}
char *issue_LP_listunspent(char *destip,uint16_t destport,char *symbol,char *coinaddr) char *issue_LP_listunspent(char *destip,uint16_t destport,char *symbol,char *coinaddr)
{ {
char url[512],*retstr; char url[512],*retstr;

3
iguana/exchanges/LP_socket.c

@ -597,7 +597,8 @@ cJSON *electrum_address_listunspent(char *symbol,struct electrum_info *ep,cJSON
{ {
if ( jobj(retjson,"error") == 0 && is_cJSON_Array(retjson) != 0 ) if ( jobj(retjson,"error") == 0 && is_cJSON_Array(retjson) != 0 )
{ {
//printf("%s.%d u.%u/%d t.%ld %s LISTUNSPENT.(%d)\n",coin->symbol,height,ap->unspenttime,ap->unspentheight,time(NULL),addr,(int32_t)strlen(jprint(retjson,0))); if ( electrumflag > 1 )
printf("%s.%d u.%u/%d t.%ld %s LISTUNSPENT.(%d)\n",coin->symbol,height,ap->unspenttime,ap->unspentheight,time(NULL),addr,(int32_t)strlen(jprint(retjson,0)));
updatedflag = 0; updatedflag = 0;
if ( electrum_process_array(coin,ep,addr,retjson,electrumflag) != 0 ) if ( electrum_process_array(coin,ep,addr,retjson,electrumflag) != 0 )
LP_postutxos(coin->symbol,addr), updatedflag = 1; LP_postutxos(coin->symbol,addr), updatedflag = 1;

Loading…
Cancel
Save