diff --git a/cmd/root.go b/cmd/root.go index 994bf7c..d7aa16d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -272,8 +272,9 @@ func startServer(opts *common.Options) error { walletrpc.RegisterDarksideStreamerServer(server, service) } - // Initialize price fetcher - common.StartPriceFetcher(dbPath, chainName) + if !opts.Darkside { + common.StartPriceFetcher(dbPath, chainName) + } // Start listening listener, err := net.Listen("tcp", opts.GRPCBindAddr) diff --git a/common/prices.go b/common/prices.go index d0c6b3a..31e6e39 100644 --- a/common/prices.go +++ b/common/prices.go @@ -109,10 +109,8 @@ func median(inp []float64) (median float64) { l := len(inp) if l == 0 { return -1 - } else if l == 2 { - return (inp[0] + inp[1]) / 2 } else if l%2 == 0 { - return (inp[l/2-1] + inp[l/2+1]) / 2 + return (inp[l/2-1] + inp[l/2]) / 2 } else { return inp[l/2] }