|
|
@ -120,16 +120,23 @@ func NewOracle(backend OracleBackend, params Config, startPrice *big.Int) *Oracl |
|
|
|
|
|
|
|
|
|
|
|
cache := lru.NewCache[cacheKey, processedFees](2048) |
|
|
|
cache := lru.NewCache[cacheKey, processedFees](2048) |
|
|
|
headEvent := make(chan core.ChainHeadEvent, 1) |
|
|
|
headEvent := make(chan core.ChainHeadEvent, 1) |
|
|
|
backend.SubscribeChainHeadEvent(headEvent) |
|
|
|
sub := backend.SubscribeChainHeadEvent(headEvent) |
|
|
|
go func() { |
|
|
|
if sub != nil { // the gasprice testBackend doesn't support subscribing to head events
|
|
|
|
var lastHead common.Hash |
|
|
|
go func() { |
|
|
|
for ev := range headEvent { |
|
|
|
var lastHead common.Hash |
|
|
|
if ev.Header.ParentHash != lastHead { |
|
|
|
for { |
|
|
|
cache.Purge() |
|
|
|
select { |
|
|
|
|
|
|
|
case ev := <-headEvent: |
|
|
|
|
|
|
|
if ev.Header.ParentHash != lastHead { |
|
|
|
|
|
|
|
cache.Purge() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lastHead = ev.Header.Hash() |
|
|
|
|
|
|
|
case <-sub.Err(): |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
lastHead = ev.Header.Hash() |
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return &Oracle{ |
|
|
|
return &Oracle{ |
|
|
|
backend: backend, |
|
|
|
backend: backend, |
|
|
|