From d05dceb0b077c2ac3a0e05fc6883f48d2c1f11fd Mon Sep 17 00:00:00 2001 From: Marco Stronati Date: Fri, 2 Feb 2018 20:40:23 +0100 Subject: [PATCH] State: export predecessor_n --- src/lib_shell/state.ml | 5 +++++ src/lib_shell/state.mli | 1 + 2 files changed, 6 insertions(+) diff --git a/src/lib_shell/state.ml b/src/lib_shell/state.ml index 5f21d1b26..12ab06481 100644 --- a/src/lib_shell/state.ml +++ b/src/lib_shell/state.ml @@ -541,6 +541,11 @@ module Block = struct read_exn net_state header.shell.predecessor >>= fun block -> Lwt.return (Some block) + let predecessor_n (net: Net.t) (b: Block_hash.t) (distance: int) : Block_hash.t option Lwt.t = + Shared.use net.block_store (fun store -> + predecessor_n store b distance) + + type error += Inconsistent_hash of Context_hash.t * Context_hash.t let () = diff --git a/src/lib_shell/state.mli b/src/lib_shell/state.mli index 9f3e39c38..813459552 100644 --- a/src/lib_shell/state.mli +++ b/src/lib_shell/state.mli @@ -138,6 +138,7 @@ module Block : sig val is_genesis: t -> bool val predecessor: t -> block option Lwt.t + val predecessor_n: Net.t -> Block_hash.t -> int -> Block_hash.t option Lwt.t val context: t -> Context.t Lwt.t val protocol_hash: t -> Protocol_hash.t Lwt.t