header docs and fixed header default

This commit is contained in:
debris 2016-02-02 18:21:31 +01:00
parent 38dfa18e8c
commit bb2104d312

View File

@ -13,39 +13,39 @@ pub type BlockNumber = u64;
/// which is non-specific. /// which is non-specific.
/// ///
/// Doesn't do all that much on its own. /// Doesn't do all that much on its own.
#[derive(Default, Debug, Clone)] #[derive(Debug, Clone)]
pub struct Header { pub struct Header {
// TODO: make all private. // TODO: make all private.
/// TODO [Gav Wood] Please document me /// Parent hash.
pub parent_hash: H256, pub parent_hash: H256,
/// TODO [arkpar] Please document me /// Block timestamp.
pub timestamp: u64, pub timestamp: u64,
/// TODO [debris] Please document me /// Block number.
pub number: BlockNumber, pub number: BlockNumber,
/// TODO [Gav Wood] Please document me /// Block author.
pub author: Address, pub author: Address,
/// TODO [debris] Please document me /// Transactions root.
pub transactions_root: H256, pub transactions_root: H256,
/// TODO [debris] Please document me /// Block uncles hash.
pub uncles_hash: H256, pub uncles_hash: H256,
/// TODO [Gav Wood] Please document me /// Block extra data.
pub extra_data: Bytes, pub extra_data: Bytes,
/// TODO [debris] Please document me /// State root.
pub state_root: H256, pub state_root: H256,
/// TODO [debris] Please document me /// Block receipts root.
pub receipts_root: H256, pub receipts_root: H256,
/// TODO [debris] Please document me /// Block bloom.
pub log_bloom: LogBloom, pub log_bloom: LogBloom,
/// TODO [debris] Please document me /// Gas used for contracts execution.
pub gas_used: U256, pub gas_used: U256,
/// TODO [Gav Wood] Please document me /// Block gas limit.
pub gas_limit: U256, pub gas_limit: U256,
/// TODO [debris] Please document me /// Block difficulty.
pub difficulty: U256, pub difficulty: U256,
/// TODO [arkpar] Please document me /// Block seal.
pub seal: Vec<Bytes>, pub seal: Vec<Bytes>,
/// TODO [arkpar] Please document me /// TODO [arkpar] Please document me
@ -54,9 +54,8 @@ pub struct Header {
pub bare_hash: RefCell<Option<H256>>, pub bare_hash: RefCell<Option<H256>>,
} }
impl Header { impl Default for Header {
/// Create a new, default-valued, header. fn default() -> Self {
pub fn new() -> Header {
Header { Header {
parent_hash: ZERO_H256.clone(), parent_hash: ZERO_H256.clone(),
timestamp: 0, timestamp: 0,
@ -79,6 +78,13 @@ impl Header {
bare_hash: RefCell::new(None), bare_hash: RefCell::new(None),
} }
} }
}
impl Header {
/// Create a new, default-valued, header.
pub fn new() -> Self {
Self::default()
}
/// TODO [Gav Wood] Please document me /// TODO [Gav Wood] Please document me
pub fn number(&self) -> BlockNumber { self.number } pub fn number(&self) -> BlockNumber { self.number }