From 40c745e540e306b83b8e145ca57cce9474196c46 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 13 Oct 2020 07:42:44 +1000 Subject: [PATCH] Keep check.rs functions in alphabetical order --- zebra-consensus/src/block/check.rs | 50 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/zebra-consensus/src/block/check.rs b/zebra-consensus/src/block/check.rs index 5891804e8..9386a35c8 100644 --- a/zebra-consensus/src/block/check.rs +++ b/zebra-consensus/src/block/check.rs @@ -72,31 +72,6 @@ pub fn equihash_solution_is_valid(header: &Header) -> Result<(), equihash::Error header.solution.check(&header) } -/// Returns `Ok(())` if `header.time` is less than or equal to -/// 2 hours in the future, according to the node's local clock (`now`). -/// -/// This is a non-deterministic rule, as clocks vary over time, and -/// between different nodes. -/// -/// "In addition, a full validator MUST NOT accept blocks with nTime -/// more than two hours in the future according to its clock. This -/// is not strictly a consensus rule because it is nondeterministic, -/// and clock time varies between nodes. Also note that a block that -/// is rejected by this rule at a given point in time may later be -/// accepted." [§7.5][7.5] -/// -/// [7.5]: https://zips.z.cash/protocol/protocol.pdf#blockheader -/// -/// If the header time is invalid, returns an error containing `height` and `hash`. -pub fn time_is_valid_at( - header: &Header, - now: DateTime, - height: &Height, - hash: &Hash, -) -> Result<(), zebra_chain::block::BlockTimeError> { - header.time_is_valid_at(now, height, hash) -} - /// Returns `Ok(())` if the block subsidy and miner fees in `block` are valid for `network` /// /// [3.9]: https://zips.z.cash/protocol/protocol.pdf#subsidyconcepts @@ -141,3 +116,28 @@ pub fn subsidy_is_valid(block: &Block, network: Network) -> Result<(), BlockErro Ok(()) } } + +/// Returns `Ok(())` if `header.time` is less than or equal to +/// 2 hours in the future, according to the node's local clock (`now`). +/// +/// This is a non-deterministic rule, as clocks vary over time, and +/// between different nodes. +/// +/// "In addition, a full validator MUST NOT accept blocks with nTime +/// more than two hours in the future according to its clock. This +/// is not strictly a consensus rule because it is nondeterministic, +/// and clock time varies between nodes. Also note that a block that +/// is rejected by this rule at a given point in time may later be +/// accepted." [§7.5][7.5] +/// +/// [7.5]: https://zips.z.cash/protocol/protocol.pdf#blockheader +/// +/// If the header time is invalid, returns an error containing `height` and `hash`. +pub fn time_is_valid_at( + header: &Header, + now: DateTime, + height: &Height, + hash: &Hash, +) -> Result<(), zebra_chain::block::BlockTimeError> { + header.time_is_valid_at(now, height, hash) +}