Design decisions on a library: A new event listener idea on Lightsteem

Streaming blockchain for the incoming transfers of a specific account


events = EventListener(client)

for transfer in events.on('transfer', filter={"to": "emrebeyler"}):
    print(transfer)

Streaming for incoming witness vote actions


events = EventListener(client)

for witness_vote in events.on('account_witness_vote', filter={"witness": "emrebeyler"}):
    print(witness_vote)

Callables (Filtering on conditions)


Let's get the comments and posts tagged with utopian-io:

def filter_tags(comment_body):
    return "utopian-io" in comment_body["json_metadata"]["tags"]:


for op in events.on("comment", condition=filter_tags):
    print("only comments has a tag with utopian-io")

Stream everything


for op in events.stream():
    print(op)

Hooks


events = EventListener(client)

def send_to_discord(data):
    # r = requests.post(...)
    pass

for witness_vote in events.on('account_witness_vote', 
        filter={"witness": "emrebeyler"}, 
        hook=send_to_discord):
    print(witness_vote)

Any thoughts?

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center