Skip to content

Commit

Permalink
Use cached EthereumBlock information for indexing Safe events
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Aug 9, 2024
1 parent 7a49a47 commit 77c3007
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions safe_transaction_service/history/indexers/safe_events_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ def _process_decoded_element(
args = dict(decoded_element["args"])
ethereum_tx_hash = HexBytes(decoded_element["transactionHash"])
ethereum_tx_hash_hex = ethereum_tx_hash.hex()
ethereum_block = EthereumBlock.objects.values("number", "timestamp").get(
txs=ethereum_tx_hash
ethereum_block_number = decoded_element["blockNumber"]
ethereum_block_timestamp = EthereumBlock.objects.get_timestamp_by_hash(
decoded_element["blockHash"]
)
logger.debug(
"[%s] %s - tx-hash=%s - Processing event %s",
Expand All @@ -312,8 +313,8 @@ def _process_decoded_element(

internal_tx = InternalTx(
ethereum_tx_id=ethereum_tx_hash,
timestamp=ethereum_block["timestamp"],
block_number=ethereum_block["number"],
timestamp=ethereum_block_timestamp,
block_number=ethereum_block_number,
_from=safe_address,
gas=50000,
data=b"",
Expand Down Expand Up @@ -393,8 +394,8 @@ def _process_decoded_element(
if args["value"] and not data: # Simulate ether transfer
child_internal_tx = InternalTx(
ethereum_tx_id=ethereum_tx_hash,
timestamp=ethereum_block["timestamp"],
block_number=ethereum_block["number"],
timestamp=ethereum_block_timestamp,
block_number=ethereum_block_number,
_from=safe_address,
gas=23000,
data=b"",
Expand Down Expand Up @@ -459,7 +460,7 @@ def _process_decoded_element(
ethereum_tx_id=ethereum_tx_hash,
safe=safe_address,
defaults={
"timestamp": ethereum_block["timestamp"],
"timestamp": ethereum_block_timestamp,
},
)
if child_internal_tx:
Expand Down

0 comments on commit 77c3007

Please sign in to comment.