diff --git a/consensus/dccs/2_dccs.go b/consensus/dccs/2_dccs.go index 5ad5a3a078cc..d18741d1c700 100644 --- a/consensus/dccs/2_dccs.go +++ b/consensus/dccs/2_dccs.go @@ -511,7 +511,7 @@ func (c *Context) prepare2(header *types.Header) error { header.Difficulty = new(big.Int).SetUint64(difficulty) var price *Price - if c.engine.config.IsPriceBlock(number) { + if c.engine.config.IsPriceBlock(number) && len(c.engine.priceURL) > 0 { price = c.engine.PriceEngine().CurrentPrice() if price == nil { log.Warn("No price to record in block", "number", number) diff --git a/consensus/dccs/2_price.go b/consensus/dccs/2_price.go index 17591fded8c5..f5b02258498f 100644 --- a/consensus/dccs/2_price.go +++ b/consensus/dccs/2_price.go @@ -105,6 +105,10 @@ func (a ByPrice) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // CalcMedianPrice calculates the median price of a price block and cache it. // TODO: optimize rolling median calculation func (c *Context) CalcMedianPrice(number uint64) (*Price, error) { + if len(c.engine.priceURL) == 0 { + // price server URL not provided + return nil, nil + } if !c.engine.config.IsPriceBlock(number) { // not a price block return nil, nil @@ -156,6 +160,10 @@ func medianPrice(prices []*Price, minValues int) (*Price, error) { // GetBlockPrice returns the price encoded in a block header extra data func (c *Context) GetBlockPrice(number uint64) *Price { + if len(c.engine.priceURL) == 0 { + // price server URL not provided + return nil + } if !c.engine.config.IsPriceBlock(number) { // not a price block return nil diff --git a/eth/config.go b/eth/config.go index ee08f7c365ee..312be45e01e8 100644 --- a/eth/config.go +++ b/eth/config.go @@ -61,7 +61,6 @@ var DefaultConfig = Config{ Blocks: 20, Percentile: 60, }, - PriceServiceURL: "http://localhost:3000/price/NUSD_USD", } func init() {