Browse Source

Merge pull request #433 from jl777/spvdex

latest
etomic
jl777 7 years ago
committed by GitHub
parent
commit
208e8b735c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      iguana/exchanges/LP_commands.c
  2. 13
      iguana/exchanges/LP_nativeDEX.c
  3. 2
      iguana/exchanges/LP_transaction.c
  4. 41
      iguana/exchanges/stats.c

8
iguana/exchanges/LP_commands.c

@ -342,9 +342,15 @@ bot_resume(botid)\n\
if ( LP_conflicts_find(ptr) == 0 )
{
ptr->inactive = 0;
cJSON *array = cJSON_CreateArray();
cJSON *array;
if ( ptr->smartaddr[0] != 0 )
LP_unspents_load(coin,ptr->smartaddr);
if ( LP_getheight(ptr) <= 0 )
{
ptr->inactive = (uint32_t)time(NULL);
return(clonestr("{\"error\":\"coin cant be activated till synced\"}"));
} else LP_unspents_load(coin,ptr->smartaddr);
array = cJSON_CreateArray();
jaddi(array,LP_coinjson(ptr,0));
return(jprint(array,1));
} else return(clonestr("{\"error\":\"coin port conflicts with existing coin\"}"));

13
iguana/exchanges/LP_nativeDEX.c

@ -65,7 +65,8 @@ void LP_millistats_update(struct LP_millistats *mp)
mp->millisum += elapsed;
if ( mp->threshold != 0. && elapsed > mp->threshold )
{
printf("%32s elapsed %10.2f millis > threshold %10.2f, ave %10.2f millis, count.%u\n",mp->name,elapsed,mp->threshold,mp->millisum/mp->count,mp->count);
if ( IAMLP == 0 )
printf("%32s elapsed %10.2f millis > threshold %10.2f, ave %10.2f millis, count.%u\n",mp->name,elapsed,mp->threshold,mp->millisum/mp->count,mp->count);
}
mp->lastmilli = millis;
}
@ -446,7 +447,7 @@ void command_rpcloop(void *myipaddr)
void utxosQ_loop(void *myipaddr)
{
strcpy(utxosQ_loop_stats.name,"utxosQ_loop");
utxosQ_loop_stats.threshold = 50.;
utxosQ_loop_stats.threshold = 150.;
while ( 1 )
{
LP_millistats_update(&utxosQ_loop_stats);
@ -723,7 +724,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int
}
HASH_ITER(hh,LP_coins,coin,ctmp) // firstrefht,firstscanht,lastscanht
{
if ( coin->addr_listunspent_requested != 0 && time(NULL) > coin->lastpushtime+LP_ORDERBOOK_DURATION )
if ( coin->addr_listunspent_requested != 0 && time(NULL) > coin->lastpushtime+10 )
{
//printf("PUSH addr_listunspent_requested %u\n",coin->addr_listunspent_requested);
coin->lastpushtime = (uint32_t)time(NULL);
@ -758,7 +759,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
{
if ( LP_getheight(coin) <= 0 )
coin->inactive = (uint32_t)time(NULL);
LP_unspents_load(coin->symbol,coin->smartaddr);
else LP_unspents_load(coin->symbol,coin->smartaddr);
}
}
if ( (n= cJSON_GetArraySize(coins)) > 0 )
@ -775,7 +776,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
{
if ( LP_getheight(coin) <= 0 )
coin->inactive = (uint32_t)time(NULL);
LP_unspents_load(coin->symbol,coin->smartaddr);
else LP_unspents_load(coin->symbol,coin->smartaddr);
}
}
}
@ -880,7 +881,7 @@ void LP_reserved_msgs(void *ignore)
bits256 zero; int32_t flag,nonz; struct nn_pollfd pfd;
memset(zero.bytes,0,sizeof(zero));
strcpy(LP_reserved_msgs_stats.name,"LP_reserved_msgs");
LP_reserved_msgs_stats.threshold = 50.;
LP_reserved_msgs_stats.threshold = 150.;
while ( 1 )
{
nonz = 0;

2
iguana/exchanges/LP_transaction.c

@ -648,7 +648,7 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch
satoshis = value - 3*txfee/4;
printf("reduce satoshis %.8f by txfee %.8f to value %.8f\n",dstr(satoshis),dstr(txfee),dstr(value));
}
else if ( value == satoshis && (double)txfee/value < 0.001 )
else if ( value == satoshis && (double)txfee/value < 0.1 )
{
satoshis = value - txfee;
printf("txfee allocation from value %.8f identical to satoshis: %.8f txfee %.8f\n",dstr(value),dstr(satoshis),dstr(txfee));

41
iguana/exchanges/stats.c

@ -745,19 +745,11 @@ extern int32_t IAMLP;
void stats_rpcloop(void *args)
{
static uint32_t counter;
uint16_t port; int32_t sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req;
uint16_t port; int32_t retval,sock,bindsock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req,*req2,*rtmp;
if ( (port= *(uint16_t *)args) == 0 )
port = 7779;
RPC_port = port;
localhostbits = (uint32_t)calc_ipbits("127.0.0.1");
/*while ( (bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 )
{
//if ( coin->MAXPEERS == 1 )
// break;
//exit(-1);
sleep(3);
}
printf(">>>>>>>>>> DEX stats 127.0.0.1:%d bind sock.%d DEX stats API enabled <<<<<<<<<\n",port,bindsock);*/
while ( 1 )
{
if ( bindsock < 0 )
@ -780,21 +772,26 @@ void stats_rpcloop(void *args)
req = calloc(1,sizeof(*req));
req->sock = sock;
req->ipbits = ipbits;
if ( 0 )
{
//LP_rpc_processreq((void *)&arg64);
//free(arg64ptr);
//closesocket(sock);
}
else if ( OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req) != 0 )
{
printf("error launching rpc handler on port %d\n",port);
}
/*if ( 0 && IAMLP != 0 && ipbits != localhostbits )
LP_rpc_processreq(req);
continue;
if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 )
{
printf("error launching rpc handler on port %d, retval.%d\n",port,retval);
close(bindsock);
bindsock = iguana_socket(1,"0.0.0.0",port);
} //else printf("skip close and rebind\n");*/
bindsock = -1;
portable_mutex_lock(&LP_networkmutex);
DL_FOREACH_SAFE(LP_garbage_collector,req2,rtmp)
{
DL_DELETE(LP_garbage_collector,req2);
free(req2);
}
portable_mutex_unlock(&LP_networkmutex);
if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 )
{
printf("error2 launching rpc handler on port %d, retval.%d\n",port,retval);
LP_rpc_processreq(req);
}
}
}
}

Loading…
Cancel
Save