From 76bf007660f46b34d0dfea3e44b12644bb15fd60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Fri, 22 Sep 2017 18:20:26 +0200 Subject: [PATCH] Shell/Irmin: tag the commit of the head as the "git branch" --- src/node/shell/state.ml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/node/shell/state.ml b/src/node/shell/state.ml index bdef798ea..c4f1481ee 100644 --- a/src/node/shell/state.ml +++ b/src/node/shell/state.ml @@ -84,10 +84,18 @@ let read_chain_store { chain_state } f = f state.chain_store state.data end -let update_chain_store { chain_state } f = +let update_chain_store { net_id ; context_index ; chain_state } f = Shared.use chain_state begin fun state -> f state.chain_store state.data >>= fun (data, res) -> - Utils.iter_option data ~f:(fun data -> state.data <- data) ; + Lwt_utils.may data + ~f:begin fun data -> + state.data <- data ; + Shared.use context_index begin fun context_index -> + Context.set_head context_index net_id + data.current_head.contents.context + end >>= fun () -> + Lwt.return_unit + end >>= fun () -> Lwt.return res end