2018-04-16 02:44:24 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2018-04-21 15:09:59 +04:00
|
|
|
let build_rpc_directory state =
|
2018-04-16 02:44:24 +04:00
|
|
|
|
|
|
|
let dir : unit RPC_directory.t ref = ref RPC_directory.empty in
|
|
|
|
let gen_register0 s f =
|
|
|
|
dir := RPC_directory.gen_register !dir s (fun () p q -> f p q) in
|
|
|
|
let register1 s f =
|
|
|
|
dir := RPC_directory.register !dir s (fun ((), a) p q -> f a p q) in
|
|
|
|
|
2018-04-21 15:09:59 +04:00
|
|
|
gen_register0 Protocol_services.S.list begin fun () () ->
|
2018-04-16 02:44:24 +04:00
|
|
|
State.Protocol.list state >>= fun set ->
|
|
|
|
let protocols = Protocol_hash.Set.elements set in
|
2018-04-21 15:09:59 +04:00
|
|
|
RPC_answer.return protocols
|
|
|
|
end ;
|
2018-04-16 02:44:24 +04:00
|
|
|
|
|
|
|
register1 Protocol_services.S.contents begin fun hash () () ->
|
|
|
|
State.Protocol.read state hash
|
|
|
|
end ;
|
|
|
|
|
|
|
|
!dir
|