|
| 1 | +package supplyverifier |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "fmt" |
| 6 | + |
| 7 | + "github.com/lightninglabs/taproot-assets/asset" |
| 8 | + "github.com/lightninglabs/taproot-assets/tapgarden" |
| 9 | + "github.com/lightninglabs/taproot-assets/universe/supplycommit" |
| 10 | +) |
| 11 | + |
| 12 | +// SupplyCommitView is an interface that is used to look up supply commitments |
| 13 | +// and pre-commitments. |
| 14 | +type SupplyCommitView interface { |
| 15 | + // UnspentPrecommits returns the set of unspent pre-commitments for a |
| 16 | + // given asset spec. |
| 17 | + UnspentPrecommits(ctx context.Context, |
| 18 | + assetSpec asset.Specifier) (supplycommit.PreCommits, error) |
| 19 | + |
| 20 | + // SupplyCommit returns the latest supply commitment for a given asset |
| 21 | + // spec. |
| 22 | + SupplyCommit(ctx context.Context, |
| 23 | + assetSpec asset.Specifier) (*supplycommit.RootCommitment, error) |
| 24 | + |
| 25 | + // LastVerifiedCommitment returns the last verified supply commitment |
| 26 | + // for a given asset spec. |
| 27 | + LastVerifiedCommitment(ctx context.Context, |
| 28 | + assetSpec asset.Specifier) (*supplycommit.RootCommitment, error) |
| 29 | +} |
| 30 | + |
| 31 | +// Environment is a struct that holds all the dependencies that the supply |
| 32 | +// verifier needs to carry out its duties. |
| 33 | +type Environment struct { |
| 34 | + // AssetSpec is the asset specifier that is used to identify the asset |
| 35 | + // that we're maintaining a supply commit for. |
| 36 | + AssetSpec asset.Specifier |
| 37 | + |
| 38 | + // Chain is our access to the current main chain. |
| 39 | + Chain tapgarden.ChainBridge |
| 40 | + |
| 41 | + // SupplyCommitView allows us to look up supply commitments and |
| 42 | + // pre-commitments. |
| 43 | + SupplyCommitView SupplyCommitView |
| 44 | + |
| 45 | + // ErrChan is the channel that is used to send errors to the caller. |
| 46 | + ErrChan chan<- error |
| 47 | + |
| 48 | + // QuitChan is the channel that is used to signal that the state |
| 49 | + // machine should quit. |
| 50 | + QuitChan <-chan struct{} |
| 51 | +} |
| 52 | + |
| 53 | +// Name returns the name of the environment. |
| 54 | +func (e *Environment) Name() string { |
| 55 | + return fmt.Sprintf("supply_verifier(%s)", e.AssetSpec.String()) |
| 56 | +} |
0 commit comments