From 32e40ec19a55cba8347695f30be31679b3c97960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Sat, 21 Apr 2018 15:39:05 +0200 Subject: [PATCH] Alpha/RPC: remove `helpers/minimal_time` --- .../lib_baking/client_baking_forge.ml | 10 +++++--- .../lib_protocol/src/helpers_services.ml | 23 ------------------- .../lib_protocol/src/helpers_services.mli | 7 ------ 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/src/proto_alpha/lib_baking/client_baking_forge.ml b/src/proto_alpha/lib_baking/client_baking_forge.ml index 0fa6b56c9..31171c825 100644 --- a/src/proto_alpha/lib_baking/client_baking_forge.ml +++ b/src/proto_alpha/lib_baking/client_baking_forge.ml @@ -150,9 +150,13 @@ let forge_block cctxt ?(chain = `Main) block begin match priority with | `Set priority -> begin - Alpha_services.Helpers.minimal_time - cctxt (chain, block) ~priority >>=? fun time -> - return (priority, Some time) + Alpha_services.Delegate.Baking_rights.get cctxt + ~all:true ~max_priority:(priority+1) (chain, block) >>=? fun rights -> + let time = + Option.apply + ~f:(fun r -> r.Alpha_services.Delegate.Baking_rights.timestamp) + (List.nth_opt rights priority) in + return (priority, time) end | `Auto (src_pkh, max_priority, free_baking) -> Alpha_services.Helpers.level diff --git a/src/proto_alpha/lib_protocol/src/helpers_services.ml b/src/proto_alpha/lib_protocol/src/helpers_services.ml index 3a05995ac..c191505d8 100644 --- a/src/proto_alpha/lib_protocol/src/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/src/helpers_services.ml @@ -65,22 +65,6 @@ module S = struct (req "last" Raw_level.encoding)) RPC_path.(custom_root / "levels_in_cycle" /: Cycle.arg) - type minimal_timestamp_query = { - priority: int ; - } - let minimal_timestamp_query : minimal_timestamp_query RPC_query.t = - let open RPC_query in - query (fun priority -> { priority }) - |+ field "priority" RPC_arg.int 0 (fun t -> t.priority) - |> seal - - let minimal_timestamp = - RPC_service.get_service - ~description: "Minimal timestamp for the next block." - ~query: minimal_timestamp_query - ~output: (obj1 (req "timestamp" Timestamp.encoding)) - RPC_path.(custom_root / "minimal_timestamp") - let run_code_input_encoding = (obj5 (req "script" Script.expr_encoding) @@ -170,10 +154,6 @@ let () = let last = List.hd levels in return (first.level, last.level) end ; - register0 S.minimal_timestamp begin fun ctxt q () -> - let timestamp = Alpha_context.Timestamp.current ctxt in - Baking.minimal_time ctxt q.priority timestamp - end ; register0 S.run_code begin fun ctxt () (code, storage, parameter, amount, contract) -> Lwt.return (Gas.set_limit ctxt (Constants.hard_gas_limit_per_operation ctxt)) >>=? fun ctxt -> @@ -235,9 +215,6 @@ let level ctxt ?(offset = 0l) block = let levels ctxt block cycle = RPC_context.make_call1 S.levels ctxt block cycle () () -let minimal_time ctxt ?(priority = 0) block = - RPC_context.make_call0 S.minimal_timestamp ctxt block { priority } () - let run_code ctxt block code (storage, input, amount, contract) = RPC_context.make_call0 S.run_code ctxt block () (code, storage, input, amount, contract) diff --git a/src/proto_alpha/lib_protocol/src/helpers_services.mli b/src/proto_alpha/lib_protocol/src/helpers_services.mli index b30fc96b0..f8c46a81b 100644 --- a/src/proto_alpha/lib_protocol/src/helpers_services.mli +++ b/src/proto_alpha/lib_protocol/src/helpers_services.mli @@ -21,13 +21,6 @@ val levels: 'a #RPC_context.simple -> 'a -> Cycle.t -> (Raw_level.t * Raw_level.t) shell_tzresult Lwt.t -val minimal_time: - 'a #RPC_context.simple -> - ?priority:int -> 'a -> Time.t shell_tzresult Lwt.t -(** [minimal_time cctxt ?prio blk] is the minimal acceptable - timestamp for the successor of [blk]. [?priority] defaults to - [0]. *) - val run_code: 'a #RPC_context.simple -> 'a -> Script.expr ->