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

Seed index with genesis rune #3426

Merged
merged 3 commits into from
Mar 31, 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
43 changes: 43 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,49 @@ impl Index {
Self::set_statistic(&mut statistics, Statistic::Schema, SCHEMA_VERSION)?;
}

if settings.index_runes() && settings.chain() == Chain::Mainnet {
let rune = Rune(2055900680524219742);

let id = RuneId { block: 1, tx: 0 };
let etching = Txid::all_zeros();

tx.open_table(RUNE_TO_RUNE_ID)?
.insert(rune.store(), id.store())?;

let mut statistics = tx.open_table(STATISTIC_TO_COUNT)?;

Self::set_statistic(&mut statistics, Statistic::Runes, 1)?;

tx.open_table(RUNE_ID_TO_RUNE_ENTRY)?.insert(
id.store(),
RuneEntry {
block: id.block,
burned: 0,
divisibility: 0,
etching,
terms: Some(Terms {
amount: Some(1),
cap: Some(u128::MAX),
height: (
Some((SUBSIDY_HALVING_INTERVAL * 4).into()),
Some((SUBSIDY_HALVING_INTERVAL * 5).into()),
),
offset: (None, None),
}),
mints: 0,
number: 0,
premine: 0,
spaced_rune: SpacedRune { rune, spacers: 128 },
symbol: Some('\u{29C9}'),
timestamp: 0,
}
.store(),
)?;

tx.open_table(TRANSACTION_ID_TO_RUNE)?
.insert(&etching.store(), rune.store())?;
}

tx.commit()?;

database
Expand Down
43 changes: 43 additions & 0 deletions src/runes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5386,4 +5386,47 @@ mod tests {

context.assert_runes([], []);
}

#[test]
fn genesis_rune() {
assert_eq!(
Chain::Mainnet.first_rune_height(),
SUBSIDY_HALVING_INTERVAL * 4,
);

Context::builder()
.chain(Chain::Mainnet)
.arg("--index-runes")
.build()
.assert_runes(
[(
RuneId { block: 1, tx: 0 },
RuneEntry {
block: 1,
burned: 0,
divisibility: 0,
etching: Txid::all_zeros(),
mints: 0,
number: 0,
premine: 0,
spaced_rune: SpacedRune {
rune: Rune(2055900680524219742),
spacers: 128,
},
symbol: Some('\u{29C9}'),
terms: Some(Terms {
amount: Some(1),
cap: Some(u128::MAX),
height: (
Some((SUBSIDY_HALVING_INTERVAL * 4).into()),
Some((SUBSIDY_HALVING_INTERVAL * 5).into()),
),
offset: (None, None),
}),
timestamp: 0,
},
)],
[],
);
}
}
Loading