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

Runes review #3605

Merged
merged 4 commits into from
Apr 18, 2024
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
7 changes: 5 additions & 2 deletions src/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Decimal {

impl Display for Decimal {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let magnitude = 10u128.pow(self.scale.into());
let magnitude = 10u128.checked_pow(self.scale.into()).ok_or(fmt::Error)?;

let integer = self.value / magnitude;
let mut fraction = self.value % magnitude;
Expand Down Expand Up @@ -68,7 +68,10 @@ impl FromStr for Decimal {
} else {
let trailing_zeros = decimal.chars().rev().take_while(|c| *c == '0').count();
let significant_digits = decimal.chars().count() - trailing_zeros;
let decimal = decimal.parse::<u128>()? / 10u128.pow(u32::try_from(trailing_zeros).unwrap());
let decimal = decimal.parse::<u128>()?
/ 10u128
.checked_pow(u32::try_from(trailing_zeros).unwrap())
.context("excessive trailing zeros")?;
(decimal, u8::try_from(significant_digits).unwrap())
};

Expand Down
6 changes: 3 additions & 3 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1782,12 +1782,12 @@ impl Index {
};

let max_id = RuneId {
block: block_height + 1,
tx: 0,
block: block_height,
tx: u32::MAX,
};

let runes = rune_id_to_rune_entry
.range(min_id.store()..max_id.store())?
.range(min_id.store()..=max_id.store())?
.map(|result| result.map(|(_, entry)| RuneEntry::load(entry.value()).spaced_rune))
.collect::<Result<Vec<SpacedRune>, StorageError>>()?;

Expand Down
3 changes: 1 addition & 2 deletions src/index/updater/rune_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> {
.unwrap_or_default();

// assign all un-allocated runes to the default output, or the first non
// OP_RETURN output if there is no default, or if the default output is
// too large
// OP_RETURN output if there is no default
if let Some(vout) = pointer
.map(|pointer| pointer.into_usize())
.inspect(|&pointer| assert!(pointer < allocated.len()))
Expand Down
Loading