mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
c51573f333
Implemented polygon->eth flow
24 lines
534 B
Go
24 lines
534 B
Go
package health
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
|
)
|
|
|
|
func checkBlockNumber(blockNumber rpc.BlockNumber, api EthAPI) error {
|
|
if api == nil {
|
|
return fmt.Errorf("no connection to the Erigon server or `eth` namespace isn't enabled")
|
|
}
|
|
data, err := api.GetBlockByNumber(context.TODO(), blockNumber, false)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(data) == 0 { // block not found
|
|
return fmt.Errorf("no known block with number %v (%x hex)", blockNumber.Uint64(), blockNumber.Uint64())
|
|
}
|
|
|
|
return nil
|
|
}
|