From a285d58f73f9e728a26b36fcc3baef528c477083 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 22 Nov 2017 22:35:28 +0400 Subject: [PATCH] test --- iguana/exchanges/LP_zeroconf.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_zeroconf.c b/iguana/exchanges/LP_zeroconf.c index f47e67633..996a5d4c4 100644 --- a/iguana/exchanges/LP_zeroconf.c +++ b/iguana/exchanges/LP_zeroconf.c @@ -266,11 +266,25 @@ void LP_zeroconf_deposits(struct iguana_info *coin) int32_t LP_dynamictrust(bits256 pubkey,int64_t kmdvalue) { - struct LP_pubkey_info *pubp; - if ( (pubp= LP_pubkeyfind(pubkey)) != 0 ) + struct LP_pubswap *ptr,*tmp; struct LP_swapstats *sp; struct LP_pubkey_info *pubp; struct LP_address *ap; char coinaddr[64]; struct iguana_info *coin; int64_t swaps_kmdvalue = 0; + if ( (coin= LP_coinfind("KMD")) != 0 && (pubp= LP_pubkeyfind(pubkey)) != 0 ) { - if ( pubp->bondvalue > pubp->swaps_kmdvalue+kmdvalue ) - return(1); + if ((ap= LP_address(coin,coinaddr)) != 0 && ap->zeroconf_credits >= kmdvalue ) + { + DL_FOREACH_SAFE(pubp->bobswaps,ptr,tmp) + { + if ( (sp= ptr->swap) != 0 && sp->finished == 0 && sp->expired == 0 ) + swaps_kmdvalue += LP_kmdvalue(sp->Q.srccoin,sp->Q.satoshis); + } + DL_FOREACH_SAFE(pubp->aliceswaps,ptr,tmp) + { + if ( (sp= ptr->swap) != 0 && sp->finished == 0 && sp->expired == 0 ) + swaps_kmdvalue += LP_kmdvalue(sp->Q.destcoin,sp->Q.destsatoshis); + } + printf("credits %.8f vs (%.8f + current %.8f)\n",dstr(ap->zeroconf_credits),dstr(swaps_kmdvalue),dstr(kmdvalue)); + if ( ap->zeroconf_credits > swaps_kmdvalue+kmdvalue ) + return(1); + } } return(0); }