github.com/lbryio/lbcd@v0.22.119/fees/cmd/dumpfeedb/dumpfeedb.go (about) 1 // Copyright (c) 2018-2020 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 // Tool dumpfeedb can be used to dump the internal state of the buckets of an 6 // estimator's feedb so that it can be externally analyzed. 7 package main 8 9 import ( 10 "errors" 11 "fmt" 12 "os" 13 "path" 14 15 "github.com/btcsuite/btclog" 16 flags "github.com/jessevdk/go-flags" 17 "github.com/lbryio/lbcd/fees" 18 "github.com/lbryio/lbcutil" 19 ) 20 21 type config struct { 22 DB string `short:"b" long:"db" description:"Path to fee database"` 23 } 24 25 var feesLog = btclog.NewBackend(os.Stdout).Logger("FEES") 26 27 func main() { 28 cfg := config{ 29 DB: path.Join(lbcutil.AppDataDir("lbcd", false), "data", "mainnet", "feesdb"), 30 } 31 32 fees.UseLogger(feesLog) 33 parser := flags.NewParser(&cfg, flags.Default) 34 _, err := parser.Parse() 35 if err != nil { 36 var e *flags.Error 37 if !errors.As(err, &e) || e.Type != flags.ErrHelp { 38 parser.WriteHelp(os.Stderr) 39 } 40 return 41 } 42 43 ecfg := fees.EstimatorConfig{ 44 DatabaseFile: cfg.DB, 45 ReplaceBucketsOnLoad: true, 46 MinBucketFee: 1, 47 MaxBucketFee: 2, 48 FeeRateStep: fees.DefaultFeeRateStep, 49 } 50 est, err := fees.NewEstimator(&ecfg) 51 if err != nil { 52 panic(err) 53 } 54 55 fmt.Println(est.DumpBuckets()) 56 }