Alpha/RPC: remove helpers/minimal_time

This commit is contained in:
Grégoire Henry 2018-04-21 15:39:05 +02:00 committed by Benjamin Canou
parent 0a78bbe33b
commit 32e40ec19a
3 changed files with 7 additions and 33 deletions

View File

@ -150,9 +150,13 @@ let forge_block cctxt ?(chain = `Main) block
begin begin
match priority with match priority with
| `Set priority -> begin | `Set priority -> begin
Alpha_services.Helpers.minimal_time Alpha_services.Delegate.Baking_rights.get cctxt
cctxt (chain, block) ~priority >>=? fun time -> ~all:true ~max_priority:(priority+1) (chain, block) >>=? fun rights ->
return (priority, Some time) let time =
Option.apply
~f:(fun r -> r.Alpha_services.Delegate.Baking_rights.timestamp)
(List.nth_opt rights priority) in
return (priority, time)
end end
| `Auto (src_pkh, max_priority, free_baking) -> | `Auto (src_pkh, max_priority, free_baking) ->
Alpha_services.Helpers.level Alpha_services.Helpers.level

View File

@ -65,22 +65,6 @@ module S = struct
(req "last" Raw_level.encoding)) (req "last" Raw_level.encoding))
RPC_path.(custom_root / "levels_in_cycle" /: Cycle.arg) 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 = let run_code_input_encoding =
(obj5 (obj5
(req "script" Script.expr_encoding) (req "script" Script.expr_encoding)
@ -170,10 +154,6 @@ let () =
let last = List.hd levels in let last = List.hd levels in
return (first.level, last.level) return (first.level, last.level)
end ; 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 () register0 S.run_code begin fun ctxt ()
(code, storage, parameter, amount, contract) -> (code, storage, parameter, amount, contract) ->
Lwt.return (Gas.set_limit ctxt (Constants.hard_gas_limit_per_operation ctxt)) >>=? fun ctxt -> 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 = let levels ctxt block cycle =
RPC_context.make_call1 S.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) = let run_code ctxt block code (storage, input, amount, contract) =
RPC_context.make_call0 S.run_code ctxt RPC_context.make_call0 S.run_code ctxt
block () (code, storage, input, amount, contract) block () (code, storage, input, amount, contract)

View File

@ -21,13 +21,6 @@ val levels:
'a #RPC_context.simple -> 'a #RPC_context.simple ->
'a -> Cycle.t -> (Raw_level.t * Raw_level.t) shell_tzresult Lwt.t '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: val run_code:
'a #RPC_context.simple -> 'a #RPC_context.simple ->
'a -> Script.expr -> 'a -> Script.expr ->