Skip to content

Commit

Permalink
Addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerson2102 committed Sep 7, 2024
1 parent 8832889 commit b6eeeb1
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions scripts/data/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,48 +266,24 @@ def generate_data(
elif mode == "full":
block = fetch_block(next_block_hash)

for tx in block["data"]:
for idx, output in enumerate(tx["outputs"]):
outpoint = (tx["txid"], idx)
utxo_set[outpoint] = output

output["cached"] = False

for tx in block["data"]:
for tx_input in tx["inputs"]:
outpoint = (
tx_input["previous_output"]["txid"],
tx_input["previous_output"]["vout"],
)

if outpoint in utxo_set:
tx_input["previous_output"]["cached"] = True
utxo_set[outpoint]["cached"] = True

for idx, output in enumerate(tx["outputs"]):
outpoint = (tx["txid"], idx)
utxo_set[outpoint] = output
else:
raise NotImplementedError(mode)
next_block_hash = block["nextblockhash"]
blocks.append(block)

for block in blocks:
for tx in block["data"]:
for idx, output in enumerate(tx["outputs"]):
outpoint = (tx["txid"], idx)
if outpoint in utxo_set:
tx["outputs"][idx]["cached"] = utxo_set[outpoint].get(
"cached", False
)

for tx_input in tx["inputs"]:
outpoint = (
tx_input["previous_output"]["txid"],
tx_input["previous_output"]["vout"],
)
if outpoint in utxo_set:
tx_input["previous_output"]["cached"] = utxo_set[outpoint].get(
"cached", False
)

block_formatter = (
format_block if mode == "light" else format_block_with_transactions
)
Expand Down

0 comments on commit b6eeeb1

Please sign in to comment.