Browse Source

Test

etomic
jl777 7 years ago
parent
commit
47366177ac
  1. 2
      iguana/exchanges/LP_include.h
  2. 30
      iguana/exchanges/LP_nativeDEX.c

2
iguana/exchanges/LP_include.h

@ -37,7 +37,7 @@
#define LP_GETINFO_INCR 30
#define LP_ORDERBOOK_DURATION 3600
#define LP_HTTP_TIMEOUT 5 // 1 is too small due to edge cases of time(NULL)
#define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL)
#define LP_MAXPEER_ERRORS 3
#define LP_MINPEER_GOOD 20
#define LP_PEERGOOD_ERRORDECAY 0.9

30
iguana/exchanges/LP_nativeDEX.c

@ -318,6 +318,31 @@ void command_rpcloop(void *myipaddr)
}
}
void LP_smartutxos_push(struct iguana_info *coin)
{
struct LP_peerinfo *peer,*tmp; uint64_t value; bits256 txid; int32_t i,vout,height,n; char *retstr; cJSON *array,*item;
if ( (array= LP_address_utxos(coin,coin->smartaddr,1)) != 0 )
{
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
txid = jbits256(item,"tx_hash");
vout = jint(item,"tx_pos");
value = j64bits(item,"value");
height = jint(item,"height");
HASH_ITER(hh,LP_peerinfos,peer,tmp)
{
if ( (retstr= issue_LP_uitem(peer->ipaddr,peer->port,coin->symbol,coin->smartaddr,txid,vout,height,value)) != 0 )
free(retstr);
}
}
}
free_json(array);
}
}
int32_t LP_utxos_sync(struct LP_peerinfo *peer)
{
int32_t i,j,n=0,m,v,posted=0; bits256 txid; cJSON *array,*item,*item2,*array2,*array3; uint64_t total,total2,metric; struct iguana_info *coin,*ctmp; struct LP_address *ap; char *retstr,*retstr2,*coinaddr;
@ -463,6 +488,7 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int
}
if ( peer->diduquery == 0 )
{
needpings++;
LP_peer_pricesquery(peer);
LP_utxos_sync(peer);
peer->diduquery = now;
@ -479,6 +505,10 @@ int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int
{
//printf("needpings.%d send notify\n",needpings);
LP_notify_pubkeys(ctx,pubsock);
HASH_ITER(hh,LP_coins,coin,ctmp)
{
LP_smartutxos_push(coin);
}
}
if ( (counter % 6000) == 10 )
{

Loading…
Cancel
Save