Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade redb to 0.12.0 #1329

Merged
merged 9 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?
Expand Down Expand Up @@ -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()?;
Expand Down Expand Up @@ -551,6 +551,7 @@ impl Index {
.open_table(SATPOINT_TO_INSCRIPTION_ID)?,
outpoint,
)?
.into_iter()
.map(|(_satpoint, inscription_id)| inscription_id)
.collect(),
)
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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()))),
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down