From 1f37792f2f1f262b1e1ea0a171696b2f1113f5fd Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 13:45:45 +0100 Subject: [PATCH 1/5] tapdb: rename BaseMultiverse to MultiverseStore --- config.go | 2 +- tapdb/multiverse.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index d22822f1c..a588d3fe8 100644 --- a/config.go +++ b/config.go @@ -67,7 +67,7 @@ type DatabaseConfig struct { TapAddrBook *tapdb.TapAddressBook - Multiverse *tapdb.BaseMultiverse + Multiverse *tapdb.MultiverseStore FederationDB *tapdb.UniverseFederationDB } diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index bc10df3ec..7de63394c 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -53,10 +53,10 @@ type BatchedMultiverse interface { BatchedTx[BaseMultiverseStore] } -// BaseMultiverse implements the persistent storage for a multiverse. +// MultiverseStore implements the persistent storage for a multiverse. // // NOTE: This implements the universe.BaseMultiverse interface. -type BaseMultiverse struct { +type MultiverseStore struct { db BatchedMultiverse // TODO(roasbeef): actually the start of multiverse? @@ -65,15 +65,15 @@ type BaseMultiverse struct { } // NewBaseMultiverse creates a new base multiverse. -func NewBaseMultiverse(db BatchedMultiverse) *BaseMultiverse { - return &BaseMultiverse{ +func NewBaseMultiverse(db BatchedMultiverse) *MultiverseStore { + return &MultiverseStore{ db: db, } } // RootNodes returns the complete set of known base universe root nodes for the // set of base universes tracked in the multiverse. -func (b *BaseMultiverse) RootNodes( +func (b *MultiverseStore) RootNodes( ctx context.Context) ([]universe.BaseRoot, error) { var ( @@ -135,7 +135,7 @@ func (b *BaseMultiverse) RootNodes( // doesn't have a script key specified, then all the proofs for the minting // outpoint will be returned. If neither are specified, then proofs for all the // inserted leaves will be returned. -func (b *BaseMultiverse) FetchIssuanceProof(ctx context.Context, +func (b *MultiverseStore) FetchIssuanceProof(ctx context.Context, id universe.Identifier, universeKey universe.BaseKey) ([]*universe.IssuanceProof, error) { @@ -194,7 +194,7 @@ func (b *BaseMultiverse) FetchIssuanceProof(ctx context.Context, // RegisterIssuance inserts a new minting leaf within the multiverse tree and // the universe tree that corresponds to the given base key. -func (b *BaseMultiverse) RegisterIssuance(ctx context.Context, +func (b *MultiverseStore) RegisterIssuance(ctx context.Context, id universe.Identifier, key universe.BaseKey, leaf *universe.MintingLeaf, metaReveal *proof.MetaReveal) (*universe.IssuanceProof, error) { @@ -276,7 +276,7 @@ func (b *BaseMultiverse) RegisterIssuance(ctx context.Context, // RegisterBatchIssuance inserts a new minting leaf batch within the multiverse // tree and the universe tree that corresponds to the given base key(s). -func (b *BaseMultiverse) RegisterBatchIssuance(ctx context.Context, +func (b *MultiverseStore) RegisterBatchIssuance(ctx context.Context, items []*universe.IssuanceItem) error { insertProof := func(item *universe.IssuanceItem, From 3f4fbbe653137e2aeebfe6da3d22d917681de26e Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 13:46:49 +0100 Subject: [PATCH 2/5] tapdb: rename NewBaseMultiverse to NewMultiverseStore --- tapcfg/server.go | 2 +- tapdb/multiverse.go | 4 ++-- tapdb/universe_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tapcfg/server.go b/tapcfg/server.go index acba44652..26a016f8a 100644 --- a/tapcfg/server.go +++ b/tapcfg/server.go @@ -115,7 +115,7 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger, return db.WithTx(tx) }, ) - multiverse := tapdb.NewBaseMultiverse(multiverseDB) + multiverse := tapdb.NewMultiverseStore(multiverseDB) uniStatsDB := tapdb.NewTransactionExecutor( db, func(tx *sql.Tx) tapdb.UniverseStatsStore { diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 7de63394c..6bf922c27 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -64,8 +64,8 @@ type MultiverseStore struct { // * drop base in front? } -// NewBaseMultiverse creates a new base multiverse. -func NewBaseMultiverse(db BatchedMultiverse) *MultiverseStore { +// NewMultiverseStore creates a new multiverse DB store handle. +func NewMultiverseStore(db BatchedMultiverse) *MultiverseStore { return &MultiverseStore{ db: db, } diff --git a/tapdb/universe_test.go b/tapdb/universe_test.go index e9e484d51..4ae13658c 100644 --- a/tapdb/universe_test.go +++ b/tapdb/universe_test.go @@ -400,7 +400,7 @@ func TestUniverseTreeIsolation(t *testing.T) { return db.WithTx(tx) }, ) - multiverse := NewBaseMultiverse(multiverseDB) + multiverse := NewMultiverseStore(multiverseDB) rootNodes, err := multiverse.RootNodes(ctx) require.NoError(t, err) From c81e4d11f3163eaac522c2dc8cac5084cd21c89d Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 15:02:03 +0100 Subject: [PATCH 3/5] tapdb: rename multiverse store RegisterIssuance to UpsertProofLeaf --- tapdb/multiverse.go | 6 +++--- universe/base.go | 2 +- universe/interface.go | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 6bf922c27..cac7097d4 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -192,9 +192,9 @@ func (b *MultiverseStore) FetchIssuanceProof(ctx context.Context, return proofs, nil } -// RegisterIssuance inserts a new minting leaf within the multiverse tree and -// the universe tree that corresponds to the given base key. -func (b *MultiverseStore) RegisterIssuance(ctx context.Context, +// UpsertProofLeaf upserts a proof leaf within the multiverse tree and the +// universe tree that corresponds to the given key. +func (b *MultiverseStore) UpsertProofLeaf(ctx context.Context, id universe.Identifier, key universe.BaseKey, leaf *universe.MintingLeaf, metaReveal *proof.MetaReveal) (*universe.IssuanceProof, error) { diff --git a/universe/base.go b/universe/base.go index 8d8e0879d..cc09a3f06 100644 --- a/universe/base.go +++ b/universe/base.go @@ -181,7 +181,7 @@ func (a *MintingArchive) RegisterIssuance(ctx context.Context, id Identifier, // Now that we know the proof is valid, we'll insert it into the base // multiverse backend, and return the new issuance proof. - issuanceProof, err := a.cfg.Multiverse.RegisterIssuance( + issuanceProof, err := a.cfg.Multiverse.UpsertProofLeaf( ctx, id, key, leaf, assetSnapshot.MetaReveal, ) if err != nil { diff --git a/universe/interface.go b/universe/interface.go index e568d4048..922f1b7d8 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -239,9 +239,9 @@ type BaseMultiverse interface { // of assets tracked in the base Universe. RootNodes(ctx context.Context) ([]BaseRoot, error) - // RegisterIssuance inserts a new minting (issuance) leaf within the - // multiverse tree, stored at the given base key. - RegisterIssuance(ctx context.Context, id Identifier, key BaseKey, + // UpsertProofLeaf upserts a proof leaf within the multiverse tree and + // the universe tree that corresponds to the given key. + UpsertProofLeaf(ctx context.Context, id Identifier, key BaseKey, leaf *MintingLeaf, metaReveal *proof.MetaReveal) (*IssuanceProof, error) From d352763614dfa6df947a8cbe89bd5166c10d4692 Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 15:14:18 +0100 Subject: [PATCH 4/5] universe: rename interface BaseMultiverse to MultiverseArchive --- tapdb/multiverse.go | 2 +- universe/base.go | 2 +- universe/interface.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index cac7097d4..9f671312c 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -55,7 +55,7 @@ type BatchedMultiverse interface { // MultiverseStore implements the persistent storage for a multiverse. // -// NOTE: This implements the universe.BaseMultiverse interface. +// NOTE: This implements the universe.MultiverseArchive interface. type MultiverseStore struct { db BatchedMultiverse diff --git a/universe/base.go b/universe/base.go index cc09a3f06..5f4e89c6d 100644 --- a/universe/base.go +++ b/universe/base.go @@ -28,7 +28,7 @@ type MintingArchiveConfig struct { // Multiverse is used to interact with the set of known base // universe trees, and also obtain associated metadata and statistics. - Multiverse BaseMultiverse + Multiverse MultiverseArchive // UniverseStats is used to export statistics related to the set of // external/internal queries to the base universe instance. diff --git a/universe/interface.go b/universe/interface.go index 922f1b7d8..f8a7761a0 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -230,11 +230,11 @@ type BaseRoot struct { AssetName string } -// BaseMultiverse is an interface used to keep track of the set of base universe +// MultiverseArchive is an interface used to keep track of the set of universe // roots that we know of. The BaseBackend interface is used to interact with a // particular base universe, while this is used to obtain aggregate information // about the universes. -type BaseMultiverse interface { +type MultiverseArchive interface { // RootNodes returns the complete set of known root nodes for the set // of assets tracked in the base Universe. RootNodes(ctx context.Context) ([]BaseRoot, error) From ae4ce245b64cb5d1f0f09dab4b0b6650b097d65e Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 8 Sep 2023 15:34:21 +0100 Subject: [PATCH 5/5] tapdb: rename multiverse store FetchIssuanceProof to FetchProofLeaf --- tapdb/multiverse.go | 10 +++++----- universe/base.go | 4 ++-- universe/interface.go | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tapdb/multiverse.go b/tapdb/multiverse.go index 9f671312c..a171dd718 100644 --- a/tapdb/multiverse.go +++ b/tapdb/multiverse.go @@ -131,11 +131,11 @@ func (b *MultiverseStore) RootNodes( return uniRoots, nil } -// FetchIssuanceProof returns an issuance proof for the target key. If the key -// doesn't have a script key specified, then all the proofs for the minting -// outpoint will be returned. If neither are specified, then proofs for all the -// inserted leaves will be returned. -func (b *MultiverseStore) FetchIssuanceProof(ctx context.Context, +// FetchProofLeaf returns a proof leaf for the target key. If the key +// doesn't have a script key specified, then all the proof leafs for the minting +// outpoint will be returned. If neither are specified, then all inserted proof +// leafs will be returned. +func (b *MultiverseStore) FetchProofLeaf(ctx context.Context, id universe.Identifier, universeKey universe.BaseKey) ([]*universe.IssuanceProof, error) { diff --git a/universe/base.go b/universe/base.go index 5f4e89c6d..f27fc09eb 100644 --- a/universe/base.go +++ b/universe/base.go @@ -143,7 +143,7 @@ func (a *MintingArchive) RegisterIssuance(ctx context.Context, id Identifier, // We'll first check to see if we already know of this leaf within the // multiverse. If so, then we'll return the existing issuance proof. - issuanceProofs, err := a.cfg.Multiverse.FetchIssuanceProof(ctx, id, key) + issuanceProofs, err := a.cfg.Multiverse.FetchProofLeaf(ctx, id, key) switch { case err == nil && len(issuanceProofs) > 0: issuanceProof := issuanceProofs[0] @@ -329,7 +329,7 @@ func (a *MintingArchive) FetchIssuanceProof(ctx context.Context, id Identifier, }() }() - return a.cfg.Multiverse.FetchIssuanceProof(ctx, id, key) + return a.cfg.Multiverse.FetchProofLeaf(ctx, id, key) } // MintingKeys returns the set of minting keys known for the specified base diff --git a/universe/interface.go b/universe/interface.go index f8a7761a0..cb183678f 100644 --- a/universe/interface.go +++ b/universe/interface.go @@ -250,11 +250,11 @@ type MultiverseArchive interface { // base key(s). RegisterBatchIssuance(ctx context.Context, items []*IssuanceItem) error - // FetchIssuanceProof returns an issuance proof for the target key. If - // the key doesn't have a script key specified, then all the proofs for - // the minting outpoint will be returned. If neither are specified, then - // proofs for all the inserted leaves will be returned. - FetchIssuanceProof(ctx context.Context, id Identifier, + // FetchProofLeaf returns a proof leaf for the target key. If the key + // doesn't have a script key specified, then all the proof leafs for the + // minting outpoint will be returned. If neither are specified, then all + // inserted proof leafs will be returned. + FetchProofLeaf(ctx context.Context, id Identifier, key BaseKey) ([]*IssuanceProof, error) // TODO(roasbeef): other stats stuff here, like total number of assets, etc