diff --git a/eth/backend.go b/eth/backend.go index 939501cfb3..54b8c2e75d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -211,6 +211,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } eth.engine.VerifyHeader(eth.blockchain, eth.blockchain.CurrentHeader(), true) // TODO think on it + // BOR changes + eth.APIBackend.gpo.ProcessCache() + // BOR changes + // Rewind the chain in case of an incompatible config upgrade. if compat, ok := genesisErr.(*params.ConfigCompatError); ok { log.Warn("Rewinding chain to upgrade configuration", "err", compat) diff --git a/eth/gasprice/gasprice.go b/eth/gasprice/gasprice.go index 8feb5ef24b..0fa6c29591 100644 --- a/eth/gasprice/gasprice.go +++ b/eth/gasprice/gasprice.go @@ -106,17 +106,6 @@ func NewOracle(backend OracleBackend, params Config) *Oracle { } cache, _ := lru.New(2048) - headEvent := make(chan core.ChainHeadEvent, 1) - backend.SubscribeChainHeadEvent(headEvent) - go func() { - var lastHead common.Hash - for ev := range headEvent { - if ev.Block.ParentHash() != lastHead { - cache.Purge() - } - lastHead = ev.Block.Hash() - } - }() return &Oracle{ backend: backend, @@ -131,6 +120,20 @@ func NewOracle(backend OracleBackend, params Config) *Oracle { } } +func (oracle *Oracle) ProcessCache() { + headEvent := make(chan core.ChainHeadEvent, 1) + oracle.backend.SubscribeChainHeadEvent(headEvent) + go func() { + var lastHead common.Hash + for ev := range headEvent { + if ev.Block.ParentHash() != lastHead { + oracle.historyCache.Purge() + } + lastHead = ev.Block.Hash() + } + }() +} + // SuggestTipCap returns a tip cap so that newly created transaction can have a // very high chance to be included in the following blocks. //