From d53918451baa7738d355b00218517aed1479ca5b Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Tue, 11 Dec 2018 21:31:28 +0000 Subject: [PATCH] Shell: mempool RPC fixes --- src/lib_shell/mempool_worker.ml | 9 +++++---- src/lib_shell/prevalidator.ml | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib_shell/mempool_worker.ml b/src/lib_shell/mempool_worker.ml index ca7da1a97..b5d303f36 100644 --- a/src/lib_shell/mempool_worker.ml +++ b/src/lib_shell/mempool_worker.ml @@ -602,18 +602,19 @@ module Make(Static: STATIC)(Proto: Registered_protocol.T) let state = Worker.state w in let filter_result = function | Applied _ -> params#applied - | Refused _ -> params#branch_refused - | Branch_refused _ -> params#refused + | Refused _ -> params#refused + | Branch_refused _ -> params#branch_refused | Branch_delayed _ -> params#branch_delayed | _ -> false in let op_stream, stopper = Lwt_watcher.create_stream state.operation_stream in let shutdown () = Lwt_watcher.shutdown stopper in - let next () = + let rec next () = Lwt_stream.get op_stream >>= function | Some (kind, shell, protocol_data) when filter_result kind -> Lwt.return_some [ { Proto.shell ; protocol_data } ] - | _ -> Lwt.return_none in + | Some _ -> next () + | None -> Lwt.return_none in RPC_answer.return_stream { next ; shutdown } ) diff --git a/src/lib_shell/prevalidator.ml b/src/lib_shell/prevalidator.ml index 8d70b1ce0..91575c80c 100644 --- a/src/lib_shell/prevalidator.ml +++ b/src/lib_shell/prevalidator.ml @@ -470,7 +470,7 @@ module Make(Proto: Registered_protocol.T)(Arg: ARG): T = struct (fun (hash, op) -> (hash, map_op op)) (List.rev pv.applied) ; refused = - Operation_hash.Map.map map_op_error pv.branch_refusals ; + Operation_hash.Map.map map_op_error pv.refusals ; branch_refused = Operation_hash.Map.map map_op_error pv.branch_refusals ; branch_delayed = @@ -510,11 +510,11 @@ module Make(Proto: Registered_protocol.T)(Arg: ARG): T = struct let current_mempool = ref (Some current_mempool) in let filter_result = function | `Applied -> params#applied - | `Refused -> params#branch_refused - | `Branch_refused -> params#refused + | `Refused -> params#refused + | `Branch_refused -> params#branch_refused | `Branch_delayed -> params#branch_delayed in - let next () = + let rec next () = match !current_mempool with | Some mempool -> begin current_mempool := None ; @@ -532,7 +532,8 @@ module Make(Proto: Registered_protocol.T)(Arg: ARG): T = struct Proto.operation_data_encoding bytes in Lwt.return_some [ { Proto.shell ; protocol_data } ] - | _ -> Lwt.return_none + | Some _ -> next () + | None -> Lwt.return_none end in let shutdown () = Lwt_watcher.shutdown stopper in