Created
May 17, 2019 15:06
-
-
Save igor-egorov/1a2c13f69baab8c9ff4c338fc26768df to your computer and use it in GitHub Desktop.
GetAccountTransactions pagination sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from iroha import Iroha, IrohaCrypto, IrohaGrpc | |
import binascii | |
admin_private = '85025c609c7cf82c1e8d6f398bdb28f6b799a49874e9215a3835df0c92c9ec14' | |
iroha = Iroha('admin@hoge') | |
net = IrohaGrpc('localhost:50051') | |
def get_txs1_1_1(): | |
query1 = iroha.query('GetAccountTransactions', | |
account_id='admin@hoge', page_size=1) | |
IrohaCrypto.sign_query(query1, admin_private) | |
response1 = net.send_query(query1) | |
for tx in response1.transactions_page_response.transactions: | |
print(binascii.hexlify(IrohaCrypto.hash(tx))) | |
assert 1 == len(response1.transactions_page_response.transactions) | |
print('===================================') | |
query2 = iroha.query('GetAccountTransactions', account_id='admin@hoge', page_size=1, | |
first_tx_hash=response1.transactions_page_response.next_tx_hash) | |
IrohaCrypto.sign_query(query2, admin_private) | |
response2 = net.send_query(query2) | |
for tx in response2.transactions_page_response.transactions: | |
print(binascii.hexlify(IrohaCrypto.hash(tx))) | |
assert 1 == len(response2.transactions_page_response.transactions) | |
print('===================================') | |
query3 = iroha.query('GetAccountTransactions', account_id='admin@hoge', page_size=1, | |
first_tx_hash=response2.transactions_page_response.next_tx_hash) | |
IrohaCrypto.sign_query(query3, admin_private) | |
response3 = net.send_query(query3) | |
for tx in response3.transactions_page_response.transactions: | |
print(binascii.hexlify(IrohaCrypto.hash(tx))) | |
assert 1 == len(response3.transactions_page_response.transactions) | |
get_txs1_1_1() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment