Custom cache size
This commit is contained in:
@@ -23,8 +23,6 @@ import (
|
|||||||
var log *logrus.Entry
|
var log *logrus.Entry
|
||||||
var logger = logrus.New()
|
var logger = logrus.New()
|
||||||
|
|
||||||
var cacheSize = 30000
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
logger.SetFormatter(&logrus.TextFormatter{
|
logger.SetFormatter(&logrus.TextFormatter{
|
||||||
//DisableColors: true,
|
//DisableColors: true,
|
||||||
@@ -84,6 +82,7 @@ type Options struct {
|
|||||||
logLevel uint64 `json:"log_level,omitempty"`
|
logLevel uint64 `json:"log_level,omitempty"`
|
||||||
logPath string `json:"log_file,omitempty"`
|
logPath string `json:"log_file,omitempty"`
|
||||||
zcashConfPath string `json:"zcash_conf,omitempty"`
|
zcashConfPath string `json:"zcash_conf,omitempty"`
|
||||||
|
cacheSize int `json:"zcash_conf,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -94,6 +93,8 @@ func main() {
|
|||||||
flag.Uint64Var(&opts.logLevel, "log-level", uint64(logrus.InfoLevel), "log level (logrus 1-7)")
|
flag.Uint64Var(&opts.logLevel, "log-level", uint64(logrus.InfoLevel), "log level (logrus 1-7)")
|
||||||
flag.StringVar(&opts.logPath, "log-file", "", "log file to write to")
|
flag.StringVar(&opts.logPath, "log-file", "", "log file to write to")
|
||||||
flag.StringVar(&opts.zcashConfPath, "conf-file", "", "conf file to pull RPC creds from")
|
flag.StringVar(&opts.zcashConfPath, "conf-file", "", "conf file to pull RPC creds from")
|
||||||
|
flag.IntVar(&opts.cacheSize, "cache-size", 40000, "number of blocks to hold in the cache")
|
||||||
|
|
||||||
// TODO prod metrics
|
// TODO prod metrics
|
||||||
// TODO support config from file and env vars
|
// TODO support config from file and env vars
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@@ -171,12 +172,12 @@ func main() {
|
|||||||
log.Info("Got sapling height ", saplingHeight, " chain ", chainName, " branchID ", branchID)
|
log.Info("Got sapling height ", saplingHeight, " chain ", chainName, " branchID ", branchID)
|
||||||
|
|
||||||
// Initialize the cache
|
// Initialize the cache
|
||||||
cache := common.NewBlockCache(cacheSize)
|
cache := common.NewBlockCache(opts.cacheSize)
|
||||||
|
|
||||||
stopChan := make(chan bool, 1)
|
stopChan := make(chan bool, 1)
|
||||||
|
|
||||||
// Start the block cache importer at latestblock - 100k(cache size)
|
// Start the block cache importer at latestblock - 100k(cache size)
|
||||||
cacheStart := blockHeight - cacheSize
|
cacheStart := blockHeight - opts.cacheSize
|
||||||
if cacheStart < saplingHeight {
|
if cacheStart < saplingHeight {
|
||||||
cacheStart = saplingHeight
|
cacheStart = saplingHeight
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user