fix for when the code is run using the gasprice testBackend

This commit is contained in:
Jared Wasinger 2025-01-14 15:00:47 +08:00
parent 0510fc8662
commit d8095c40e5

View file

@ -121,6 +121,7 @@ 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)
sub := backend.SubscribeChainHeadEvent(headEvent) sub := backend.SubscribeChainHeadEvent(headEvent)
if sub != nil { // the gasprice testBackend doesn't support subscribing to head events
go func() { go func() {
var lastHead common.Hash var lastHead common.Hash
for { for {
@ -135,6 +136,7 @@ func NewOracle(backend OracleBackend, params Config, startPrice *big.Int) *Oracl
} }
} }
}() }()
}
return &Oracle{ return &Oracle{
backend: backend, backend: backend,