diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 47b3a2d4c..b4daf3195 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -473,14 +473,21 @@ end module Seed : sig + type seed + type error += | Unknown of { oldest : Cycle.t ; cycle : Cycle.t ; latest : Cycle.t } + val for_cycle: + context -> Cycle.t -> seed tzresult Lwt.t + val cycle_end: context -> Cycle.t -> (context * Nonce.unrevealed list) tzresult Lwt.t + val seed_encoding : seed Data_encoding.t + end module Contract : sig diff --git a/src/proto_alpha/lib_protocol/src/alpha_services.ml b/src/proto_alpha/lib_protocol/src/alpha_services.ml index 6e926a41e..f6ac15903 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_services.ml +++ b/src/proto_alpha/lib_protocol/src/alpha_services.ml @@ -11,6 +11,35 @@ open Alpha_context let custom_root = RPC_path.open_root +module Seed = struct + + module S = struct + + open Data_encoding + + let seed = + RPC_service.post_service + ~description: "Seed of the cycle to which the block belongs." + ~query: RPC_query.empty + ~input: empty + ~output: Seed.seed_encoding + RPC_path.(custom_root / "context" / "seed") + + end + + let () = + let open Services_registration in + register0 S.seed begin fun ctxt () () -> + let l = Level.current ctxt in + Seed.for_cycle ctxt l.cycle + end + + + let get ctxt block = + RPC_context.make_call0 S.seed ctxt block () () + +end + module Nonce = struct type info = diff --git a/src/proto_alpha/lib_protocol/src/alpha_services.mli b/src/proto_alpha/lib_protocol/src/alpha_services.mli index 98dfed37c..bd0849f91 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_services.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_services.mli @@ -9,6 +9,12 @@ open Alpha_context +module Seed : sig + + val get: 'a #RPC_context.simple -> 'a -> Seed.seed shell_tzresult Lwt.t + +end + module Nonce : sig type info =