From 11d2d2cce923c2a1ab1f5794e995778785635dd8 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 1 Feb 2023 15:13:22 -0800 Subject: [PATCH] Update redb to 0.12.1 (#1329) --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- src/index.rs | 11 ++++++----- src/index/updater.rs | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5181cee173..7a9e511663 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2403,9 +2403,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.17.3" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28fcd1e73f06ec85bf3280c48c67e731d8290ad3d730f8be9dc07946923005c8" +checksum = "9cd09fe469834db21ee60e0051030339e5d361293d8cb5ec02facf7fdcf52dbf" dependencies = [ "once_cell", "target-lexicon", @@ -2521,9 +2521,9 @@ dependencies = [ [[package]] name = "redb" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f8b4cc3bef0a4f1ef5953df24395705e4b53d44000fa1169d0a9cdab2d5bd92" +checksum = "104c124eba7be2bc4c2c9f97d1abfdc8d8f3e0fc16fe95c030dcbebd4860a749" dependencies = [ "libc", "pyo3-build-config", diff --git a/Cargo.toml b/Cargo.toml index a10c6762de..ac1e25078c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ mime = "0.3.16" mime_guess = "2.0.4" miniscript = "9.0.0" ord-bitcoincore-rpc = "0.16.5" -redb = "0.11.0" +redb = "0.12.1" regex = "1.6.0" rss = "2.0.1" rust-embed = "6.4.0" diff --git a/src/index.rs b/src/index.rs index 43abdb60e6..1a51fdad36 100644 --- a/src/index.rs +++ b/src/index.rs @@ -155,7 +155,7 @@ impl Index { data_dir.join("index.redb") }; - let database = match unsafe { redb::Database::builder().open_mmapped(&path) } { + let database = match unsafe { Database::builder().open_mmapped(&path) } { Ok(database) => { let schema_version = database .begin_read()? @@ -215,7 +215,7 @@ impl Index { if options.index_sats { tx.open_table(OUTPOINT_TO_SAT_RANGES)? - .insert(&OutPoint::null().store(), &[])?; + .insert(&OutPoint::null().store(), [].as_slice())?; } tx.commit()?; @@ -551,6 +551,7 @@ impl Index { .open_table(SATPOINT_TO_INSCRIPTION_ID)?, outpoint, )? + .into_iter() .map(|(_satpoint, inscription_id)| inscription_id) .collect(), ) @@ -602,7 +603,7 @@ impl Index { let outpoint_to_sat_ranges = rtx.0.open_table(OUTPOINT_TO_SAT_RANGES)?; - for (key, value) in outpoint_to_sat_ranges.range([0; 36]..)? { + for (key, value) in outpoint_to_sat_ranges.range::<&[u8; 36]>(&[0; 36]..)? { let mut offset = 0; for chunk in value.value().chunks_exact(11) { let (start, end) = SatRange::load(chunk.try_into().unwrap()); @@ -696,7 +697,7 @@ impl Index { .database .begin_read()? .open_table(SATPOINT_TO_INSCRIPTION_ID)? - .range([0; 44]..)? + .range::<&[u8; 44]>(&[0; 44]..)? .map(|(satpoint, id)| (Entry::load(*satpoint.value()), Entry::load(*id.value()))) .take(n.unwrap_or(usize::MAX)) .collect(), @@ -878,7 +879,7 @@ impl Index { Ok( satpoint_to_id - .range(start..=end)? + .range::<&[u8; 44]>(&start..=&end)? .map(|(satpoint, id)| (Entry::load(*satpoint.value()), Entry::load(*id.value()))), ) } diff --git a/src/index/updater.rs b/src/index/updater.rs index 32640d5266..876cdf7b7a 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -389,7 +389,7 @@ impl Updater { lost_sats += end - start; } - outpoint_to_sat_ranges.insert(&OutPoint::null().store(), &lost_sat_ranges)?; + outpoint_to_sat_ranges.insert(&OutPoint::null().store(), lost_sat_ranges.as_slice())?; } } else { for (tx, txid) in block.txdata.iter().skip(1).chain(block.txdata.first()) { @@ -495,7 +495,7 @@ impl Updater { let mut outpoint_to_sat_ranges = wtx.open_table(OUTPOINT_TO_SAT_RANGES)?; for (outpoint, sat_range) in self.range_cache.drain() { - outpoint_to_sat_ranges.insert(&outpoint, &sat_range)?; + outpoint_to_sat_ranges.insert(&outpoint, sat_range.as_slice())?; } self.outputs_inserted_since_flush = 0;