Skip to content

Commit 4d10eb0

Browse files
Grzegorz BaziorMBoldyrev
authored andcommitted
Add possibility of checking transaction status by hash
Signed-off-by: Grzegorz Bazior <[email protected]>
1 parent c0a53ef commit 4d10eb0

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

iroha/iroha.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,25 @@ def tx_status_stream(self, transaction, timeout=None):
448448
integral status code, and error code (will be 0 if no error occurred)
449449
:raise: grpc.RpcError with .code() available in case of any error
450450
"""
451+
tx_hash = IrohaCrypto.hash(transaction)
452+
yield from self.tx_hash_status_stream(tx_hash, timeout)
453+
454+
def tx_hash_status_stream(self, transaction_hash: "str or bytes", timeout=None):
455+
"""
456+
Generator of transaction statuses from status stream
457+
:param transaction_hash: the hash of transaction, which status is about to be known
458+
:param timeout: timeout for network I/O operations in seconds
459+
:return: an iterable over a series of tuples with symbolic status description,
460+
integral status code, and error code (will be 0 if no error occurred)
461+
:raise: grpc.RpcError with .code() available in case of any error
462+
"""
451463
if not timeout:
452464
timeout = self._timeout
453465
request = endpoint_pb2.TxStatusRequest()
454-
request.tx_hash = binascii.hexlify(IrohaCrypto.hash(transaction))
466+
if isinstance(transaction_hash, bytes):
467+
request.tx_hash = binascii.hexlify(transaction_hash)
468+
else:
469+
request.tx_hash = transaction_hash.encode('utf-8')
455470
response = self._command_service_stub.StatusStream(
456471
request, timeout=timeout)
457472
for status in response:

0 commit comments

Comments
 (0)