watchtower: use a stable blob identifier

In this commit, we add an Identifier method to the blob.Type struct
which returns a unique identifier for a given blob type. This identifier
is then used for initialising the disk overflow queue of the given
client.
This commit is contained in:
Elle Mouton
2023-05-18 15:17:22 +02:00
parent db145bfd8e
commit 8abe2f89e1
2 changed files with 20 additions and 7 deletions

View File

@@ -67,6 +67,20 @@ const (
TypeRewardCommit = Type(FlagCommitOutputs | FlagReward)
)
// Identifier returns a unique, stable string identifier for the blob Type.
func (t Type) Identifier() (string, error) {
switch t {
case TypeAltruistCommit:
return "legacy", nil
case TypeAltruistAnchorCommit:
return "anchor", nil
case TypeRewardCommit:
return "reward", nil
default:
return "", fmt.Errorf("unknown blob type: %v", t)
}
}
// Has returns true if the Type has the passed flag enabled.
func (t Type) Has(flag Flag) bool {
return Flag(t)&flag == flag