diff --git a/src/bin/dolos/doctor/rebuild_ledger.rs b/src/bin/dolos/doctor/rebuild_ledger.rs index 3a2a2173..1f8fdabe 100644 --- a/src/bin/dolos/doctor/rebuild_ledger.rs +++ b/src/bin/dolos/doctor/rebuild_ledger.rs @@ -26,7 +26,7 @@ pub fn run(config: &crate::Config, _args: &Args, feedback: &Feedback) -> miette: .into_diagnostic() .context("creating in-memory state store")?; - let mut light = dolos::state::LedgerStore::Redb(light); + let light = dolos::state::LedgerStore::Redb(light); if light .is_empty() @@ -81,7 +81,7 @@ pub fn run(config: &crate::Config, _args: &Args, feedback: &Feedback) -> miette: .into_diagnostic() .context("decoding blocks")?; - dolos::state::apply_block_batch(&blocks, &mut light, &genesis) + dolos::state::apply_block_batch(&blocks, &light, &genesis) .into_diagnostic() .context("importing blocks to ledger store")?; diff --git a/src/mempool.rs b/src/mempool.rs index 9ac60fd2..0003998a 100644 --- a/src/mempool.rs +++ b/src/mempool.rs @@ -211,7 +211,7 @@ impl Mempool { } } - pub fn apply_block(&mut self, block: &MultiEraBlock) { + pub fn apply_block(&self, block: &MultiEraBlock) { let mut state = self.mempool.write().unwrap(); if state.acknowledged.is_empty() { @@ -229,7 +229,7 @@ impl Mempool { } } - pub fn undo_block(&mut self, block: &MultiEraBlock) { + pub fn undo_block(&self, block: &MultiEraBlock) { let mut state = self.mempool.write().unwrap(); if state.acknowledged.is_empty() { diff --git a/src/state/mod.rs b/src/state/mod.rs index 3d2cf59b..a0e00972 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -121,13 +121,13 @@ impl LedgerStore { } } - pub fn apply(&mut self, deltas: &[LedgerDelta]) -> Result<(), LedgerError> { + pub fn apply(&self, deltas: &[LedgerDelta]) -> Result<(), LedgerError> { match self { LedgerStore::Redb(x) => x.apply(deltas), } } - pub fn finalize(&mut self, until: BlockSlot) -> Result<(), LedgerError> { + pub fn finalize(&self, until: BlockSlot) -> Result<(), LedgerError> { match self { LedgerStore::Redb(x) => x.finalize(until), } @@ -215,7 +215,7 @@ pub fn load_slice_for_block( pub fn apply_block_batch<'a>( blocks: impl IntoIterator>, - store: &mut LedgerStore, + store: &LedgerStore, genesis: &Genesis, ) -> Result<(), LedgerError> { let mut deltas: Vec = vec![]; diff --git a/src/state/redb/mod.rs b/src/state/redb/mod.rs index dd8ea95e..e64842b2 100644 --- a/src/state/redb/mod.rs +++ b/src/state/redb/mod.rs @@ -239,7 +239,7 @@ impl LedgerStore { } } - pub fn apply(&mut self, deltas: &[LedgerDelta]) -> Result<(), LedgerError> { + pub fn apply(&self, deltas: &[LedgerDelta]) -> Result<(), LedgerError> { match self { LedgerStore::SchemaV1(x) => Ok(x.apply(deltas)?), LedgerStore::SchemaV2(x) => Ok(x.apply(deltas)?), @@ -247,7 +247,7 @@ impl LedgerStore { } } - pub fn finalize(&mut self, until: BlockSlot) -> Result<(), LedgerError> { + pub fn finalize(&self, until: BlockSlot) -> Result<(), LedgerError> { match self { LedgerStore::SchemaV1(x) => Ok(x.finalize(until)?), LedgerStore::SchemaV2(x) => Ok(x.finalize(until)?), diff --git a/src/state/redb/v1.rs b/src/state/redb/v1.rs index 4d326d56..fd38f833 100644 --- a/src/state/redb/v1.rs +++ b/src/state/redb/v1.rs @@ -41,7 +41,7 @@ impl LedgerStore { tables::BlocksTable::last(&rx) } - pub fn apply(&mut self, deltas: &[LedgerDelta]) -> Result<(), Error> { + pub fn apply(&self, deltas: &[LedgerDelta]) -> Result<(), Error> { let mut wx = self.db().begin_write()?; wx.set_durability(Durability::Eventual); @@ -57,7 +57,7 @@ impl LedgerStore { Ok(()) } - pub fn finalize(&mut self, until: BlockSlot) -> Result<(), Error> { + pub fn finalize(&self, until: BlockSlot) -> Result<(), Error> { let rx = self.db().begin_read()?; let tss = tables::TombstonesTable::get_range(&rx, until)?; diff --git a/src/state/redb/v2.rs b/src/state/redb/v2.rs index 8cdb69c6..de0d697d 100644 --- a/src/state/redb/v2.rs +++ b/src/state/redb/v2.rs @@ -48,7 +48,7 @@ impl LedgerStore { Ok(last) } - pub fn apply(&mut self, deltas: &[LedgerDelta]) -> Result<(), Error> { + pub fn apply(&self, deltas: &[LedgerDelta]) -> Result<(), Error> { let mut wx = self.db().begin_write()?; wx.set_durability(Durability::Eventual); @@ -64,7 +64,7 @@ impl LedgerStore { Ok(()) } - pub fn finalize(&mut self, until: BlockSlot) -> Result<(), Error> { + pub fn finalize(&self, until: BlockSlot) -> Result<(), Error> { let rx = self.db().begin_read()?; let cursors = tables::CursorTable::get_range(&rx, until)?; diff --git a/src/state/redb/v2light.rs b/src/state/redb/v2light.rs index d31071b8..59eed722 100644 --- a/src/state/redb/v2light.rs +++ b/src/state/redb/v2light.rs @@ -48,7 +48,7 @@ impl LedgerStore { Ok(last) } - pub fn apply(&mut self, deltas: &[LedgerDelta]) -> Result<(), Error> { + pub fn apply(&self, deltas: &[LedgerDelta]) -> Result<(), Error> { let mut wx = self.db().begin_write()?; wx.set_durability(Durability::Eventual); @@ -63,7 +63,7 @@ impl LedgerStore { Ok(()) } - pub fn finalize(&mut self, until: BlockSlot) -> Result<(), Error> { + pub fn finalize(&self, until: BlockSlot) -> Result<(), Error> { let rx = self.db().begin_read()?; let cursors = tables::CursorTable::get_range(&rx, until)?;