preparescript: --usebtcfastsync option will initialise the BTC datadir from a chain snapshot.

This commit is contained in:
tecnovert
2022-06-04 22:41:24 +02:00
parent a659eb3931
commit 0c2c86070f
12 changed files with 118 additions and 29 deletions

View File

@@ -608,12 +608,12 @@ class BasicSwap(BaseApp):
if self.coin_clients[c]['connection_type'] == 'rpc' and chain_client_settings['manage_daemon'] is True:
self.stopDaemon(c)
def waitForDaemonRPC(self, coin_type):
def waitForDaemonRPC(self, coin_type, with_wallet=True):
for i in range(self.startup_tries):
if not self.is_running:
return
try:
self.coin_clients[coin_type]['interface'].testDaemonRPC()
self.coin_clients[coin_type]['interface'].testDaemonRPC(with_wallet)
return
except Exception as ex:
self.log.warning('Can\'t connect to %s RPC: %s. Trying again in %d second/s.', coin_type, str(ex), (1 + i))
@@ -3778,12 +3778,11 @@ class BasicSwap(BaseApp):
self.mxDB.acquire()
use_session = scoped_session(self.session_factory)
link = session.query(AutomationLink).filter_by(active_ind=1, linked_type=TableTypes.OFFER, linked_id=offer.offer_id).first()
link = use_session.query(AutomationLink).filter_by(active_ind=1, linked_type=TableTypes.OFFER, linked_id=offer.offer_id).first()
if not link:
return False
strategy = session.query(AutomationStrategy).filter_by(active_ind=1, record_id=link.strategy_id).first()
strategy = use_session.query(AutomationStrategy).filter_by(active_ind=1, record_id=link.strategy_id).first()
opts = json.loads(strategy.data.decode('utf-8'))
self.log.debug('Evaluating against strategy {}'.format(strategy.record_id))
@@ -3800,7 +3799,7 @@ class BasicSwap(BaseApp):
return False
if strategy.only_known_identities:
identity_stats = session.query(KnownIdentity).filter_by(address=bid.bid_addr).first()
identity_stats = use_session.query(KnownIdentity).filter_by(address=bid.bid_addr).first()
if not identity_stats:
return False
@@ -3811,6 +3810,9 @@ class BasicSwap(BaseApp):
return False
return True
except Exception as e:
self.log.error('shouldAutoAcceptBid: %s', str(e))
return False
finally:
if session is None:
use_session.close()

View File

@@ -211,8 +211,11 @@ class BTCInterface(CoinInterface):
ensure(new_conf_target >= 1 and new_conf_target < 33, 'Invalid conf_target value')
self._conf_target = new_conf_target
def testDaemonRPC(self):
self.rpc_callback('getwalletinfo', [])
def testDaemonRPC(self, with_wallet=True):
if with_wallet:
self.rpc_callback('getwalletinfo', [])
else:
self.rpc_callback('getblockchaininfo', [])
def getDaemonVersion(self):
return self.rpc_callback('getnetworkinfo')['version']

View File

@@ -110,7 +110,7 @@ class XMRInterface(CoinInterface):
with self._mx_wallet:
self.rpc_wallet_cb('open_wallet', {'filename': self._wallet_filename})
def testDaemonRPC(self):
def testDaemonRPC(self, with_wallet=True):
self.rpc_wallet_cb('get_languages')
def getDaemonVersion(self):