Skip to content

Instantly share code, notes, and snippets.

@igor-egorov
Created February 1, 2019 16:23
Show Gist options
  • Save igor-egorov/e07d803b3ef9f17eee48804713140c04 to your computer and use it in GitHub Desktop.
Save igor-egorov/e07d803b3ef9f17eee48804713140c04 to your computer and use it in GitHub Desktop.
HL Iroha TxStatusStream performance degradation
#!/usr/bin/env python3
#
# Copyright Soramitsu Co., Ltd. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#
from irohalib import Iroha, IrohaCrypto, IrohaGrpc
import uuid
import time
import binascii
admin_key = open('../admin@test.priv', 'rb').read()
iroha = Iroha('admin@test')
def check(message='', ts=None):
now = time.time()
diff_str = ''
if ts:
diff = now - ts
diff_str = '(diff: {})'.format(time.strftime("%H:%M:%S", time.gmtime(diff)))
print('{} {} {}'.format(time.strftime("%H:%M:%S", time.gmtime(now)), message, diff_str))
return now
def compose_tx():
tx = iroha.transaction([
iroha.command('CreateAccount',
account_name=uuid.uuid4().hex,
domain_id='test',
public_key=IrohaCrypto.private_key())
])
IrohaCrypto.sign_transaction(tx, admin_key)
return tx
txs = [compose_tx() for x in range(100)]
net = IrohaGrpc()
t1 = check('start sending')
net.send_txs(*txs)
t2 = check('start requesting statuses', t1)
tt = check('interval', t2)
for tpl in enumerate(txs):
print('TX {}'.format(tpl[0]), binascii.hexlify(IrohaCrypto.hash(tpl[1])))
sc = 9
while sc != 5:
print('resub')
for status in net.tx_status_stream(tpl[1]):
sc = status[1]
print(status)
tt = check('interval', tt)
t3 = check('end', t2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment