Skip to content

Commit

Permalink
fix: dup
Browse files Browse the repository at this point in the history
  • Loading branch information
banteg committed Jul 28, 2022
1 parent f21dc08 commit bfe7994
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions storage_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,23 @@ 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)}]
)
bar = tqdm(traces, unit=" traces")
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"]}
)
Expand Down

0 comments on commit bfe7994

Please sign in to comment.