mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-14 16:03:45 +00:00
fix: gas oracle cache purge
This commit is contained in:
parent
7e76e9f27c
commit
a91b24d4d0
2 changed files with 18 additions and 11 deletions
|
|
@ -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
|
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.
|
// Rewind the chain in case of an incompatible config upgrade.
|
||||||
if compat, ok := genesisErr.(*params.ConfigCompatError); ok {
|
if compat, ok := genesisErr.(*params.ConfigCompatError); ok {
|
||||||
log.Warn("Rewinding chain to upgrade configuration", "err", compat)
|
log.Warn("Rewinding chain to upgrade configuration", "err", compat)
|
||||||
|
|
|
||||||
|
|
@ -106,17 +106,6 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
|
||||||
}
|
}
|
||||||
|
|
||||||
cache, _ := lru.New(2048)
|
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{
|
return &Oracle{
|
||||||
backend: backend,
|
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
|
// SuggestTipCap returns a tip cap so that newly created transaction can have a
|
||||||
// very high chance to be included in the following blocks.
|
// very high chance to be included in the following blocks.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue