mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
fix for when the code is run using the gasprice testBackend
This commit is contained in:
parent
0510fc8662
commit
d8095c40e5
1 changed files with 14 additions and 12 deletions
|
|
@ -121,20 +121,22 @@ func NewOracle(backend OracleBackend, params Config, startPrice *big.Int) *Oracl
|
|||
cache := lru.NewCache[cacheKey, processedFees](2048)
|
||||
headEvent := make(chan core.ChainHeadEvent, 1)
|
||||
sub := backend.SubscribeChainHeadEvent(headEvent)
|
||||
go func() {
|
||||
var lastHead common.Hash
|
||||
for {
|
||||
select {
|
||||
case ev := <-headEvent:
|
||||
if ev.Header.ParentHash != lastHead {
|
||||
cache.Purge()
|
||||
if sub != nil { // the gasprice testBackend doesn't support subscribing to head events
|
||||
go func() {
|
||||
var lastHead common.Hash
|
||||
for {
|
||||
select {
|
||||
case ev := <-headEvent:
|
||||
if ev.Header.ParentHash != lastHead {
|
||||
cache.Purge()
|
||||
}
|
||||
lastHead = ev.Header.Hash()
|
||||
case <-sub.Err():
|
||||
return
|
||||
}
|
||||
lastHead = ev.Header.Hash()
|
||||
case <-sub.Err():
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
return &Oracle{
|
||||
backend: backend,
|
||||
|
|
|
|||
Loading…
Reference in a new issue