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

Update to redb 0.0.5 #160

Merged
merged 1 commit into from
Feb 21, 2022
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
5 changes: 3 additions & 2 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 @@ -18,7 +18,7 @@ integer-cbrt = "0.1.2"
integer-sqrt = "0.1.5"
jsonrpc = "0.12.1"
log = "0.4.14"
redb = { version = "0.0.4", git = "https://github.com/cberner/redb.git" }
redb = "0.0.5"

[dev-dependencies]
criterion = "0.3.5"
Expand Down
11 changes: 7 additions & 4 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ impl Index {
let height_to_hash = tx.open_table(&Self::HEIGHT_TO_HASH)?;

let blocks_indexed = height_to_hash
.range_reversed(0..)?
.range(0..)?
.rev()
.next()
.map(|(height, _hash)| height + 1)
.unwrap_or(0);
Expand Down Expand Up @@ -103,7 +104,8 @@ impl Index {

let mut height_to_hash = wtx.open_table(&Self::HEIGHT_TO_HASH)?;
let height = height_to_hash
.range_reversed(0..)?
.range(0..)?
.rev()
.next()
.map(|(height, _hash)| height + 1)
.unwrap_or(0);
Expand Down Expand Up @@ -270,7 +272,7 @@ impl Index {
Err(err) => return Err(err.into()),
};

match height_to_hash.range_reversed(0..)?.next() {
match height_to_hash.range(0..)?.rev().next() {
Some((height, _hash)) if height >= ordinal.height().0 => {}
_ => return Ok(None),
}
Expand All @@ -282,7 +284,8 @@ impl Index {
};

match key_to_satpoint
.range_reversed([].as_slice()..=Key::new(ordinal).encode().as_slice())?
.range([].as_slice()..=Key::new(ordinal).encode().as_slice())?
.rev()
.next()
{
Some((start_key, start_satpoint)) => {
Expand Down