mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make block field private (#13628)
This commit is contained in:
@ -151,9 +151,10 @@ pub(crate) fn txs_testdata(num_blocks: u64) -> TestStageDB {
|
||||
.unwrap();
|
||||
let second_block = blocks.get_mut(1).unwrap();
|
||||
let cloned_second = second_block.clone();
|
||||
let mut updated_header = cloned_second.header.unseal();
|
||||
let mut updated_header = cloned_second.header.clone().unseal();
|
||||
updated_header.state_root = root;
|
||||
*second_block = SealedBlock { header: SealedHeader::seal(updated_header), ..cloned_second };
|
||||
*second_block =
|
||||
SealedBlock::new(SealedHeader::seal(updated_header), cloned_second.into_body());
|
||||
|
||||
let offset = transitions.len() as u64;
|
||||
|
||||
@ -184,9 +185,9 @@ pub(crate) fn txs_testdata(num_blocks: u64) -> TestStageDB {
|
||||
|
||||
let last_block = blocks.last_mut().unwrap();
|
||||
let cloned_last = last_block.clone();
|
||||
let mut updated_header = cloned_last.header.unseal();
|
||||
let mut updated_header = cloned_last.header.clone().unseal();
|
||||
updated_header.state_root = root;
|
||||
*last_block = SealedBlock { header: SealedHeader::seal(updated_header), ..cloned_last };
|
||||
*last_block = SealedBlock::new(SealedHeader::seal(updated_header), cloned_last.into_body());
|
||||
|
||||
db.insert_blocks(blocks.iter(), StorageKind::Static).unwrap();
|
||||
|
||||
|
||||
@ -519,7 +519,7 @@ mod tests {
|
||||
|
||||
/// A helper to create a collection of block bodies keyed by their hash.
|
||||
pub(crate) fn body_by_hash(block: &SealedBlock) -> (B256, BlockBody) {
|
||||
(block.hash(), block.body.clone())
|
||||
(block.hash(), block.body().clone())
|
||||
}
|
||||
|
||||
/// A helper struct for running the [`BodyStage`].
|
||||
@ -592,7 +592,7 @@ mod tests {
|
||||
|
||||
let body = StoredBlockBodyIndices {
|
||||
first_tx_num: 0,
|
||||
tx_count: progress.body.transactions.len() as u64,
|
||||
tx_count: progress.body().transactions.len() as u64,
|
||||
};
|
||||
|
||||
static_file_producer.set_block_range(0..=progress.number);
|
||||
@ -614,7 +614,7 @@ mod tests {
|
||||
if !progress.ommers_hash_is_empty() {
|
||||
tx.put::<tables::BlockOmmers>(
|
||||
progress.number,
|
||||
StoredBlockOmmers { ommers: progress.body.ommers.clone() },
|
||||
StoredBlockOmmers { ommers: progress.body().ommers.clone() },
|
||||
)?;
|
||||
}
|
||||
|
||||
@ -801,7 +801,7 @@ mod tests {
|
||||
} else {
|
||||
let body =
|
||||
this.responses.remove(&header.hash()).expect("requested unknown body");
|
||||
response.push(BlockResponse::Full(SealedBlock { header, body }));
|
||||
response.push(BlockResponse::Full(SealedBlock::new(header, body)));
|
||||
}
|
||||
|
||||
if response.len() as u64 >= this.batch_size {
|
||||
|
||||
@ -353,7 +353,7 @@ mod tests {
|
||||
// Insert last progress data
|
||||
let block_number = progress.number;
|
||||
self.db.commit(|tx| {
|
||||
progress.body.transactions.iter().try_for_each(
|
||||
progress.body().transactions.iter().try_for_each(
|
||||
|transaction| -> Result<(), reth_db::DatabaseError> {
|
||||
tx.put::<tables::TransactionHashNumbers>(
|
||||
transaction.hash(),
|
||||
@ -398,7 +398,7 @@ mod tests {
|
||||
|
||||
let body = StoredBlockBodyIndices {
|
||||
first_tx_num,
|
||||
tx_count: progress.body.transactions.len() as u64,
|
||||
tx_count: progress.body().transactions.len() as u64,
|
||||
};
|
||||
|
||||
first_tx_num = next_tx_num;
|
||||
|
||||
@ -520,11 +520,12 @@ mod tests {
|
||||
accounts.iter().map(|(addr, acc)| (*addr, (*acc, std::iter::empty()))),
|
||||
)?;
|
||||
|
||||
let SealedBlock { header, body } = random_block(
|
||||
let (header, body) = random_block(
|
||||
&mut rng,
|
||||
stage_progress,
|
||||
BlockParams { parent: preblocks.last().map(|b| b.hash()), ..Default::default() },
|
||||
);
|
||||
)
|
||||
.split_header_body();
|
||||
let mut header = header.unseal();
|
||||
|
||||
header.state_root = state_root(
|
||||
@ -533,7 +534,7 @@ mod tests {
|
||||
.into_iter()
|
||||
.map(|(address, account)| (address, (account, std::iter::empty()))),
|
||||
);
|
||||
let sealed_head = SealedBlock { header: SealedHeader::seal(header), body };
|
||||
let sealed_head = SealedBlock::new(SealedHeader::seal(header), body);
|
||||
|
||||
let head_hash = sealed_head.hash();
|
||||
let mut blocks = vec![sealed_head];
|
||||
|
||||
@ -267,8 +267,8 @@ mod tests {
|
||||
let mut receipts = Vec::with_capacity(blocks.len());
|
||||
let mut tx_num = 0u64;
|
||||
for block in &blocks {
|
||||
let mut block_receipts = Vec::with_capacity(block.body.transactions.len());
|
||||
for transaction in &block.body.transactions {
|
||||
let mut block_receipts = Vec::with_capacity(block.body().transactions.len());
|
||||
for transaction in &block.body().transactions {
|
||||
block_receipts.push((tx_num, random_receipt(&mut rng, transaction, Some(0))));
|
||||
tx_num += 1;
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ mod tests {
|
||||
);
|
||||
self.db.insert_blocks(blocks.iter(), StorageKind::Static)?;
|
||||
self.db.insert_transaction_senders(
|
||||
blocks.iter().flat_map(|block| block.body.transactions.iter()).enumerate().map(
|
||||
blocks.iter().flat_map(|block| block.body().transactions.iter()).enumerate().map(
|
||||
|(i, tx)| (i as u64, tx.recover_signer().expect("failed to recover signer")),
|
||||
),
|
||||
)?;
|
||||
|
||||
@ -477,7 +477,7 @@ mod tests {
|
||||
let expected_progress = seed
|
||||
.iter()
|
||||
.find(|x| {
|
||||
tx_count += x.body.transactions.len();
|
||||
tx_count += x.body().transactions.len();
|
||||
tx_count as u64 > threshold
|
||||
})
|
||||
.map(|x| x.number)
|
||||
@ -536,7 +536,7 @@ mod tests {
|
||||
let mut tx_senders = Vec::new();
|
||||
let mut tx_number = 0;
|
||||
for block in &blocks[..=max_processed_block] {
|
||||
for transaction in &block.body.transactions {
|
||||
for transaction in &block.body().transactions {
|
||||
if block.number > max_pruned_block {
|
||||
tx_senders
|
||||
.push((tx_number, transaction.recover_signer().expect("recover signer")));
|
||||
@ -555,7 +555,7 @@ mod tests {
|
||||
tx_number: Some(
|
||||
blocks[..=max_pruned_block as usize]
|
||||
.iter()
|
||||
.map(|block| block.body.transactions.len() as u64)
|
||||
.map(|block| block.body().transactions.len() as u64)
|
||||
.sum(),
|
||||
),
|
||||
prune_mode: PruneMode::Full,
|
||||
@ -570,9 +570,9 @@ mod tests {
|
||||
EntitiesCheckpoint {
|
||||
processed: blocks[..=max_processed_block]
|
||||
.iter()
|
||||
.map(|block| block.body.transactions.len() as u64)
|
||||
.map(|block| block.body().transactions.len() as u64)
|
||||
.sum(),
|
||||
total: blocks.iter().map(|block| block.body.transactions.len() as u64).sum()
|
||||
total: blocks.iter().map(|block| block.body().transactions.len() as u64).sum()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ mod tests {
|
||||
let mut tx_hash_numbers = Vec::new();
|
||||
let mut tx_hash_number = 0;
|
||||
for block in &blocks[..=max_processed_block] {
|
||||
for transaction in &block.body.transactions {
|
||||
for transaction in &block.body().transactions {
|
||||
if block.number > max_pruned_block {
|
||||
tx_hash_numbers.push((transaction.hash(), tx_hash_number));
|
||||
}
|
||||
@ -403,7 +403,7 @@ mod tests {
|
||||
tx_number: Some(
|
||||
blocks[..=max_pruned_block as usize]
|
||||
.iter()
|
||||
.map(|block| block.body.transactions.len() as u64)
|
||||
.map(|block| block.body().transactions.len() as u64)
|
||||
.sum::<u64>()
|
||||
.sub(1), // `TxNumber` is 0-indexed
|
||||
),
|
||||
@ -419,9 +419,9 @@ mod tests {
|
||||
EntitiesCheckpoint {
|
||||
processed: blocks[..=max_processed_block]
|
||||
.iter()
|
||||
.map(|block| block.body.transactions.len() as u64)
|
||||
.map(|block| block.body().transactions.len() as u64)
|
||||
.sum(),
|
||||
total: blocks.iter().map(|block| block.body.transactions.len() as u64).sum()
|
||||
total: blocks.iter().map(|block| block.body().transactions.len() as u64).sum()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -252,10 +252,10 @@ impl TestStageDB {
|
||||
// Insert into body tables.
|
||||
let block_body_indices = StoredBlockBodyIndices {
|
||||
first_tx_num: next_tx_num,
|
||||
tx_count: block.body.transactions.len() as u64,
|
||||
tx_count: block.body().transactions.len() as u64,
|
||||
};
|
||||
|
||||
if !block.body.transactions.is_empty() {
|
||||
if !block.body().transactions.is_empty() {
|
||||
tx.put::<tables::TransactionBlocks>(
|
||||
block_body_indices.last_tx_num(),
|
||||
block.number,
|
||||
@ -263,7 +263,7 @@ impl TestStageDB {
|
||||
}
|
||||
tx.put::<tables::BlockBodyIndices>(block.number, block_body_indices)?;
|
||||
|
||||
let res = block.body.transactions.iter().try_for_each(|body_tx| {
|
||||
let res = block.body().transactions.iter().try_for_each(|body_tx| {
|
||||
if let Some(txs_writer) = &mut txs_writer {
|
||||
txs_writer.append_transaction(next_tx_num, body_tx)?;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user