mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-28 18:51:47 +01:00
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:
parent
db145bfd8e
commit
8abe2f89e1
@ -67,6 +67,20 @@ const (
|
|||||||
TypeRewardCommit = Type(FlagCommitOutputs | FlagReward)
|
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.
|
// Has returns true if the Type has the passed flag enabled.
|
||||||
func (t Type) Has(flag Flag) bool {
|
func (t Type) Has(flag Flag) bool {
|
||||||
return Flag(t)&flag == flag
|
return Flag(t)&flag == flag
|
||||||
|
@ -350,10 +350,12 @@ func New(config *Config) (*TowerClient, error) {
|
|||||||
cfg.WriteTimeout = DefaultWriteTimeout
|
cfg.WriteTimeout = DefaultWriteTimeout
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix := "(legacy)"
|
identifier, err := cfg.Policy.BlobType.Identifier()
|
||||||
if cfg.Policy.IsAnchorChannel() {
|
if err != nil {
|
||||||
prefix = "(anchor)"
|
return nil, err
|
||||||
}
|
}
|
||||||
|
prefix := fmt.Sprintf("(%s)", identifier)
|
||||||
|
|
||||||
plog := build.NewPrefixLog(prefix, log)
|
plog := build.NewPrefixLog(prefix, log)
|
||||||
|
|
||||||
// Load the sweep pkscripts that have been generated for all previously
|
// Load the sweep pkscripts that have been generated for all previously
|
||||||
@ -363,10 +365,7 @@ func New(config *Config) (*TowerClient, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
queueDB := cfg.DB.GetDBQueue([]byte(identifier))
|
||||||
policy = cfg.Policy.BlobType.String()
|
|
||||||
queueDB = cfg.DB.GetDBQueue([]byte(policy))
|
|
||||||
)
|
|
||||||
queue, err := NewDiskOverflowQueue[*wtdb.BackupID](
|
queue, err := NewDiskOverflowQueue[*wtdb.BackupID](
|
||||||
queueDB, cfg.MaxTasksInMemQueue, plog,
|
queueDB, cfg.MaxTasksInMemQueue, plog,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user