Compare commits

...

3 commits

Author SHA1 Message Date
Victor Shyba
c6419f199c wip patch 2020-05-26 14:12:47 -03:00
Victor Shyba
5a3cd577db log before processing, after server reply 2020-05-23 01:27:28 -03:00
Victor Shyba
f5ccb8efdc more logs 2020-05-20 23:19:08 -03:00
2 changed files with 8 additions and 1 deletions

View file

@ -483,6 +483,7 @@ class Ledger(metaclass=LedgerRegistry):
def process_status_update(self, update):
address, remote_status = update
log.info("Server sent update for %s, processing.", address)
self._update_tasks.add(self.update_history(address, remote_status))
async def update_history(self, address, remote_status, address_manager: AddressManager = None):
@ -640,6 +641,7 @@ class Ledger(metaclass=LedgerRegistry):
return self.network.broadcast(hexlify(tx.raw).decode())
async def wait(self, tx: Transaction, height=-1, timeout=1):
log.info("waiting for tx %s with timeout %s seconds", tx.id, timeout)
timeout = timeout or 600 # after 10 minutes there is almost 0 hope
addresses = set()
for txi in tx.inputs:
@ -653,6 +655,7 @@ class Ledger(metaclass=LedgerRegistry):
start = int(time.perf_counter())
while timeout and (int(time.perf_counter()) - start) <= timeout:
if await self._wait_round(tx, height, addresses):
log.info("got reply for tx %s with timeout %s seconds", tx.id, timeout)
return
raise asyncio.TimeoutError('Timed out waiting for transaction.')
@ -675,7 +678,9 @@ class Ledger(metaclass=LedgerRegistry):
if txid == tx.id and local_height >= height:
found = True
if not found:
log.debug("timeout: %s, %s, %s", record['history'], addresses, tx.id)
log.info('forcing update on %s', record['address'])
self._update_tasks.add(self.update_history(record['address'], 'force'))
log.info("timeout: %s, %s, %s", record['history'], addresses, tx.id)
return False
return True

View file

@ -298,7 +298,9 @@ class WalletManager:
async def broadcast_or_release(self, tx, blocking=False):
try:
log.info("broadcasting %s", tx.id)
await self.ledger.broadcast(tx)
log.info("broadcasted %s", tx.id)
if blocking:
await self.ledger.wait(tx, timeout=None)
except: