-
-
Save emre/5550df1b9bf33e0f071ea635b8f09145 to your computer and use it in GitHub Desktop.
exp.py
This file contains 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
import time | |
from steem import Steem | |
from pprint import pprint | |
s = Steem() | |
def parse_block(block_height): | |
block = s.get_block(block_height) | |
for transaction in block["transactions"]: | |
for operation in transaction['operations']: | |
operation_type, operation_data = operation[0:2] | |
print("Operation: %s" % operation_type) | |
pprint(operation_data) | |
def get_last_block_height(): | |
props = s.get_dynamic_global_properties() | |
return props['last_irreversible_block_num'] | |
def listen_blocks(starting_point=None): | |
if not starting_point: | |
starting_point = get_last_block_height() | |
while True: | |
while(get_last_block_height() - starting_point) > 0: | |
starting_point += 1 | |
parse_block(starting_point) | |
print("Sleeping for 3 seconds...") | |
time.sleep(3) | |
listen_blocks(starting_point=18263207) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment