From bfe7994592915b81d09b59656d3a879758fb8388 Mon Sep 17 00:00:00 2001 From: banteg <4562643+banteg@users.noreply.github.com> Date: Fri, 29 Jul 2022 01:06:12 +0400 Subject: [PATCH] fix: dup --- storage_layout.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage_layout.py b/storage_layout.py index d52e46d..2b242be 100644 --- a/storage_layout.py +++ b/storage_layout.py @@ -195,12 +195,13 @@ def index_txs(contract: str): need_header = False cached = csv.DictReader(path.open("rt")) for item in cached: - last_block = int(item["block_number"]) + last_block = int(item["block_number"]) + 1 writer = csv.DictWriter(path.open("at"), ["block_number", "transaction_hash"]) if need_header: writer.writeheader() + seen = set() traces = chain.provider.stream_request( "trace_filter", [{"toAddress": [contract], "fromBlock": hex(last_block)}] ) @@ -208,7 +209,9 @@ def index_txs(contract: str): for item in bar: if "error" in item or item["type"] != "call" or item["action"]["callType"] != "call": continue - + if item["transactionHash"] in seen: + continue + seen.add(item["transactionHash"]) writer.writerow( {"block_number": item["blockNumber"], "transaction_hash": item["transactionHash"]} )