lnd: start fee estimator at a single point

This commit is contained in:
Joost Jager 2020-09-14 11:43:10 +02:00
parent 166be979dd
commit dae0e2194d
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -253,17 +253,12 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
if cfg.NeutrinoMode.FeeURL != "" {
ltndLog.Infof("Using API fee estimator!")
estimator := chainfee.NewWebAPIEstimator(
cc.feeEstimator = chainfee.NewWebAPIEstimator(
chainfee.SparseConfFeeSource{
URL: cfg.NeutrinoMode.FeeURL,
},
false,
)
if err := estimator.Start(); err != nil {
return nil, err
}
cc.feeEstimator = estimator
}
walletConfig.ChainSource = chain.NewNeutrinoClient(
@ -366,9 +361,6 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
if err != nil {
return nil, err
}
if err := cc.feeEstimator.Start(); err != nil {
return nil, err
}
} else if cfg.Litecoin.Active && !cfg.Litecoin.RegTest {
ltndLog.Infof("Initializing litecoind backed fee estimator in "+
"%s mode", bitcoindMode.EstimateMode)
@ -385,9 +377,6 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
if err != nil {
return nil, err
}
if err := cc.feeEstimator.Start(); err != nil {
return nil, err
}
}
case "btcd", "ltcd":
// Otherwise, we'll be speaking directly via RPC to a node.
@ -490,15 +479,17 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
if err != nil {
return nil, err
}
if err := cc.feeEstimator.Start(); err != nil {
return nil, err
}
}
default:
return nil, fmt.Errorf("unknown node type: %s",
homeChainConfig.Node)
}
// Start fee estimator.
if err := cc.feeEstimator.Start(); err != nil {
return nil, err
}
wc, err := btcwallet.New(*walletConfig)
if err != nil {
fmt.Printf("unable to create wallet controller: %v\n", err)