forked from LBRYCommunity/lbry-sdk
Wait on usage payement TX to be processed.
This commit is contained in:
parent
fd69401791
commit
231b982422
3 changed files with 11 additions and 8 deletions
|
@ -722,6 +722,15 @@ class Ledger(metaclass=LedgerRegistry):
|
||||||
return account.address_managers[details['chain']]
|
return account.address_managers[details['chain']]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
async def broadcast_or_release(self, tx, blocking=False):
|
||||||
|
try:
|
||||||
|
await self.broadcast(tx)
|
||||||
|
except:
|
||||||
|
await self.release_tx(tx)
|
||||||
|
raise
|
||||||
|
if blocking:
|
||||||
|
await self.wait(tx, timeout=None)
|
||||||
|
|
||||||
def broadcast(self, tx):
|
def broadcast(self, tx):
|
||||||
# broadcast can't be a retriable call yet
|
# broadcast can't be a retriable call yet
|
||||||
return self.network.broadcast(hexlify(tx.raw).decode())
|
return self.network.broadcast(hexlify(tx.raw).decode())
|
||||||
|
|
|
@ -317,10 +317,4 @@ class WalletManager:
|
||||||
)
|
)
|
||||||
|
|
||||||
async def broadcast_or_release(self, tx, blocking=False):
|
async def broadcast_or_release(self, tx, blocking=False):
|
||||||
try:
|
await self.ledger.broadcast_or_release(tx, blocking=blocking)
|
||||||
await self.ledger.broadcast(tx)
|
|
||||||
except:
|
|
||||||
await self.ledger.release_tx(tx)
|
|
||||||
raise
|
|
||||||
if blocking:
|
|
||||||
await self.ledger.wait(tx, timeout=None)
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ class WalletServerPayer:
|
||||||
)
|
)
|
||||||
|
|
||||||
log.info("pay loop: before transaction broadcast")
|
log.info("pay loop: before transaction broadcast")
|
||||||
await self.ledger.broadcast(tx)
|
await self.ledger.broadcast_or_release(tx, blocking=True)
|
||||||
if self.analytics_manager:
|
if self.analytics_manager:
|
||||||
await self.analytics_manager.send_credits_sent()
|
await self.analytics_manager.send_credits_sent()
|
||||||
log.info("pay loop: after transaction broadcast")
|
log.info("pay loop: after transaction broadcast")
|
||||||
|
|
Loading…
Reference in a new issue