Skip to content

Commit

Permalink
enha: tidying rocksdb - don't store block number and hash for each tx…
Browse files Browse the repository at this point in the history
… log
  • Loading branch information
marcospb19-cw committed Dec 10, 2024
1 parent 7c6237f commit 3941200
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/eth/storage/permanent/rocks/rocks_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ impl RocksStorageState {
break;
}

let block = block.into_inner();
let logs = block
.into_inner()
.transactions
.into_iter()
.flat_map(|transaction| transaction.logs)
.map(LogMined::from);
.map(|log| LogMined::from_rocks_primitives(log, block.header.number, block.header.hash));

let filtered_logs = logs.filter(|log| filter.matches(log));
logs_result.extend(filtered_logs);
Expand Down
20 changes: 8 additions & 12 deletions src/eth/storage/permanent/rocks/types/log_mined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ pub struct LogMinedRocksdb {
pub transaction_hash: HashRocksdb,
pub transaction_index: IndexRocksdb,
pub log_index: IndexRocksdb,
pub block_number: BlockNumberRocksdb,
pub block_hash: HashRocksdb,
}

impl From<LogMined> for LogMinedRocksdb {
Expand All @@ -23,21 +21,19 @@ impl From<LogMined> for LogMinedRocksdb {
transaction_hash: item.transaction_hash.into(),
transaction_index: item.transaction_index.into(),
log_index: item.log_index.into(),
block_number: item.block_number.into(),
block_hash: item.block_hash.into(),
}
}
}

impl From<LogMinedRocksdb> for LogMined {
fn from(item: LogMinedRocksdb) -> Self {
impl LogMined {
pub fn from_rocks_primitives(other: LogMinedRocksdb, block_number: BlockNumberRocksdb, block_hash: HashRocksdb) -> Self {
Self {
log: item.log.into(),
transaction_hash: item.transaction_hash.into(),
transaction_index: item.transaction_index.into(),
log_index: item.log_index.into(),
block_number: item.block_number.into(),
block_hash: item.block_hash.into(),
block_number: block_number.into(),
block_hash: block_hash.into(),
log: other.log.into(),
transaction_hash: other.transaction_hash.into(),
transaction_index: other.transaction_index.into(),
log_index: other.log_index.into(),
}
}
}
6 changes: 5 additions & 1 deletion src/eth/storage/permanent/rocks/types/transaction_mined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ impl TransactionMined {
block_hash: block_hash.into(),
input: other.input.into(),
execution: other.execution.into(),
logs: other.logs.into_iter().map(LogMined::from).collect(),
logs: other
.logs
.into_iter()
.map(|log| LogMined::from_rocks_primitives(log, block_number, block_hash))
.collect(),
transaction_index: other.transaction_index.into(),
}
}
Expand Down

0 comments on commit 3941200

Please sign in to comment.