lbcd/fees/cmd/dumpfeedb/dumpfeedb.go
Roy Lee d126d0c10e [lbry] fees: port estimatesmartfee from DCRD
1. logger
2. blockheight: int64 -> int32
3. dcrutil -> lbcutl
4. MaxConfirimation: 42
5. MinBucketFee: mempool.MinRelayFee (default 1000)
6. BucketFee Spacing: 1.1 -> 1.05

Note:
  DCRD implementation of estimatesmartfee is based on bitcoin core 0.14
  Lbrycrd (0.17) includes the updates of bitcoin core 0.15.
  They are slightly different, but shouldn't matter much.
2022-05-24 00:04:19 -07:00

56 lines
1.3 KiB
Go

// Copyright (c) 2018-2020 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
// Tool dumpfeedb can be used to dump the internal state of the buckets of an
// estimator's feedb so that it can be externally analyzed.
package main
import (
"errors"
"fmt"
"os"
"path"
"github.com/btcsuite/btclog"
flags "github.com/jessevdk/go-flags"
"github.com/lbryio/lbcd/fees"
"github.com/lbryio/lbcutil"
)
type config struct {
DB string `short:"b" long:"db" description:"Path to fee database"`
}
var feesLog = btclog.NewBackend(os.Stdout).Logger("FEES")
func main() {
cfg := config{
DB: path.Join(lbcutil.AppDataDir("lbcd", false), "data", "mainnet", "feesdb"),
}
fees.UseLogger(feesLog)
parser := flags.NewParser(&cfg, flags.Default)
_, err := parser.Parse()
if err != nil {
var e *flags.Error
if !errors.As(err, &e) || e.Type != flags.ErrHelp {
parser.WriteHelp(os.Stderr)
}
return
}
ecfg := fees.EstimatorConfig{
DatabaseFile: cfg.DB,
ReplaceBucketsOnLoad: true,
MinBucketFee: 1,
MaxBucketFee: 2,
FeeRateStep: fees.DefaultFeeRateStep,
}
est, err := fees.NewEstimator(&ecfg)
if err != nil {
panic(err)
}
fmt.Println(est.DumpBuckets())
}