forked from cerc-io/plugeth
rpc: avoid crashing on clique getSigner during sync (#23832)
This commit is contained in:
parent
c113520d5d
commit
ff844918e8
@ -214,6 +214,9 @@ func (api *API) GetSigner(rlpOrBlockNr *blockNumberOrHashOrRLP) (common.Address,
|
|||||||
} else if number, ok := blockNrOrHash.Number(); ok {
|
} else if number, ok := blockNrOrHash.Number(); ok {
|
||||||
header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
|
header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
|
||||||
}
|
}
|
||||||
|
if header == nil {
|
||||||
|
return common.Address{}, fmt.Errorf("missing block %v", blockNrOrHash.String())
|
||||||
|
}
|
||||||
return api.clique.Author(header)
|
return api.clique.Author(header)
|
||||||
}
|
}
|
||||||
block := new(types.Block)
|
block := new(types.Block)
|
||||||
|
10
rpc/types.go
10
rpc/types.go
@ -186,6 +186,16 @@ func (bnh *BlockNumberOrHash) Number() (BlockNumber, bool) {
|
|||||||
return BlockNumber(0), false
|
return BlockNumber(0), false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bnh *BlockNumberOrHash) String() string {
|
||||||
|
if bnh.BlockNumber != nil {
|
||||||
|
return strconv.Itoa(int(*bnh.BlockNumber))
|
||||||
|
}
|
||||||
|
if bnh.BlockHash != nil {
|
||||||
|
return bnh.BlockHash.String()
|
||||||
|
}
|
||||||
|
return "nil"
|
||||||
|
}
|
||||||
|
|
||||||
func (bnh *BlockNumberOrHash) Hash() (common.Hash, bool) {
|
func (bnh *BlockNumberOrHash) Hash() (common.Hash, bool) {
|
||||||
if bnh.BlockHash != nil {
|
if bnh.BlockHash != nil {
|
||||||
return *bnh.BlockHash, true
|
return *bnh.BlockHash, true
|
||||||
|
Loading…
Reference in New Issue
Block a user