Shell: add error for blocks inconsistent with the checkpoint
This commit is contained in:
parent
d552c611c5
commit
535616e21e
@ -231,6 +231,7 @@ let () =
|
|||||||
(************************ Validator errors ********************************)
|
(************************ Validator errors ********************************)
|
||||||
|
|
||||||
type error += Inactive_chain of Chain_id.t
|
type error += Inactive_chain of Chain_id.t
|
||||||
|
type error += Checkpoint_error of Block_hash.t * P2p_peer.Id.t option
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
(* Inactive network *)
|
(* Inactive network *)
|
||||||
@ -246,4 +247,28 @@ let () =
|
|||||||
Chain_id.pp chain)
|
Chain_id.pp chain)
|
||||||
Data_encoding.(obj1 (req "inactive_chain" Chain_id.encoding))
|
Data_encoding.(obj1 (req "inactive_chain" Chain_id.encoding))
|
||||||
(function Inactive_chain chain -> Some chain | _ -> None)
|
(function Inactive_chain chain -> Some chain | _ -> None)
|
||||||
(fun chain -> Inactive_chain chain)
|
(fun chain -> Inactive_chain chain) ;
|
||||||
|
register_error_kind
|
||||||
|
`Branch
|
||||||
|
~id:"node.validator.checkpoint_error"
|
||||||
|
~title: "Block incompatble with the current checkpoint."
|
||||||
|
~description: "The block belongs to a branch that is not compatible \
|
||||||
|
with the current checkpoint."
|
||||||
|
~pp: (fun ppf (block, peer) ->
|
||||||
|
match peer with
|
||||||
|
| None ->
|
||||||
|
Format.fprintf ppf
|
||||||
|
"The block %a is incompatible with the current checkpoint."
|
||||||
|
Block_hash.pp_short block
|
||||||
|
| Some peer ->
|
||||||
|
Format.fprintf ppf
|
||||||
|
"The peer %a send us a block which is a sibling \
|
||||||
|
of the configured checkpoint (%a)."
|
||||||
|
P2p_peer.Id.pp peer
|
||||||
|
Block_hash.pp_short block)
|
||||||
|
Data_encoding.(obj2
|
||||||
|
(req "block" Block_hash.encoding)
|
||||||
|
(opt "peer" P2p_peer.Id.encoding))
|
||||||
|
(function Checkpoint_error (block, peer) -> Some (block, peer) | _ -> None)
|
||||||
|
(fun (block, peer) -> Checkpoint_error (block, peer))
|
||||||
|
|
||||||
|
@ -45,3 +45,4 @@ type error +=
|
|||||||
(************************ Validator errors ********************************)
|
(************************ Validator errors ********************************)
|
||||||
|
|
||||||
type error += Inactive_chain of Chain_id.t
|
type error += Inactive_chain of Chain_id.t
|
||||||
|
type error += Checkpoint_error of Block_hash.t * P2p_peer.Id.t option
|
||||||
|
Loading…
Reference in New Issue
Block a user