Alpha: add rpc to get seed of a cycle of a block
This commit is contained in:
parent
125e5ce95f
commit
eeb7c6ff5e
@ -473,14 +473,21 @@ end
|
|||||||
|
|
||||||
module Seed : sig
|
module Seed : sig
|
||||||
|
|
||||||
|
type seed
|
||||||
|
|
||||||
type error +=
|
type error +=
|
||||||
| Unknown of { oldest : Cycle.t ;
|
| Unknown of { oldest : Cycle.t ;
|
||||||
cycle : Cycle.t ;
|
cycle : Cycle.t ;
|
||||||
latest : Cycle.t }
|
latest : Cycle.t }
|
||||||
|
|
||||||
|
val for_cycle:
|
||||||
|
context -> Cycle.t -> seed tzresult Lwt.t
|
||||||
|
|
||||||
val cycle_end:
|
val cycle_end:
|
||||||
context -> Cycle.t -> (context * Nonce.unrevealed list) tzresult Lwt.t
|
context -> Cycle.t -> (context * Nonce.unrevealed list) tzresult Lwt.t
|
||||||
|
|
||||||
|
val seed_encoding : seed Data_encoding.t
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Contract : sig
|
module Contract : sig
|
||||||
|
@ -11,6 +11,35 @@ open Alpha_context
|
|||||||
|
|
||||||
let custom_root = RPC_path.open_root
|
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
|
module Nonce = struct
|
||||||
|
|
||||||
type info =
|
type info =
|
||||||
|
@ -9,6 +9,12 @@
|
|||||||
|
|
||||||
open Alpha_context
|
open Alpha_context
|
||||||
|
|
||||||
|
module Seed : sig
|
||||||
|
|
||||||
|
val get: 'a #RPC_context.simple -> 'a -> Seed.seed shell_tzresult Lwt.t
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
module Nonce : sig
|
module Nonce : sig
|
||||||
|
|
||||||
type info =
|
type info =
|
||||||
|
Loading…
Reference in New Issue
Block a user