Skip to content

Commit

Permalink
chainfee: make sure web API has feerate info during startup
Browse files Browse the repository at this point in the history
Previously we may get a floor feerate when calling `EstimateFeePerKW`
due to the ticker is not yet ticked, which gives us an empty fee map.
This is now fixed to always query the API to initialize the fee map
during startup.
  • Loading branch information
yyforyongyu committed Jul 4, 2024
1 parent 71ba355 commit 451cedc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lnwallet/chainfee/estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,22 +816,24 @@ func (w *WebAPIEstimator) EstimateFeePerKW(numBlocks uint32) (
//
// NOTE: This method is part of the Estimator interface.
func (w *WebAPIEstimator) Start() error {
log.Infof("Starting Web API fee estimator...")

// During startup we'll query the API to initialize the fee map.
w.updateFeeEstimates()

// No update loop is needed when we don't cache.
if w.noCache {
return nil
}

var err error
w.started.Do(func() {
log.Infof("Starting web API fee estimator")

feeUpdateTimeout := w.randomFeeUpdateTimeout()

log.Infof("Web API fee estimator using update timeout of %v",
feeUpdateTimeout)

w.updateFeeTicker = time.NewTicker(feeUpdateTimeout)
w.updateFeeEstimates()

w.wg.Add(1)
go w.feeUpdateManager()
Expand Down

0 comments on commit 451cedc

Please sign in to comment.