mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 09:50:45 +00:00
fix: always check for error value and return nil, err where possible (#426)
Co-authored-by: wjrjerome <wjrjerome@babylonchain.io>
This commit is contained in:
parent
b739db6a52
commit
a54a645cda
2 changed files with 9 additions and 0 deletions
|
|
@ -451,6 +451,9 @@ func (x *XDPoS) GetSnapshot(chain consensus.ChainReader, header *types.Header) (
|
||||||
switch x.config.BlockConsensusVersion(header.Number, header.Extra, ExtraFieldCheck) {
|
switch x.config.BlockConsensusVersion(header.Number, header.Extra, ExtraFieldCheck) {
|
||||||
case params.ConsensusEngineVersion2:
|
case params.ConsensusEngineVersion2:
|
||||||
sp, err := x.EngineV2.GetSnapshot(chain, header)
|
sp, err := x.EngineV2.GetSnapshot(chain, header)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &utils.PublicApiSnapshot{
|
return &utils.PublicApiSnapshot{
|
||||||
Number: sp.Number,
|
Number: sp.Number,
|
||||||
Hash: sp.Hash,
|
Hash: sp.Hash,
|
||||||
|
|
@ -458,6 +461,9 @@ func (x *XDPoS) GetSnapshot(chain consensus.ChainReader, header *types.Header) (
|
||||||
}, err
|
}, err
|
||||||
default: // Default "v1"
|
default: // Default "v1"
|
||||||
sp, err := x.EngineV1.GetSnapshot(chain, header)
|
sp, err := x.EngineV1.GetSnapshot(chain, header)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
// Convert to a standard PublicApiSnapshot type, otherwise it's a breaking change to API
|
// Convert to a standard PublicApiSnapshot type, otherwise it's a breaking change to API
|
||||||
return &utils.PublicApiSnapshot{
|
return &utils.PublicApiSnapshot{
|
||||||
Number: sp.Number,
|
Number: sp.Number,
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,9 @@ func (x *XDPoS_v2) GetRoundNumber(header *types.Header) (types.Round, error) {
|
||||||
|
|
||||||
func (x *XDPoS_v2) GetSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error) {
|
func (x *XDPoS_v2) GetSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error) {
|
||||||
snap, err := x.getSnapshot(chain, header.Number.Uint64(), false)
|
snap, err := x.getSnapshot(chain, header.Number.Uint64(), false)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return snap.NextEpochMasterNodes, err
|
return snap.NextEpochMasterNodes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue