Make the block header struct's internals private (#2000)
* Make the block header struct's internals private Currently, this involves a lot of explicit cloning, but we could migrate the return types of the get_* functions to be copies rather than references since they are mostly copy types anyway. I opted to eliminate the constructor in favor of using Default::default() plus calling a bunch of setters. This is similar to the model that a Google Protobuf client uses and I think it looks fine. * Drop some unnecessary cloning by comparing references * Fix compiler errors from callsites in tests.
This commit is contained in:
committed by
Arkadiy Paronyan
parent
2d883c43c9
commit
4389742ca3
@@ -158,22 +158,22 @@ impl<C, S: ?Sized, M, EM> EthClient<C, S, M, EM> where
|
||||
let block = Block {
|
||||
hash: Some(uncle.hash().into()),
|
||||
size: None,
|
||||
parent_hash: uncle.parent_hash.into(),
|
||||
uncles_hash: uncle.uncles_hash.into(),
|
||||
author: uncle.author.into(),
|
||||
miner: uncle.author.into(),
|
||||
state_root: uncle.state_root.into(),
|
||||
transactions_root: uncle.transactions_root.into(),
|
||||
number: Some(uncle.number.into()),
|
||||
gas_used: uncle.gas_used.into(),
|
||||
gas_limit: uncle.gas_limit.into(),
|
||||
logs_bloom: uncle.log_bloom.into(),
|
||||
timestamp: uncle.timestamp.into(),
|
||||
difficulty: uncle.difficulty.into(),
|
||||
total_difficulty: (uncle.difficulty + parent_difficulty).into(),
|
||||
receipts_root: uncle.receipts_root.into(),
|
||||
extra_data: uncle.extra_data.into(),
|
||||
seal_fields: uncle.seal.into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
|
||||
parent_hash: uncle.parent_hash().clone().into(),
|
||||
uncles_hash: uncle.uncles_hash().clone().into(),
|
||||
author: uncle.author().clone().into(),
|
||||
miner: uncle.author().clone().into(),
|
||||
state_root: uncle.state_root().clone().into(),
|
||||
transactions_root: uncle.transactions_root().clone().into(),
|
||||
number: Some(uncle.number().into()),
|
||||
gas_used: uncle.gas_used().clone().into(),
|
||||
gas_limit: uncle.gas_limit().clone().into(),
|
||||
logs_bloom: uncle.log_bloom().clone().into(),
|
||||
timestamp: uncle.timestamp().into(),
|
||||
difficulty: uncle.difficulty().clone().into(),
|
||||
total_difficulty: (uncle.difficulty().clone() + parent_difficulty).into(),
|
||||
receipts_root: uncle.receipts_root().clone().into(),
|
||||
extra_data: uncle.extra_data().clone().into(),
|
||||
seal_fields: uncle.seal().clone().into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
|
||||
uncles: vec![],
|
||||
transactions: BlockTransactions::Hashes(vec![]),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user