From 76bdffc0554c60e6b3771fa6d74da5c9a40249a8 Mon Sep 17 00:00:00 2001 From: Evgenii P Date: Sat, 25 May 2019 18:43:34 +0700 Subject: [PATCH 1/2] txhashset.rs: make self references immutable in getters --- chain/src/txhashset/txhashset.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index 545c3a715e..a980e25760 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -642,7 +642,7 @@ impl<'a> HeaderExtension<'a> { /// Get the header at the specified height based on the current state of the header extension. /// Derives the MMR pos from the height (insertion index) and retrieves the header hash. /// Looks the header up in the db by hash. - pub fn get_header_by_height(&mut self, height: u64) -> Result { + pub fn get_header_by_height(&self, height: u64) -> Result { let pos = pmmr::insertion_to_pmmr_index(height + 1); if let Some(hash) = self.get_header_hash(pos) { let header = self.batch.get_block_header(&hash)?; @@ -654,7 +654,7 @@ impl<'a> HeaderExtension<'a> { /// Compares the provided header to the header in the header MMR at that height. /// If these match we know the header is on the current chain. - pub fn is_on_current_chain(&mut self, header: &BlockHeader) -> Result<(), Error> { + pub fn is_on_current_chain(&self, header: &BlockHeader) -> Result<(), Error> { let chain_header = self.get_header_by_height(header.height)?; if chain_header.hash() == header.hash() { Ok(()) @@ -991,7 +991,7 @@ impl<'a> Extension<'a> { /// Compares the provided header to the header in the header MMR at that height. /// If these match we know the header is on the current chain. - pub fn is_on_current_chain(&mut self, header: &BlockHeader) -> Result<(), Error> { + pub fn is_on_current_chain(&self, header: &BlockHeader) -> Result<(), Error> { let chain_header = self.get_header_by_height(header.height)?; if chain_header.hash() == header.hash() { Ok(()) From 3b7aff9cbee1eb6e90a071741664be4051981584 Mon Sep 17 00:00:00 2001 From: Evgenii P Date: Sat, 25 May 2019 18:43:46 +0700 Subject: [PATCH 2/2] rustfmt --- chain/src/txhashset/txhashset.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index a980e25760..793a8e2706 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -949,7 +949,9 @@ impl<'a> Extension<'a> { } if output_pos != rproof_pos { - return Err(ErrorKind::Other(format!("output vs rproof MMRs different pos")).into()); + return Err( + ErrorKind::Other(format!("output vs rproof MMRs different pos")).into(), + ); } }