Client refactor: add calling function in Worker_services
This commit is contained in:
parent
1858bdd852
commit
0e675c2d16
@ -449,14 +449,14 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Prevalidators *)
|
(* Workers : Prevalidators *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Worker_services.Prevalidators.list
|
RPC_directory.register0 dir Worker_services.Prevalidators.S.list
|
||||||
(fun () () ->
|
(fun () () ->
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
(List.map
|
(List.map
|
||||||
(fun (id, w) -> (id, Prevalidator.status w))
|
(fun (id, w) -> (id, Prevalidator.status w))
|
||||||
(Prevalidator.running_workers ()))) in
|
(Prevalidator.running_workers ()))) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Worker_services.Prevalidators.state
|
RPC_directory.register1 dir Worker_services.Prevalidators.S.state
|
||||||
(fun net_id () () ->
|
(fun net_id () () ->
|
||||||
let w = List.assoc net_id (Prevalidator.running_workers ()) in
|
let w = List.assoc net_id (Prevalidator.running_workers ()) in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
@ -468,7 +468,7 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Block_validator *)
|
(* Workers : Block_validator *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Worker_services.Block_validator.state
|
RPC_directory.register0 dir Worker_services.Block_validator.S.state
|
||||||
(fun () () ->
|
(fun () () ->
|
||||||
let w = Block_validator.running_worker () in
|
let w = Block_validator.running_worker () in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
@ -480,7 +480,7 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Peer validators *)
|
(* Workers : Peer validators *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Worker_services.Peer_validators.list
|
RPC_directory.register1 dir Worker_services.Peer_validators.S.list
|
||||||
(fun net_id () () ->
|
(fun net_id () () ->
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
(List.filter_map
|
(List.filter_map
|
||||||
@ -490,7 +490,7 @@ let build_rpc_directory node =
|
|||||||
else None)
|
else None)
|
||||||
(Peer_validator.running_workers ()))) in
|
(Peer_validator.running_workers ()))) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register2 dir Worker_services.Peer_validators.state
|
RPC_directory.register2 dir Worker_services.Peer_validators.S.state
|
||||||
(fun net_id peer_id () () ->
|
(fun net_id peer_id () () ->
|
||||||
let w = List.assoc (net_id, peer_id) (Peer_validator.running_workers ()) in
|
let w = List.assoc (net_id, peer_id) (Peer_validator.running_workers ()) in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
@ -502,14 +502,14 @@ let build_rpc_directory node =
|
|||||||
(* Workers : Net validators *)
|
(* Workers : Net validators *)
|
||||||
|
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register0 dir Worker_services.Net_validators.list
|
RPC_directory.register0 dir Worker_services.Net_validators.S.list
|
||||||
(fun () () ->
|
(fun () () ->
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
(List.map
|
(List.map
|
||||||
(fun (id, w) -> (id, Net_validator.status w))
|
(fun (id, w) -> (id, Net_validator.status w))
|
||||||
(Net_validator.running_workers ()))) in
|
(Net_validator.running_workers ()))) in
|
||||||
let dir =
|
let dir =
|
||||||
RPC_directory.register1 dir Worker_services.Net_validators.state
|
RPC_directory.register1 dir Worker_services.Net_validators.S.state
|
||||||
(fun net_id () () ->
|
(fun net_id () () ->
|
||||||
let w = List.assoc net_id (Net_validator.running_workers ()) in
|
let w = List.assoc net_id (Net_validator.running_workers ()) in
|
||||||
RPC_answer.return
|
RPC_answer.return
|
||||||
|
@ -11,15 +11,13 @@ open Data_encoding
|
|||||||
|
|
||||||
module Prevalidators = struct
|
module Prevalidators = struct
|
||||||
|
|
||||||
|
module S = struct
|
||||||
|
|
||||||
let (net_id_arg : Net_id.t RPC_arg.t) =
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
||||||
RPC_arg.make
|
RPC_arg.like
|
||||||
~name:"net_id"
|
Net_id.rpc_arg
|
||||||
~descr:"The network identifier of whom the prevalidator is responsible."
|
~descr:"The network identifier of whom the prevalidator is responsible."
|
||||||
~destruct:(fun s -> try
|
"net_id"
|
||||||
Ok (Net_id.of_b58check_exn s)
|
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:Net_id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let list =
|
let list =
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
@ -44,12 +42,20 @@ module Prevalidators = struct
|
|||||||
Prevalidator_worker_state.Request.encoding
|
Prevalidator_worker_state.Request.encoding
|
||||||
Prevalidator_worker_state.Event.encoding
|
Prevalidator_worker_state.Event.encoding
|
||||||
RPC_error.encoding)
|
RPC_error.encoding)
|
||||||
RPC_path.(root / "workers" / "prevalidators" /: net_id_arg )
|
RPC_path.(root / "workers" / "prevalidators" /: Net_id.rpc_arg )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let list ctxt = make_call S.list ctxt () () ()
|
||||||
|
let state ctxt h = make_call1 S.state ctxt h () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Block_validator = struct
|
module Block_validator = struct
|
||||||
|
|
||||||
|
module S = struct
|
||||||
|
|
||||||
let state =
|
let state =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
@ -63,19 +69,22 @@ module Block_validator = struct
|
|||||||
RPC_error.encoding)
|
RPC_error.encoding)
|
||||||
RPC_path.(root / "workers" / "block_validator")
|
RPC_path.(root / "workers" / "block_validator")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let state ctxt = make_call S.state ctxt () () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Peer_validators = struct
|
module Peer_validators = struct
|
||||||
|
|
||||||
|
module S = struct
|
||||||
|
|
||||||
let (net_id_arg : Net_id.t RPC_arg.t) =
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
||||||
RPC_arg.make
|
RPC_arg.like
|
||||||
~name:"net_id"
|
Net_id.rpc_arg
|
||||||
~descr:"The network identifier the peer validator is associated to."
|
~descr:"The network identifier the peer validator is associated to."
|
||||||
~destruct:(fun s -> try
|
"net_id"
|
||||||
Ok (Net_id.of_b58check_exn s)
|
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:Net_id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) =
|
let (peer_id_arg : P2p_peer.Id.t RPC_arg.t) =
|
||||||
RPC_arg.make
|
RPC_arg.make
|
||||||
@ -112,19 +121,22 @@ module Peer_validators = struct
|
|||||||
RPC_error.encoding)
|
RPC_error.encoding)
|
||||||
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg)
|
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let list ctxt n = make_call1 S.list ctxt n () ()
|
||||||
|
let state ctxt n h = make_call2 S.state ctxt n h () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Net_validators = struct
|
module Net_validators = struct
|
||||||
|
|
||||||
|
module S = struct
|
||||||
let (net_id_arg : Net_id.t RPC_arg.t) =
|
let (net_id_arg : Net_id.t RPC_arg.t) =
|
||||||
RPC_arg.make
|
RPC_arg.like
|
||||||
~name:"net_id"
|
Net_id.rpc_arg
|
||||||
~descr:"The network identifier of whom the net validator is responsible."
|
~descr:"The network identifier of whom the net validator is responsible."
|
||||||
~destruct:(fun s -> try
|
"net_id"
|
||||||
Ok (Net_id.of_b58check_exn s)
|
|
||||||
with Failure msg -> Error msg)
|
|
||||||
~construct:Net_id.to_b58check
|
|
||||||
()
|
|
||||||
|
|
||||||
let list =
|
let list =
|
||||||
RPC_service.post_service
|
RPC_service.post_service
|
||||||
@ -151,4 +163,10 @@ module Net_validators = struct
|
|||||||
RPC_error.encoding)
|
RPC_error.encoding)
|
||||||
RPC_path.(root / "workers" / "net_validators" /: net_id_arg )
|
RPC_path.(root / "workers" / "net_validators" /: net_id_arg )
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
let list ctxt = make_call S.list ctxt () () ()
|
||||||
|
let state ctxt h = make_call1 S.state ctxt h () ()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -7,10 +7,19 @@
|
|||||||
(* *)
|
(* *)
|
||||||
(**************************************************************************)
|
(**************************************************************************)
|
||||||
|
|
||||||
|
open RPC_context
|
||||||
|
|
||||||
module Prevalidators : sig
|
module Prevalidators : sig
|
||||||
|
|
||||||
open Prevalidator_worker_state
|
open Prevalidator_worker_state
|
||||||
|
|
||||||
|
val list:
|
||||||
|
#simple -> (Net_id.t * Worker_types.worker_status) list tzresult Lwt.t
|
||||||
|
val state:
|
||||||
|
#simple -> Net_id.t -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
|
|
||||||
|
module S : sig
|
||||||
|
|
||||||
val list :
|
val list :
|
||||||
([ `POST ], unit,
|
([ `POST ], unit,
|
||||||
unit, unit, unit,
|
unit, unit, unit,
|
||||||
@ -21,23 +30,42 @@ module Prevalidators : sig
|
|||||||
unit * Net_id.t, unit, unit,
|
unit * Net_id.t, unit, unit,
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Block_validator : sig
|
module Block_validator : sig
|
||||||
|
|
||||||
open Block_validator_worker_state
|
open Block_validator_worker_state
|
||||||
|
|
||||||
|
val state:
|
||||||
|
#simple -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
|
|
||||||
|
module S : sig
|
||||||
|
|
||||||
val state :
|
val state :
|
||||||
([ `POST ], unit,
|
([ `POST ], unit,
|
||||||
unit, unit, unit,
|
unit, unit, unit,
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Peer_validators : sig
|
module Peer_validators : sig
|
||||||
|
|
||||||
open Peer_validator_worker_state
|
open Peer_validator_worker_state
|
||||||
|
|
||||||
|
val list:
|
||||||
|
#simple -> Net_id.t ->
|
||||||
|
(P2p_peer.Id.t * Worker_types.worker_status) list tzresult Lwt.t
|
||||||
|
|
||||||
|
val state:
|
||||||
|
#simple ->
|
||||||
|
Net_id.t -> P2p_peer.Id.t -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
|
|
||||||
|
module S : sig
|
||||||
|
|
||||||
val list :
|
val list :
|
||||||
([ `POST ], unit,
|
([ `POST ], unit,
|
||||||
unit * Net_id.t, unit, unit,
|
unit * Net_id.t, unit, unit,
|
||||||
@ -48,12 +76,21 @@ module Peer_validators : sig
|
|||||||
(unit * Net_id.t) * P2p_peer.Id.t, unit, unit,
|
(unit * Net_id.t) * P2p_peer.Id.t, unit, unit,
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Net_validators : sig
|
module Net_validators : sig
|
||||||
|
|
||||||
open Net_validator_worker_state
|
open Net_validator_worker_state
|
||||||
|
|
||||||
|
val list:
|
||||||
|
#simple -> (Net_id.t * Worker_types.worker_status) list tzresult Lwt.t
|
||||||
|
val state:
|
||||||
|
#simple -> Net_id.t -> (Request.view, Event.t) Worker_types.full_status tzresult Lwt.t
|
||||||
|
|
||||||
|
module S : sig
|
||||||
|
|
||||||
val list :
|
val list :
|
||||||
([ `POST ], unit,
|
([ `POST ], unit,
|
||||||
unit, unit, unit,
|
unit, unit, unit,
|
||||||
@ -64,4 +101,6 @@ module Net_validators : sig
|
|||||||
unit * Net_id.t, unit, unit,
|
unit * Net_id.t, unit, unit,
|
||||||
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
(Request.view, Event.t) Worker_types.full_status) RPC_service.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user