From 0b98dbd4725f6092b4b1af8449cff49f1b721eff Mon Sep 17 00:00:00 2001 From: Marco Stronati Date: Thu, 22 Nov 2018 15:44:14 +0100 Subject: [PATCH] Shell: add rpc to trigget a Get_current_event --- src/lib_shell/prevalidator.ml | 7 +++++++ src/lib_shell_services/block_services.ml | 11 +++++++++++ src/lib_shell_services/block_services.mli | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/lib_shell/prevalidator.ml b/src/lib_shell/prevalidator.ml index a8d663877..841efd887 100644 --- a/src/lib_shell/prevalidator.ml +++ b/src/lib_shell/prevalidator.ml @@ -461,6 +461,13 @@ module Make(Proto: Registered_protocol.T)(Arg: ARG): T = struct Operation_hash.Map.map map_op pv.pending ; }) ; + dir := RPC_directory.register !dir + (Proto_services.S.Mempool.request_operations RPC_path.open_root) + (fun pv () () -> + Distributed_db.Request.current_head pv.chain_db () ; + return_unit + ) ; + dir := RPC_directory.gen_register !dir (Proto_services.S.Mempool.monitor_operations RPC_path.open_root) begin fun { applied ; refusals = refused ; branch_refusals = branch_refused ; branch_delays = branch_delayed ; operation_stream } params () -> diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 3a2d01f97..9857f97fe 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -736,6 +736,14 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct ~output: (list next_operation_encoding) RPC_path.(path / "monitor_operations") + let request_operations path = + RPC_service.post_service + ~description:"Request the operations of your peers." + ~input: Data_encoding.empty + ~query: RPC_query.empty + ~output: Data_encoding.empty + RPC_path.(path / "request_operations") + end let live_blocks = @@ -945,6 +953,9 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct end) () + let request_operations ctxt ?(chain = `Main) () = + let s = S.Mempool.request_operations (mempool_path chain_path) in + RPC_context.make_call1 s ctxt chain () () end let live_blocks ctxt = diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index f6bf9cd2e..6913d4806 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -261,6 +261,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig ?refused:bool -> unit -> (Next_proto.operation list Lwt_stream.t * stopper) tzresult Lwt.t + val request_operations: + #simple -> + ?chain:chain -> + unit -> unit tzresult Lwt.t + end val live_blocks: @@ -417,6 +422,11 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig unit, Next_proto.operation list) RPC_service.t + val request_operations : + ('a, 'b) RPC_path.t -> + ([ `POST ], 'a, + 'b , unit, unit, unit) RPC_service.t + end val live_blocks: