def poll(monitor_id, tx_stats, stub): complete = {t: False for t in tx_stats.keys()} receipts = {t: tx_stats[t]['receipt'] for t in tx_stats.keys()} pending = complete.keys() while not all(complete.values()): for tx_id in pending: try: resp = stub.GetTxStatusAsSender( mobilecoind_api_pb2.GetTxStatusAsSenderRequest( receipt=receipts[tx_id])) if resp.status == mobilecoind_api_pb2.TxStatus.TombstoneBlockExceeded: print("Transfer did not complete in time", tx_id) complete[tx_id] = True tx_stats[tx_id]['time_delta'] = time.time( ) - tx_stats[tx_id]['start'] tx_stats[tx_id]['status'] = TransferStatus.tombstoned elif resp.status == mobilecoind_api_pb2.TxStatus.Verified: print("Transfer complete", tx_id) complete[tx_id] = True tx_stats[tx_id]['time_delta'] = time.time( ) - tx_stats[tx_id]['start'] tx_stats[tx_id]['status'] = TransferStatus.success else: print("Transfer status unknown", resp.status) except Exception as e: print(f"TransferStatus exception: {repr(e)}") pending = [k for k in complete if not complete[k]] time.sleep(0.25) print(f"All accounts transfers complete: Stats:\n {tx_stats}") return tx_stats
def get_tx_status_as_sender(self, sender_tx_receipt): """ Check if a key image appears in the ledger. """ request = api.GetTxStatusAsSenderRequest(receipt=sender_tx_receipt) response = self.stub.GetTxStatusAsSender(request) return response.status