From 22bf535d681dcf0f390961e1f1d7306795786051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sat, 2 Jun 2018 19:06:54 +0200 Subject: [PATCH] Shell: faster propagation of protocols --- src/lib_shell/peer_validator.ml | 5 ++++- src/lib_shell/protocol_validator.ml | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib_shell/peer_validator.ml b/src/lib_shell/peer_validator.ml index 4073f15c3..aa76c3eaf 100644 --- a/src/lib_shell/peer_validator.ml +++ b/src/lib_shell/peer_validator.ml @@ -265,7 +265,10 @@ let on_error w r st errs = ~peer:pv.peer_id ~timeout:pv.parameters.limits.protocol_timeout protocol >>= function - | Ok _ -> return () + | Ok _ -> + Distributed_db.Request.current_head + pv.parameters.chain_db ~peer:pv.peer_id () ; + return () | Error _ -> (* TODO: punish *) debug w diff --git a/src/lib_shell/protocol_validator.ml b/src/lib_shell/protocol_validator.ml index 599d2946e..b374bd507 100644 --- a/src/lib_shell/protocol_validator.ml +++ b/src/lib_shell/protocol_validator.ml @@ -119,8 +119,14 @@ let fetch_and_compile_protocol pv ?peer ?timeout hash = Distributed_db.Protocol.read_opt pv.db hash >>= function | Some protocol -> return protocol | None -> - lwt_log_notice "Fetching protocol %a from peer " - Protocol_hash.pp_short hash >>= fun () -> + let may_print_peer ppf = function + | None -> () + | Some peer -> + Format.fprintf ppf " from peer %a" + P2p_peer.Id.pp peer in + lwt_log_notice "Fetching protocol %a%a" + Protocol_hash.pp_short hash + may_print_peer peer >>= fun () -> Distributed_db.Protocol.fetch pv.db ?peer ?timeout hash () end >>=? fun protocol -> validate pv hash protocol >>=? fun proto ->