chainfee: replace conf target when it exceeds the maxBlockTarget

In this commit, we add a check inside EstimateFeePerKW for bitcoind so
that when the conf target exceeds the maxBlockTarget, we will use
maxBlockTarget instead.
This commit is contained in:
yyforyongyu 2021-05-06 19:12:17 +08:00
parent 6242158d51
commit 5f0561fdbc
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

View File

@ -375,7 +375,16 @@ func (b *BitcoindEstimator) Stop() error {
// confirmation and returns the estimated fee expressed in sat/kw.
//
// NOTE: This method is part of the Estimator interface.
func (b *BitcoindEstimator) EstimateFeePerKW(numBlocks uint32) (SatPerKWeight, error) {
func (b *BitcoindEstimator) EstimateFeePerKW(
numBlocks uint32) (SatPerKWeight, error) {
if numBlocks > maxBlockTarget {
log.Debugf("conf target %d exceeds the max value, "+
"use %d instead.", numBlocks, maxBlockTarget,
)
numBlocks = maxBlockTarget
}
feeEstimate, err := b.fetchEstimate(numBlocks)
switch {
// If the estimator doesn't have enough data, or returns an error, then