From d67cac7f6ae7707dab7048a3b284d8541d39e4b6 Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Mon, 18 Jun 2018 13:23:15 -0700 Subject: [PATCH] attempt to understand entry --- src/entry.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/entry.rs b/src/entry.rs index e805cb50d4dea4..03d163606b2da8 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -84,8 +84,9 @@ fn add_transaction_data(hash_data: &mut Vec, tx: &Transaction) { /// Creates the hash `num_hashes` after `start_hash`. If the transaction contains /// a signature, the final hash will be a hash of both the previous ID and -/// the signature. -pub fn next_hash(start_hash: &Hash, num_hashes: u64, transactions: &[Transaction]) -> Hash { +/// the signature. If num_hashes is zero and there's no transaction data, +// start_hash is returned. +fn next_hash(start_hash: &Hash, num_hashes: u64, transactions: &[Transaction]) -> Hash { let mut id = *start_hash; for _ in 1..num_hashes { id = hash(&id); @@ -174,5 +175,9 @@ mod tests { let tick = next_entry(&zero, 1, vec![]); assert_eq!(tick.num_hashes, 1); assert_ne!(tick.id, zero); + + let tick = next_entry(&zero, 0, vec![]); + assert_eq!(tick.num_hashes, 0); + assert_eq!(tick.id, zero); } }