mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
txhashset: remove unnecessary mutability from self references in getters (#2844)
* txhashset.rs: make self references immutable in getters * rustfmt
This commit is contained in:
parent
9f28e6aaa3
commit
a2a350dac7
1 changed files with 6 additions and 4 deletions
|
@ -642,7 +642,7 @@ impl<'a> HeaderExtension<'a> {
|
||||||
/// Get the header at the specified height based on the current state of the header extension.
|
/// 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.
|
/// Derives the MMR pos from the height (insertion index) and retrieves the header hash.
|
||||||
/// Looks the header up in the db by hash.
|
/// Looks the header up in the db by hash.
|
||||||
pub fn get_header_by_height(&mut self, height: u64) -> Result<BlockHeader, Error> {
|
pub fn get_header_by_height(&self, height: u64) -> Result<BlockHeader, Error> {
|
||||||
let pos = pmmr::insertion_to_pmmr_index(height + 1);
|
let pos = pmmr::insertion_to_pmmr_index(height + 1);
|
||||||
if let Some(hash) = self.get_header_hash(pos) {
|
if let Some(hash) = self.get_header_hash(pos) {
|
||||||
let header = self.batch.get_block_header(&hash)?;
|
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.
|
/// 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.
|
/// 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)?;
|
let chain_header = self.get_header_by_height(header.height)?;
|
||||||
if chain_header.hash() == header.hash() {
|
if chain_header.hash() == header.hash() {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -949,7 +949,9 @@ impl<'a> Extension<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if output_pos != rproof_pos {
|
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(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -991,7 +993,7 @@ impl<'a> Extension<'a> {
|
||||||
|
|
||||||
/// Compares the provided header to the header in the header MMR at that height.
|
/// 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.
|
/// 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)?;
|
let chain_header = self.get_header_by_height(header.height)?;
|
||||||
if chain_header.hash() == header.hash() {
|
if chain_header.hash() == header.hash() {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue