diff --git a/consensus/clique/api.go b/consensus/clique/api.go index 6129b5cc52..03f2daffa0 100644 --- a/consensus/clique/api.go +++ b/consensus/clique/api.go @@ -214,6 +214,9 @@ func (api *API) GetSigner(rlpOrBlockNr *blockNumberOrHashOrRLP) (common.Address, } else if number, ok := blockNrOrHash.Number(); ok { 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) } block := new(types.Block) diff --git a/rpc/types.go b/rpc/types.go index d9c2317a78..ca52d474d9 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -186,6 +186,16 @@ func (bnh *BlockNumberOrHash) Number() (BlockNumber, bool) { 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) { if bnh.BlockHash != nil { return *bnh.BlockHash, true