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

Reserve runes AAAAAAAAAAAAAAAAAAAAAAAAAAA and above #2831

Merged
merged 14 commits into from
Dec 14, 2023
3 changes: 2 additions & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod updater;
#[cfg(test)]
pub(crate) mod testing;

const SCHEMA_VERSION: u64 = 13;
const SCHEMA_VERSION: u64 = 14;

macro_rules! define_table {
($name:ident, $key:ty, $value:ty) => {
Expand Down Expand Up @@ -91,6 +91,7 @@ pub(crate) enum Statistic {
IndexSats,
LostSats,
OutputsTraversed,
ReservedRunes,
Runes,
SatRanges,
UnboundInscriptions,
Expand Down
30 changes: 27 additions & 3 deletions src/index/updater/rune_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,34 @@ impl<'a, 'db, 'tx> RuneUpdater<'a, 'db, 'tx> {
// Determine if this runestone contains a valid issuance
let mut allocation = match runestone.etching {
Some(etching) => {
// If the issuance symbol is already taken, the issuance is ignored
if etching.rune < self.minimum || self.rune_to_id.get(etching.rune.0)?.is_some() {
if etching
.rune
.map(|rune| rune < self.minimum || rune.is_reserved())
.unwrap_or_default()
|| etching
.rune
.and_then(|rune| self.rune_to_id.get(rune.0).transpose())
.transpose()?
.is_some()
{
None
} else {
let rune = if let Some(rune) = etching.rune {
rune
} else {
let reserved_runes = self
.statistic_to_count
.get(&Statistic::ReservedRunes.into())?
.map(|entry| entry.value())
.unwrap_or_default();

self
.statistic_to_count
.insert(&Statistic::ReservedRunes.into(), reserved_runes + 1)?;

Rune::reserved(reserved_runes.into())
};

casey marked this conversation as resolved.
Show resolved Hide resolved
let (limit, term) = match (etching.limit, etching.term) {
(None, Some(term)) => (Some(runes::MAX_LIMIT), Some(term)),
(limit, term) => (limit, term),
Expand All @@ -96,7 +120,7 @@ impl<'a, 'db, 'tx> RuneUpdater<'a, 'db, 'tx> {
limit,
divisibility: etching.divisibility,
id: u128::from(self.height) << 16 | u128::from(index),
rune: etching.rune,
rune,
symbol: etching.symbol,
end: term.map(|term| term + self.height),
}),
Expand Down
Loading
Loading