Skip to content

Commit

Permalink
chore: add log mined (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
renancloudwalk authored Apr 24, 2024
1 parent 91bc6d8 commit 1fa6979
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions src/eth/storage/rocks/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ impl From<ExecutionResultRocksdb> for ExecutionResult {
}
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct LogRocksdb {
pub address: AddressRocksdb,
pub topics: (Option<H256>, Option<H256>, Option<H256>, Option<H256>),
Expand Down Expand Up @@ -580,11 +581,47 @@ impl From<ExecutionRocksdb> for Execution {
}
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct LogMinedRockdb {
pub log: LogRocksdb,
pub transaction_hash: HashRocksdb,
pub transaction_index: IndexRocksdb,
pub log_index: IndexRocksdb,
pub block_number: BlockNumberRocksdb,
pub block_hash: HashRocksdb,
}

impl From<LogMined> for LogMinedRockdb {
fn from(item: LogMined) -> 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(),
}
}
}

impl From<LogMinedRockdb> for LogMined {
fn from(item: LogMinedRockdb) -> 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(),
}
}
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct TransactionMinedRocksdb {
pub input: TransactionInputRocksdb,
pub execution: Execution,
pub logs: Vec<LogMined>, //XXX
pub logs: Vec<LogMinedRockdb>,
pub transaction_index: IndexRocksdb,
pub block_number: BlockNumberRocksdb,
pub block_hash: HashRocksdb,
Expand All @@ -595,7 +632,7 @@ impl From<TransactionMined> for TransactionMinedRocksdb {
Self {
input: item.input.into(),
execution: item.execution,
logs: item.logs,
logs: item.logs.into_iter().map(LogMinedRockdb::from).collect(),
transaction_index: IndexRocksdb::from(item.transaction_index),
block_number: BlockNumberRocksdb::from(item.block_number),
block_hash: HashRocksdb::from(item.block_hash),
Expand All @@ -608,7 +645,7 @@ impl From<TransactionMinedRocksdb> for TransactionMined {
Self {
input: item.input.into(),
execution: item.execution,
logs: item.logs,
logs: item.logs.into_iter().map(LogMined::from).collect(),
transaction_index: item.transaction_index.into(),
block_number: item.block_number.into(),
block_hash: item.block_hash.into(),
Expand Down

0 comments on commit 1fa6979

Please sign in to comment.