Skip to content

Commit

Permalink
fees: add dumpfeedb tool
Browse files Browse the repository at this point in the history
The new dumpfeedb tool dumps the contents of the internal state of a fee
estimator for external validation.
  • Loading branch information
matheusd committed Sep 13, 2018
1 parent bfb415e commit e803f3b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions fees/cmd/dumpfeedb/dumpfeedb.go
@@ -0,0 +1,38 @@
// Copyright (c) 2018 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 (
"flag"
"fmt"
"os"
"path"

"github.com/decred/dcrd/dcrutil"
"github.com/decred/dcrd/fees"
)

func main() {
defaultDir := path.Join(dcrutil.AppDataDir("dcrd", false), "data", "mainnet", "feesdb")
db := flag.String("db", defaultDir, "Database location")
flag.Parse()

fmt.Fprintf(os.Stderr, "Dumping contents of %s\n", *db)

cfg := fees.EstimatorConfig{
DatabaseFile: *db,
ReplaceBucketsOnLoad: true,
}
est, err := fees.NewEstimator(&cfg)
if err != nil {
panic(err)
}

fmt.Println(est.DumpBuckets())

fmt.Fprintf(os.Stderr, "Done\n")
}

0 comments on commit e803f3b

Please sign in to comment.