Skip to content

Commit 5336054

Browse files
committed
tapdb: add option to skip multi-verse insertion for leaves
In this commit, we add an option to skip multi-verse insertion. This is useful as for the new burn and ignore trees, we won't put them in a multi-verse of all the other ignore/burn trees. Instead, they'll go in a special tree for a given group, which contains these trees as sub-trees.
1 parent 6ef81a5 commit 5336054

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

tapdb/multiverse.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ func (b *MultiverseStore) UpsertProofLeaf(ctx context.Context,
766766
// tree.
767767
var err error
768768
issuanceProof, err = universeUpsertProofLeaf(
769-
ctx, dbTx, id, key, leaf, metaReveal,
769+
ctx, dbTx, id, key, leaf, metaReveal, false,
770770
)
771771
if err != nil {
772772
return err
@@ -812,7 +812,7 @@ func (b *MultiverseStore) UpsertProofLeafBatch(ctx context.Context,
812812
// tree.
813813
return universeUpsertProofLeaf(
814814
ctx, dbTx, item.ID, item.Key, item.Leaf,
815-
item.MetaReveal,
815+
item.MetaReveal, false,
816816
)
817817
}
818818

tapdb/universe.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ func (b *BaseUniverseTree) RegisterIssuance(ctx context.Context,
340340
)
341341
dbErr := b.db.ExecTx(ctx, &writeTx, func(dbTx BaseUniverseStore) error {
342342
issuanceProof, err = universeUpsertProofLeaf(
343-
ctx, dbTx, b.id, key, leaf, metaReveal,
343+
ctx, dbTx, b.id, key, leaf, metaReveal, false,
344344
)
345345
return err
346346
})
@@ -361,7 +361,8 @@ func (b *BaseUniverseTree) RegisterIssuance(ctx context.Context,
361361
// broader DB updates.
362362
func universeUpsertProofLeaf(ctx context.Context, dbTx BaseUniverseStore,
363363
id universe.Identifier, key universe.LeafKey, leaf *universe.Leaf,
364-
metaReveal *proof.MetaReveal) (*universe.Proof, error) {
364+
metaReveal *proof.MetaReveal,
365+
skipMultiverse bool) (*universe.Proof, error) {
365366

366367
namespace := id.String()
367368

@@ -461,6 +462,20 @@ func universeUpsertProofLeaf(ctx context.Context, dbTx BaseUniverseStore,
461462
return nil, err
462463
}
463464

465+
// If this Universe tree isn't part of the greater multi-verse tree,
466+
// then we'll skip insertion for now.
467+
//
468+
// TODO(roasbeef): will go into a combined multi-verse tree for diff
469+
// proof types later
470+
if skipMultiverse {
471+
return &universe.Proof{
472+
LeafKey: key,
473+
UniverseRoot: universeRoot,
474+
UniverseInclusionProof: leafInclusionProof,
475+
Leaf: leaf,
476+
}, nil
477+
}
478+
464479
// The next step is to insert the multiverse leaf, which is a leaf in
465480
// the multiverse tree that points to the universe leaf we just created.
466481
multiverseNS, err := namespaceForProof(id.ProofType)

0 commit comments

Comments
 (0)