Skip to content

Commit

Permalink
Update redb to 0.12.1 (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Feb 1, 2023
1 parent 075f394 commit 11d2d2c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
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

0 comments on commit 11d2d2c

Please sign in to comment.