mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
ethapi: add sanity check
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
35dd61a3bf
commit
e5d6f7d933
1 changed files with 9 additions and 1 deletions
|
|
@ -1831,8 +1831,16 @@ func (api *DebugAPI) ChaindbCompact() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHead rewinds the head of the blockchain to a previous block.
|
// SetHead rewinds the head of the blockchain to a previous block.
|
||||||
func (api *DebugAPI) SetHead(number hexutil.Uint64) {
|
func (api *DebugAPI) SetHead(number hexutil.Uint64) error {
|
||||||
|
header := api.b.CurrentHeader()
|
||||||
|
if header == nil {
|
||||||
|
return errors.New("current header is not available")
|
||||||
|
}
|
||||||
|
if header.Number.Uint64() <= uint64(number) {
|
||||||
|
return errors.New("not allowed to rewind to a later block")
|
||||||
|
}
|
||||||
api.b.SetHead(uint64(number))
|
api.b.SetHead(uint64(number))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAPI offers network related RPC methods
|
// NetAPI offers network related RPC methods
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue