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

Multi parent #2839

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 3 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 All @@ -57,6 +57,7 @@ macro_rules! define_multimap_table {
define_multimap_table! { SATPOINT_TO_SEQUENCE_NUMBER, &SatPointValue, u32 }
define_multimap_table! { SAT_TO_SEQUENCE_NUMBER, u64, u32 }
define_multimap_table! { SEQUENCE_NUMBER_TO_CHILDREN, u32, u32 }
define_multimap_table! { SEQUENCE_NUMBER_TO_PARENTS, u32, u32 }
define_table! { HEIGHT_TO_BLOCK_HASH, u32, &BlockHashValue }
define_table! { HEIGHT_TO_LAST_SEQUENCE_NUMBER, u32, u32 }
define_table! { HOME_INSCRIPTIONS, u32, InscriptionIdValue }
Expand Down Expand Up @@ -287,6 +288,7 @@ impl Index {
tx.open_multimap_table(SATPOINT_TO_SEQUENCE_NUMBER)?;
tx.open_multimap_table(SAT_TO_SEQUENCE_NUMBER)?;
tx.open_multimap_table(SEQUENCE_NUMBER_TO_CHILDREN)?;
tx.open_multimap_table(SEQUENCE_NUMBER_TO_PARENTS)?;
tx.open_table(HEIGHT_TO_BLOCK_HASH)?;
tx.open_table(HEIGHT_TO_LAST_SEQUENCE_NUMBER)?;
tx.open_table(HOME_INSCRIPTIONS)?;
Expand Down
1 change: 0 additions & 1 deletion src/index/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ pub(crate) struct InscriptionEntry {
pub(crate) height: u32,
pub(crate) id: InscriptionId,
pub(crate) inscription_number: i32,
pub(crate) parent: Option<u32>,
pub(crate) sat: Option<Sat>,
pub(crate) sequence_number: u32,
pub(crate) timestamp: u32,
Expand Down
2 changes: 2 additions & 0 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ impl<'index> Updater<'_> {
let mut sat_to_sequence_number = wtx.open_multimap_table(SAT_TO_SEQUENCE_NUMBER)?;
let mut satpoint_to_sequence_number = wtx.open_multimap_table(SATPOINT_TO_SEQUENCE_NUMBER)?;
let mut sequence_number_to_children = wtx.open_multimap_table(SEQUENCE_NUMBER_TO_CHILDREN)?;
let mut sequence_number_to_parents = wtx.open_multimap_table(SEQUENCE_NUMBER_TO_PARENTS)?;
let mut sequence_number_to_inscription_entry =
wtx.open_table(SEQUENCE_NUMBER_TO_INSCRIPTION_ENTRY)?;
let mut sequence_number_to_satpoint = wtx.open_table(SEQUENCE_NUMBER_TO_SATPOINT)?;
Expand Down Expand Up @@ -438,6 +439,7 @@ impl<'index> Updater<'_> {
satpoint_to_sequence_number: &mut satpoint_to_sequence_number,
sequence_number_to_children: &mut sequence_number_to_children,
sequence_number_to_entry: &mut sequence_number_to_inscription_entry,
sequence_number_to_parents: &mut sequence_number_to_parents,
sequence_number_to_satpoint: &mut sequence_number_to_satpoint,
timestamp: block.header.time,
unbound_inscriptions,
Expand Down
6 changes: 5 additions & 1 deletion src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub(super) struct InscriptionUpdater<'a, 'db, 'tx> {
&'a mut MultimapTable<'db, 'tx, &'static SatPointValue, u32>,
pub(super) sequence_number_to_children: &'a mut MultimapTable<'db, 'tx, u32, u32>,
pub(super) sequence_number_to_entry: &'a mut Table<'db, 'tx, u32, InscriptionEntryValue>,
pub(super) sequence_number_to_parents: &'a mut MultimapTable<'db, 'tx, u32, u32>,
pub(super) sequence_number_to_satpoint: &'a mut Table<'db, 'tx, u32, &'static SatPointValue>,
pub(super) timestamp: u32,
pub(super) unbound_inscriptions: u64,
Expand Down Expand Up @@ -475,14 +476,17 @@ impl<'a, 'db, 'tx> InscriptionUpdater<'a, 'db, 'tx> {
height: self.height,
id: inscription_id,
inscription_number,
parent,
sat,
sequence_number,
timestamp: self.timestamp,
}
.store(),
)?;

self
.sequence_number_to_parents
.insert(sequence_number, parent)?;

self
.id_to_sequence_number
.insert(&inscription_id.store(), sequence_number)?;
Expand Down
Loading