trading: don't send coins to exchange which have late tx already

This commit is contained in:
crackfoo 2018-05-16 09:53:44 -03:00 committed by Tanguy Pruvot
parent a3103af7ba
commit a9dc8c5dfd

View file

@ -38,7 +38,7 @@ function sellCoinToExchange($coin)
$market = getBestMarket($coin); $market = getBestMarket($coin);
if(!$market) return; if(!$market) return;
if(!$coin->sellonbid && $market->lastsent != null && $market->lastsent > $market->lasttraded) if($market->lastsent != null && $market->lastsent > $market->lasttraded)
{ {
// debuglog("*** not sending $coin->name to $market->name. last tx is late ***"); // debuglog("*** not sending $coin->name to $market->name. last tx is late ***");
return; return;
@ -77,9 +77,6 @@ function sellCoinToExchange($coin)
$amount = round($amount, 8); $amount = round($amount, 8);
// debuglog("sending $amount $coin->symbol to $marketname, $deposit_address"); // debuglog("sending $amount $coin->symbol to $marketname, $deposit_address");
$market->lastsent = time();
$market->save();
// sleep(1); // sleep(1);
$tx = $remote->sendtoaddress($deposit_address, $amount); $tx = $remote->sendtoaddress($deposit_address, $amount);
@ -107,6 +104,12 @@ function sellCoinToExchange($coin)
return; return;
} }
} }
if($tx)
{
$market->lastsent = time();
$market->save();
}
$exchange = new db_exchange; $exchange = new db_exchange;
$exchange->market = $marketname; $exchange->market = $marketname;