From de2400031ceffa076d0baba9f62c79d82e8d4e74 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Thu, 10 Sep 2020 14:42:20 -0700 Subject: [PATCH] state: merge SledState::{queue, process_queue}. We never want to call one without the other, so just do them together. --- zebra-state/src/service.rs | 1 - zebra-state/src/sled_state.rs | 11 ++--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/zebra-state/src/service.rs b/zebra-state/src/service.rs index 12260128..9e688c05 100644 --- a/zebra-state/src/service.rs +++ b/zebra-state/src/service.rs @@ -56,7 +56,6 @@ impl Service for StateService { let (rsp_tx, rsp_rx) = oneshot::channel(); self.sled.queue(QueuedBlock { block, rsp_tx }); - self.sled.process_queue(); async move { rsp_rx diff --git a/zebra-state/src/sled_state.rs b/zebra-state/src/sled_state.rs index ecbfdc92..0d2ff586 100644 --- a/zebra-state/src/sled_state.rs +++ b/zebra-state/src/sled_state.rs @@ -60,19 +60,12 @@ impl SledState { /// Queue a finalized block to be committed to the state. /// - /// After queueing a finalized block, call [`process_queue`] to check whether - /// the newly queued block (and any of its descendants) can be committed to - /// the state. + /// After queueing a finalized block, this method checks whether the newly + /// queued block (and any of its descendants) can be committed to the state. pub fn queue(&mut self, queued_block: QueuedBlock) { let prev_hash = queued_block.block.header.previous_block_hash; self.queued_by_prev_hash.insert(prev_hash, queued_block); - } - /// Process the queue of finalized blocks, committing any that can be committed in-order. - /// - /// This should be called after [`queue`], to check whether the newly queued block - /// (and any of its descendants) can be committed to the state. - pub fn process_queue(&mut self) { // Cloning means the closure doesn't hold a borrow of &self, // conflicting with mutable access in the loop below. let hash_by_height = self.hash_by_height.clone();