mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
check if block is nil (#4528)
* check if block is nil * added to rpcdaemon22
This commit is contained in:
parent
5e2f6bb2db
commit
389af4fc06
@ -203,6 +203,9 @@ func (b *GasPriceOracleBackend) HeaderByNumber(ctx context.Context, number rpc.B
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if block == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return block.Header(), nil
|
return block.Header(), nil
|
||||||
}
|
}
|
||||||
func (b *GasPriceOracleBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
func (b *GasPriceOracleBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
||||||
|
@ -202,6 +202,9 @@ func (b *GasPriceOracleBackend) HeaderByNumber(ctx context.Context, number rpc.B
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if block == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
return block.Header(), nil
|
return block.Header(), nil
|
||||||
}
|
}
|
||||||
func (b *GasPriceOracleBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
func (b *GasPriceOracleBackend) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) {
|
||||||
|
@ -118,6 +118,9 @@ func NewOracle(backend OracleBackend, params Config) *Oracle {
|
|||||||
// baseFee to the returned bigInt
|
// baseFee to the returned bigInt
|
||||||
func (gpo *Oracle) SuggestTipCap(ctx context.Context) (*big.Int, error) {
|
func (gpo *Oracle) SuggestTipCap(ctx context.Context) (*big.Int, error) {
|
||||||
head, _ := gpo.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
head, _ := gpo.backend.HeaderByNumber(ctx, rpc.LatestBlockNumber)
|
||||||
|
if head == nil {
|
||||||
|
return gpo.lastPrice, nil
|
||||||
|
}
|
||||||
headHash := head.Hash()
|
headHash := head.Hash()
|
||||||
|
|
||||||
// If the latest gasprice is still available, return it.
|
// If the latest gasprice is still available, return it.
|
||||||
|
Loading…
Reference in New Issue
Block a user