Shell/RPC: also list embedded protocols
This commit is contained in:
parent
04c920df29
commit
9bc7b1e573
@ -31,7 +31,7 @@ end
|
|||||||
let () =
|
let () =
|
||||||
Format.printf {|
|
Format.printf {|
|
||||||
let () =
|
let () =
|
||||||
let module Ignored = Tezos_protocol_updater.Registered_protocol.Register
|
let module Ignored = Tezos_protocol_updater.Registered_protocol.Register_embedded
|
||||||
(Tezos_embedded_protocol_environment_%s.Environment)
|
(Tezos_embedded_protocol_environment_%s.Environment)
|
||||||
(Tezos_embedded_raw_protocol_%s.Main)
|
(Tezos_embedded_raw_protocol_%s.Main)
|
||||||
(Source) in
|
(Source) in
|
||||||
|
@ -42,6 +42,9 @@ module VersionTable = Protocol_hash.Table
|
|||||||
let versions : (module T) VersionTable.t =
|
let versions : (module T) VersionTable.t =
|
||||||
VersionTable.create 20
|
VersionTable.create 20
|
||||||
|
|
||||||
|
let sources : Protocol.t VersionTable.t =
|
||||||
|
VersionTable.create 20
|
||||||
|
|
||||||
let mem hash =
|
let mem hash =
|
||||||
VersionTable.mem versions hash ||
|
VersionTable.mem versions hash ||
|
||||||
Tezos_protocol_registerer.Registerer.mem hash
|
Tezos_protocol_registerer.Registerer.mem hash
|
||||||
@ -57,7 +60,17 @@ let get hash =
|
|||||||
try Some (get_exn hash)
|
try Some (get_exn hash)
|
||||||
with Not_found -> None
|
with Not_found -> None
|
||||||
|
|
||||||
module Register
|
let list_embedded () =
|
||||||
|
VersionTable.fold (fun k _ acc -> k :: acc) sources []
|
||||||
|
|
||||||
|
let get_embedded_sources_exn hash =
|
||||||
|
VersionTable.find sources hash
|
||||||
|
|
||||||
|
let get_embedded_sources hash =
|
||||||
|
try Some (get_embedded_sources_exn hash)
|
||||||
|
with Not_found -> None
|
||||||
|
|
||||||
|
module Register_embedded
|
||||||
(Env : Tezos_protocol_environment_shell.V1)
|
(Env : Tezos_protocol_environment_shell.V1)
|
||||||
(Proto : Env.Updater.PROTOCOL)
|
(Proto : Env.Updater.PROTOCOL)
|
||||||
(Source : sig
|
(Source : sig
|
||||||
@ -73,7 +86,8 @@ module Register
|
|||||||
let module Name = struct
|
let module Name = struct
|
||||||
let name = Protocol_hash.to_b58check hash
|
let name = Protocol_hash.to_b58check hash
|
||||||
end in
|
end in
|
||||||
(* TODO add a memory table for "embedded" sources... *)
|
VersionTable.add
|
||||||
|
sources hash Source.sources ;
|
||||||
VersionTable.add
|
VersionTable.add
|
||||||
versions hash
|
versions hash
|
||||||
(module struct
|
(module struct
|
||||||
|
@ -25,8 +25,12 @@ val mem: Protocol_hash.t -> bool
|
|||||||
val get: Protocol_hash.t -> t option
|
val get: Protocol_hash.t -> t option
|
||||||
val get_exn: Protocol_hash.t -> t
|
val get_exn: Protocol_hash.t -> t
|
||||||
|
|
||||||
|
val list_embedded: unit -> Protocol_hash.t list
|
||||||
|
|
||||||
module Register
|
val get_embedded_sources: Protocol_hash.t -> Protocol.t option
|
||||||
|
val get_embedded_sources_exn: Protocol_hash.t -> Protocol.t
|
||||||
|
|
||||||
|
module Register_embedded
|
||||||
(Env : Tezos_protocol_environment_shell.V1)
|
(Env : Tezos_protocol_environment_shell.V1)
|
||||||
(Proto : Env.Updater.PROTOCOL)
|
(Proto : Env.Updater.PROTOCOL)
|
||||||
(Source : sig
|
(Source : sig
|
||||||
|
@ -17,12 +17,16 @@ let build_rpc_directory state =
|
|||||||
|
|
||||||
gen_register0 Protocol_services.S.list begin fun () () ->
|
gen_register0 Protocol_services.S.list begin fun () () ->
|
||||||
State.Protocol.list state >>= fun set ->
|
State.Protocol.list state >>= fun set ->
|
||||||
let protocols = Protocol_hash.Set.elements set in
|
let protocols =
|
||||||
|
Protocol_hash.Set.elements set @
|
||||||
|
Registered_protocol.list_embedded () in
|
||||||
RPC_answer.return protocols
|
RPC_answer.return protocols
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
register1 Protocol_services.S.contents begin fun hash () () ->
|
register1 Protocol_services.S.contents begin fun hash () () ->
|
||||||
State.Protocol.read state hash
|
match Registered_protocol.get_embedded_sources hash with
|
||||||
|
| Some p -> return p
|
||||||
|
| None -> State.Protocol.read state hash
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
!dir
|
!dir
|
||||||
|
Loading…
Reference in New Issue
Block a user