Skip to content

Commit 92beb40

Browse files
committed
universe: rename interface BaseBackend to StorageBackend
Renamed interface to better reflect its broader usage. It now applies to both issuance proof leaves and transfer proof leaves.
1 parent c1580d9 commit 92beb40

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

tapcfg/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ func genServerConfig(cfg *Config, cfgLogger btclog.Logger,
155155
context.Background(), assetMintingStore,
156156
)
157157
uniArchiveCfg := universe.ArchiveConfig{
158-
NewBaseTree: func(id universe.Identifier) universe.BaseBackend {
158+
// nolint: lll
159+
NewBaseTree: func(id universe.Identifier) universe.StorageBackend {
159160
return tapdb.NewBaseUniverseTree(
160161
uniDB, id,
161162
)

tapdb/universe.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,11 @@ type BatchedUniverseTree interface {
380380
BatchedTx[BaseUniverseStore]
381381
}
382382

383-
// BaseUniverseTree implements the persistent storage for the Base universe for
383+
// BaseUniverseTree implements the persistent storage for the universe for
384384
// a given asset. The minting outpoints stored of the asset are used to key
385385
// into the universe tree.
386386
//
387-
// NOTE: This implements the universe.Base interface.
387+
// NOTE: This implements the universe.StorageBackend interface.
388388
type BaseUniverseTree struct {
389389
db BatchedUniverseTree
390390

@@ -1192,4 +1192,4 @@ func (b *BaseUniverseTree) DeleteUniverse(ctx context.Context) (string, error) {
11921192
return b.smtNamespace, dbErr
11931193
}
11941194

1195-
var _ universe.BaseBackend = (*BaseUniverseTree)(nil)
1195+
var _ universe.StorageBackend = (*BaseUniverseTree)(nil)

universe/archive.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ArchiveConfig struct {
2222
// NewBaseTree returns a new base universe backend for the given
2323
// identifier. This method always returns a new universe instance, even
2424
// if the identifier has never been seen before.
25-
NewBaseTree func(id Identifier) BaseBackend
25+
NewBaseTree func(id Identifier) StorageBackend
2626

2727
// HeaderVerifier is used to verify the validity of the header for a
2828
// genesis proof.
@@ -65,7 +65,7 @@ type Archive struct {
6565

6666
// baseUniverses is a map of all the current known base universe
6767
// instances for the archive.
68-
baseUniverses map[Identifier]BaseBackend
68+
baseUniverses map[Identifier]StorageBackend
6969

7070
sync.RWMutex
7171
}
@@ -74,7 +74,7 @@ type Archive struct {
7474
func NewArchive(cfg ArchiveConfig) *Archive {
7575
a := &Archive{
7676
cfg: cfg,
77-
baseUniverses: make(map[Identifier]BaseBackend),
77+
baseUniverses: make(map[Identifier]StorageBackend),
7878
}
7979

8080
return a
@@ -87,7 +87,7 @@ func (a *Archive) Close() error {
8787

8888
// fetchUniverse returns the base universe instance for the passed identifier.
8989
// The universe will be loaded in on demand if it has not been seen before.
90-
func (a *Archive) fetchUniverse(id Identifier) BaseBackend {
90+
func (a *Archive) fetchUniverse(id Identifier) StorageBackend {
9191
a.Lock()
9292
defer a.Unlock()
9393

@@ -103,12 +103,12 @@ func (a *Archive) fetchUniverse(id Identifier) BaseBackend {
103103
// uniFetcher takes a base universe ID, and returns the base universe
104104
// backend associated with the ID.
105105
type uniFetcher interface {
106-
fetchUniverse(id Identifier) BaseBackend
106+
fetchUniverse(id Identifier) StorageBackend
107107
}
108108

109109
// uniAction is a function that takes a base universe backend, and does
110110
// something to it, returning a type T and an error.
111-
type uniAction[T any] func(BaseBackend) (T, error)
111+
type uniAction[T any] func(StorageBackend) (T, error)
112112

113113
// withUni is a helper function that performs an action on a universe instance,
114114
// returning a generic result.
@@ -705,7 +705,7 @@ func (a *Archive) FetchLeaves(ctx context.Context,
705705
id.StringForLog())
706706

707707
return withUni(
708-
a, id, func(uni BaseBackend) ([]Leaf, error) {
708+
a, id, func(uni StorageBackend) ([]Leaf, error) {
709709
return uni.FetchLeaves(ctx)
710710
},
711711
)

universe/interface.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,11 @@ func (i *Proof) VerifyRoot(expectedRoot mssmt.Node) bool {
398398
mssmt.IsEqualNode(reconstructedRoot, expectedRoot)
399399
}
400400

401-
// BaseBackend is the backend storage interface for a base universe. The
402-
// backend can be used to store issuance profs, retrieve them, and also fetch
403-
// the set of keys and leaves stored within the universe.
404-
//
405-
// TODO(roasbeef): gRPC service to match this, think about the REST mapping
406-
type BaseBackend interface {
407-
// RootNode returns the root node for a given base universe.
401+
// StorageBackend defines the storage interface for a universe. It supports
402+
// storing and retrieving proofs, as well as fetching the set of keys and leaves
403+
// contained in the universe.
404+
type StorageBackend interface {
405+
// RootNode returns the root node for a given universe.
408406
RootNode(context.Context) (mssmt.Node, string, error)
409407

410408
// UpsertProofLeaf inserts or updates a proof leaf within the universe
@@ -430,7 +428,7 @@ type BaseBackend interface {
430428
// FetchLeaves retrieves all leaves from the universe tree.
431429
FetchLeaves(ctx context.Context) ([]Leaf, error)
432430

433-
// DeleteUniverse deletes all leaves, and the root, for a given base
431+
// DeleteUniverse deletes all leaves, and the root, for a given
434432
// universe.
435433
DeleteUniverse(ctx context.Context) (string, error)
436434
}
@@ -477,10 +475,9 @@ type MultiverseLeaf struct {
477475
*mssmt.LeafNode
478476
}
479477

480-
// MultiverseArchive is an interface used to keep track of the set of universe
481-
// roots that we know of. The BaseBackend interface is used to interact with a
482-
// particular base universe, while this is used to obtain aggregate information
483-
// about the universes.
478+
// MultiverseArchive is an interface for tracking the set of known universe
479+
// roots. While the StorageBackend interface operates on a single universe, this
480+
// interface provides aggregate access across multiple universes.
484481
type MultiverseArchive interface {
485482
// RootNodes returns the complete set of known root nodes for the set
486483
// of assets tracked in the base Universe.
@@ -779,15 +776,15 @@ type CommittedIssuanceProof struct {
779776
type ChainCommitter interface {
780777
// CommitUniverse takes a Universe and returns a new commitment to that
781778
// Universe in the main chain.
782-
CommitUniverse(universe BaseBackend) (*Commitment, error)
779+
CommitUniverse(universe StorageBackend) (*Commitment, error)
783780
}
784781

785782
// Canonical is an interface that allows a caller to query for the latest
786783
// canonical Universe information related to an asset.
787784
//
788785
// TODO(roasbeef): sync methods too, divide into read/write?
789786
type Canonical interface {
790-
BaseBackend
787+
StorageBackend
791788

792789
// Query returns a fully proved response for the target base key.
793790
Query(context.Context, LeafKey) (*CommittedIssuanceProof, error)

0 commit comments

Comments
 (0)