-
Notifications
You must be signed in to change notification settings - Fork 0
/
dumpfeedb.go
50 lines (42 loc) · 1.13 KB
/
dumpfeedb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2018 The Utopia 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 (
"fmt"
"os"
"path"
"github.com/UtopiaCoinOrg/ucd/ucutil"
"github.com/UtopiaCoinOrg/ucd/fees"
flags "github.com/jessevdk/go-flags"
)
type config struct {
DB string `short:"b" long:"db" description:"Path to fee database"`
}
func main() {
cfg := config{
DB: path.Join(ucutil.AppDataDir("ucd", false), "data", "mainnet", "feesdb"),
}
parser := flags.NewParser(&cfg, flags.Default)
_, err := parser.Parse()
if err != nil {
if e, ok := err.(*flags.Error); !ok || 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())
}