def listenEvent(self):
eventFilter = self.saleNewContract.events.SellPlayer.createFilter(fromBlock='latest')
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(
asyncio.gather(
self.logLoop(eventFilter, 0.5)
)
)
async def logLoop(self, eventFilter, pollInterval):
while True:
try:
events = eventFilter.get_new_entries()
for event in events:
self.handleEvent(event)
await asyncio.sleep(pollInterval)
except ValueError as e:
print(e)
continue
运行一段时间后出现错误:
valueerror: {'code': -32000, 'message': 'filter not found'}
我看了下,是eventFilter
这个空了,所以才出错,找不到filter。推测是一段时间后没检测到最新的事件就会出错?
各位大佬知道怎么解决吗?