Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def on_contrbution_event(event):$
- 16 print(event)$
- 17 # and whatever$
- 18 $
- 19 async def contribution_loop(event_filter, poll_interval):$
- 20 while True:$
- 21 for event in event_filter.get_new_entries():$
- 22 handle_event(event)$
- 23 await asyncio.sleep(poll_interval)$
- 24 $
- 25 @app.task$
- 26 def contributions_events():$
- 27 logger.info("***** START CONTRIBUTION ******")$
- 28 w3 = get_w3_instance()$
- 29 contract_address = "0xaEC46A0f3869A7f4B856Bc53FC36f9bB3f0D77E6"$
- 30 lending_contract = get_lending_instance(w3, contract_address)$
- 31 event_filter = lending_contract.events.onContribution.createFilter(fromBlock="latest")$
- 32 loop = asyncio.get_event_loop()$
- 33 try:$
- 34 loop.run_until_complete($
- 35 asyncio.gather($
- 36 contribution_loop(event_filter, 2)))$
- 37 finally:$
- 38 loop.close()$
- 39 logger.info("***** END CONTRIBUTION ******")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement