Skip to content

Commit c1580d9

Browse files
committed
universe: rename BaseBackend.RegisterIssuance to UpsertProofLeaf
Renamed method to better reflect its broader usage. It now applies to both issuance proof leaves and transfer proof leaves.
1 parent b476056 commit c1580d9

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

tapdb/universe.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,10 @@ func upsertAssetGen(ctx context.Context, db UpsertAssetStore,
568568
return genAssetID, nil
569569
}
570570

571-
// RegisterIssuance inserts a new minting leaf within the universe tree, stored
572-
// at the base key.
573-
func (b *BaseUniverseTree) RegisterIssuance(ctx context.Context,
571+
// UpsertProofLeaf inserts or updates a proof leaf within the universe tree,
572+
// stored at the base key. The metaReveal type is purely optional, and should be
573+
// specified if the genesis proof committed to a non-zero meta hash.
574+
func (b *BaseUniverseTree) UpsertProofLeaf(ctx context.Context,
574575
key universe.LeafKey, leaf *universe.Leaf,
575576
metaReveal *proof.MetaReveal) (*universe.Proof, error) {
576577

tapdb/universe_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func TestUniverseIssuanceProofs(t *testing.T) {
300300
targetKey := testLeaf.LeafKey
301301
leaf := testLeaf.Leaf
302302

303-
issuanceProof, err := baseUniverse.RegisterIssuance(
303+
issuanceProof, err := baseUniverse.UpsertProofLeaf(
304304
ctx, targetKey, &leaf, nil,
305305
)
306306
require.NoError(t, err)
@@ -406,7 +406,7 @@ func TestUniverseIssuanceProofs(t *testing.T) {
406406
testLeaf.Leaf.RawProof = randProofBytes
407407

408408
targetKey := testLeaf.LeafKey
409-
issuanceProof, err := baseUniverse.RegisterIssuance(
409+
issuanceProof, err := baseUniverse.UpsertProofLeaf(
410410
ctx, targetKey, &testLeaf.Leaf, nil,
411411
)
412412
require.NoError(t, err)
@@ -476,7 +476,7 @@ func TestUniverseMetaBlob(t *testing.T) {
476476
targetKey := randLeafKey(t)
477477
leaf := randMintingLeaf(t, assetGen, id.GroupKey)
478478

479-
_, err := baseUniverse.RegisterIssuance(ctx, targetKey, &leaf, meta)
479+
_, err := baseUniverse.UpsertProofLeaf(ctx, targetKey, &leaf, meta)
480480
require.NoError(t, err)
481481

482482
// We should be able to fetch the leaf based on the base key we used
@@ -503,7 +503,7 @@ func insertRandLeaf(t *testing.T, ctx context.Context, tree *BaseUniverseTree,
503503
targetKey := randLeafKey(t)
504504
leaf := randMintingLeaf(t, targetGen, tree.id.GroupKey)
505505

506-
return tree.RegisterIssuance(ctx, targetKey, &leaf, nil)
506+
return tree.UpsertProofLeaf(ctx, targetKey, &leaf, nil)
507507
}
508508

509509
// TestUniverseTreeIsolation tests that each Universe tree is properly isolated
@@ -680,7 +680,7 @@ func TestUniverseLeafQuery(t *testing.T) {
680680

681681
leafToScriptKey[scriptKey] = leaf
682682

683-
_, err := baseUniverse.RegisterIssuance(
683+
_, err := baseUniverse.UpsertProofLeaf(
684684
ctx, targetKey, &leaf, nil,
685685
)
686686
require.NoError(t, err)
@@ -754,7 +754,7 @@ func TestUniverseLeafOverflow(t *testing.T) {
754754
leaf.Amt = math.MaxUint64 - 1
755755

756756
// We should be able to insert this np.
757-
_, err := baseUniverse.RegisterIssuance(ctx, targetKey, &leaf, nil)
757+
_, err := baseUniverse.UpsertProofLeaf(ctx, targetKey, &leaf, nil)
758758
require.NoError(t, err)
759759

760760
// We should be able to fetch the leaf based on the base key we used
@@ -767,7 +767,7 @@ func TestUniverseLeafOverflow(t *testing.T) {
767767
targetKey2 := randLeafKey(t)
768768
leaf2 := randMintingLeaf(t, assetGen, id.GroupKey)
769769

770-
_, err = baseUniverse.RegisterIssuance(ctx, targetKey2, &leaf2, nil)
770+
_, err = baseUniverse.UpsertProofLeaf(ctx, targetKey2, &leaf2, nil)
771771
require.ErrorIs(t, err, mssmt.ErrIntegerOverflow)
772772

773773
// We should still be able to fetch the original issuance proof.
@@ -861,7 +861,7 @@ func TestUniverseRootSum(t *testing.T) {
861861

862862
keys[i] = targetKey
863863

864-
_, err := baseUniverse.RegisterIssuance(
864+
_, err := baseUniverse.UpsertProofLeaf(
865865
ctx, targetKey, &leaf, nil,
866866
)
867867
require.NoError(t, err)

universe/interface.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,11 @@ type BaseBackend interface {
407407
// RootNode returns the root node for a given base universe.
408408
RootNode(context.Context) (mssmt.Node, string, error)
409409

410-
// RegisterIssuance inserts a new minting leaf within the universe
411-
// tree, stored at the base key. The metaReveal type is purely
410+
// UpsertProofLeaf inserts or updates a proof leaf within the universe
411+
// tree, stored at the given key. The metaReveal type is purely
412412
// optional, and should be specified if the genesis proof committed to
413413
// a non-zero meta hash.
414-
RegisterIssuance(ctx context.Context, key LeafKey, leaf *Leaf,
414+
UpsertProofLeaf(ctx context.Context, key LeafKey, leaf *Leaf,
415415
metaReveal *proof.MetaReveal) (*Proof, error)
416416

417417
// FetchProof retrieves a universe proof corresponding to the given key.

0 commit comments

Comments
 (0)