Alpha: add rpc to get seed of a cycle of a block

This commit is contained in:
Marco Stronati 2018-05-22 17:10:14 +02:00 committed by Grégoire Henry
parent 125e5ce95f
commit eeb7c6ff5e
3 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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 =

View File

@ -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 =