Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new dumpfeedb tool dumps the contents of the internal state of a fee estimator for external validation.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |