aboutsummaryrefslogtreecommitdiff
path: root/src/block/manager.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/block/manager.rs')
-rw-r--r--src/block/manager.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs
index 50039d2b..f34d13d0 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -547,9 +547,7 @@ impl BlockManager {
// - Ok(false) -> no block was processed, but we are ready for the next iteration
// - Err(_) -> a Sled error occurred when reading/writing from resync_queue/resync_errors
async fn resync_iter(&self, must_exit: &mut watch::Receiver<bool>) -> Result<bool, db::Error> {
- if let Some(first_pair_res) = self.resync_queue.iter()?.next() {
- let (time_bytes, hash_bytes) = first_pair_res?;
-
+ if let Some((time_bytes, hash_bytes)) = self.resync_get_next()? {
let time_msec = u64::from_be_bytes(time_bytes[0..8].try_into().unwrap());
let now = now_msec();
@@ -642,6 +640,16 @@ impl BlockManager {
}
}
+ fn resync_get_next(&self) -> Result<Option<(Vec<u8>, Vec<u8>)>, db::Error> {
+ match self.resync_queue.iter()?.next() {
+ None => Ok(None),
+ Some(v) => {
+ let (time_bytes, hash_bytes) = v?;
+ Ok(Some((time_bytes.into_owned(), hash_bytes.into_owned())))
+ }
+ }
+ }
+
async fn resync_block(&self, hash: &Hash) -> Result<(), Error> {
let BlockStatus { exists, needed } = self
.mutation_lock