Skip to content

Commit

Permalink
eth/hooks: check nil stateDB to fix issue XinFinOrg#271
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Jul 22, 2024
1 parent 337acac commit 83f4c89
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions eth/hooks/engine_v1_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,14 @@ func AttachConsensusV1Hooks(adaptor *XDPoS.XDPoS, bc *core.BlockChain, chainConf
)

stateDB, err := bc.StateAt(bc.GetBlockByHash(block).Root())
candidateAddresses = state.GetCandidates(stateDB)

if err != nil {
return nil, err
}
if stateDB == nil {
return nil, errors.New("nil stateDB in HookGetSignersFromContract")
}

candidateAddresses = state.GetCandidates(stateDB)
for _, address := range candidateAddresses {
v, err := validator.GetCandidateCap(opts, address)
if err != nil {
Expand Down

0 comments on commit 83f4c89

Please sign in to comment.