Skip to content

Commit

Permalink
Added six columns to blocks (#179)
Browse files Browse the repository at this point in the history
* Added columns to blocks

* update blocks schema length in tests
  • Loading branch information
caentzminger authored Feb 3, 2024
1 parent 34b17eb commit 3809965
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions crates/freeze/src/datasets/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ pub struct Blocks {
n_rows: u64,
block_hash: Vec<Option<Vec<u8>>>,
parent_hash: Vec<Vec<u8>>,
uncles_hash: Vec<Vec<u8>>,
author: Vec<Option<Vec<u8>>>,
state_root: Vec<Vec<u8>>,
transactions_root: Vec<Vec<u8>>,
receipts_root: Vec<Vec<u8>>,
block_number: Vec<Option<u32>>,
gas_used: Vec<u64>,
gas_limit: Vec<u64>,
extra_data: Vec<Vec<u8>>,
logs_bloom: Vec<Option<Vec<u8>>>,
timestamp: Vec<u32>,
difficulty: Vec<u64>,
total_difficulty: Vec<Option<U256>>,
size: Vec<Option<u32>>,
mix_hash: Vec<Option<Vec<u8>>>,
nonce: Vec<Option<Vec<u8>>>,
base_fee_per_gas: Vec<Option<u64>>,
withdrawals_root: Vec<Option<Vec<u8>>>,
chain_id: Vec<u64>,
}

Expand Down Expand Up @@ -86,17 +92,23 @@ pub(crate) fn process_block<TX>(block: Block<TX>, columns: &mut Blocks, schema:

store!(schema, columns, block_hash, block.hash.map(|x| x.0.to_vec()));
store!(schema, columns, parent_hash, block.parent_hash.0.to_vec());
store!(schema, columns, uncles_hash, block.uncles_hash.0.to_vec());
store!(schema, columns, author, block.author.map(|x| x.0.to_vec()));
store!(schema, columns, state_root, block.state_root.0.to_vec());
store!(schema, columns, transactions_root, block.transactions_root.0.to_vec());
store!(schema, columns, receipts_root, block.receipts_root.0.to_vec());
store!(schema, columns, block_number, block.number.map(|x| x.as_u32()));
store!(schema, columns, gas_used, block.gas_used.as_u64());
store!(schema, columns, gas_limit, block.gas_limit.as_u64());
store!(schema, columns, extra_data, block.extra_data.to_vec());
store!(schema, columns, logs_bloom, block.logs_bloom.map(|x| x.0.to_vec()));
store!(schema, columns, timestamp, block.timestamp.as_u32());
store!(schema, columns, difficulty, block.difficulty.as_u64());
store!(schema, columns, total_difficulty, block.total_difficulty);
store!(schema, columns, base_fee_per_gas, block.base_fee_per_gas.map(|x| x.as_u64()));
store!(schema, columns, size, block.size.map(|x| x.as_u32()));
store!(schema, columns, mix_hash, block.mix_hash.map(|x| x.0.to_vec()));
store!(schema, columns, nonce, block.nonce.map(|x| x.0.to_vec()));
store!(schema, columns, withdrawals_root, block.withdrawals_root.map(|x| x.0.to_vec()));
Ok(())
}
4 changes: 2 additions & 2 deletions crates/freeze/src/types/schemas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ mod tests {
let table = Datatype::Blocks
.table_schema(&get_u256_types(), &ColumnEncoding::Hex, &None, &None, &cols, None, None)
.unwrap();
assert_eq!(15, table.columns().len());
assert_eq!(21, table.columns().len());
assert!(table.columns().contains(&"block_hash"));
assert!(table.columns().contains(&"transactions_root"));
}
Expand Down Expand Up @@ -308,7 +308,7 @@ mod tests {
None,
)
.unwrap();
assert_eq!(15, table.columns().len());
assert_eq!(21, table.columns().len());
assert!(table.columns().contains(&"block_hash"));
assert!(table.columns().contains(&"transactions_root"));
}
Expand Down

0 comments on commit 3809965

Please sign in to comment.