From 481772fc98434065d8f802b9b34f5f3e0a7f6937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Thu, 8 Nov 2018 09:46:28 +0800 Subject: [PATCH] Mempool_worker: only introduce errors where they are needed --- src/lib_shell/mempool_worker.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib_shell/mempool_worker.ml b/src/lib_shell/mempool_worker.ml index c242a823b..267846214 100644 --- a/src/lib_shell/mempool_worker.ml +++ b/src/lib_shell/mempool_worker.ml @@ -481,13 +481,13 @@ module Make(Proto: Registered_protocol.T) : T with module Proto = Proto = struct (* this function update the internal state of the worker *) let validate_helper w parsed_op = let state = Worker.state w in - apply_operation state parsed_op >>= fun (validation_state,result) -> + apply_operation state parsed_op >>= fun (validation_state, result) -> begin match validation_state with | Some validation_state -> state.validation_state <- validation_state | None -> () end ; - return result + Lwt.return result let notify_helper w result { Operation.shell ; proto } = let state = Worker.state w in @@ -503,12 +503,12 @@ module Make(Proto: Registered_protocol.T) : T with module Proto = Proto = struct let state = Worker.state w in match Cache.find_validated_opt state.cache parsed_op with | None | Some (Branch_delayed _) -> - validate_helper w parsed_op >>=? fun result -> + validate_helper w parsed_op >>= fun result -> Cache.add_validated state.cache parsed_op result; (* operations are notified only the first time *) notify_helper w result parsed_op.raw ; - return result - | Some result -> return result + Lwt.return result + | Some result -> Lwt.return result let on_parse w raw_op = let state = Worker.state w in @@ -524,7 +524,7 @@ module Make(Proto: Registered_protocol.T) : T with module Proto = Proto = struct type r. t -> r Request.t -> r tzresult Lwt.t = fun w request -> match request with | Request.Parse raw_op -> on_parse w raw_op - | Request.Validate parsed_op -> on_validate w parsed_op + | Request.Validate parsed_op -> on_validate w parsed_op >>= return let on_launch (_ : t) (_ : Name.t) ( { chain_db ; validation_state } as parameters ) = let chain_state = Distributed_db.chain_state chain_db in