reject invalid protocols
This commit is contained in:
parent
488373551b
commit
ec79241adb
@ -25,11 +25,16 @@ let inject_operation validator ?force bytes =
|
|||||||
Lwt.return (hash, t)
|
Lwt.return (hash, t)
|
||||||
|
|
||||||
let inject_protocol state ?force:_ proto =
|
let inject_protocol state ?force:_ proto =
|
||||||
(* TODO: Validate the protocol *)
|
|
||||||
let proto_bytes = Store.Protocol.to_bytes proto in
|
let proto_bytes = Store.Protocol.to_bytes proto in
|
||||||
let hash = Protocol_hash.hash_bytes [proto_bytes] in
|
let hash = Protocol_hash.hash_bytes [proto_bytes] in
|
||||||
let t = State.Protocol.store state proto_bytes >>|? ignore in
|
let validation = Updater.compile hash proto >>= function
|
||||||
Lwt.return (hash, t)
|
| false -> Lwt.fail_with (Format.asprintf "Invalid protocol %a: compilation failed" Protocol_hash.pp_short hash)
|
||||||
|
| true ->
|
||||||
|
State.Protocol.store state proto_bytes >>= function
|
||||||
|
| Ok None -> Lwt.fail_with "Previously registred protocol"
|
||||||
|
| t -> t >|? ignore |> Lwt.return
|
||||||
|
in
|
||||||
|
Lwt.return (hash, validation)
|
||||||
|
|
||||||
let process_operation state validator bytes =
|
let process_operation state validator bytes =
|
||||||
State.Operation.store state bytes >>= function
|
State.Operation.store state bytes >>= function
|
||||||
|
@ -70,7 +70,7 @@ module type REGISTRED_PROTOCOL = sig
|
|||||||
and type 'a tzresult := 'a tzresult
|
and type 'a tzresult := 'a tzresult
|
||||||
end
|
end
|
||||||
|
|
||||||
type component = {
|
type component = Store.component = {
|
||||||
name : string ;
|
name : string ;
|
||||||
interface : string option ;
|
interface : string option ;
|
||||||
implementation : string ;
|
implementation : string ;
|
||||||
|
Loading…
Reference in New Issue
Block a user