Shell/RPC: some module renaming/aliasing

This commit is contained in:
Grégoire Henry 2018-04-22 14:40:44 +02:00 committed by Benjamin Canou
parent 2a93a336aa
commit 64c464a73f
36 changed files with 254 additions and 213 deletions

View File

@ -25,7 +25,7 @@ let commands () =
no_options no_options
(prefixes [ "list" ; "protocols" ] stop) (prefixes [ "list" ; "protocols" ] stop)
(fun () (cctxt : #Client_context.full) -> (fun () (cctxt : #Client_context.full) ->
Protocol_services.list cctxt >>=? fun protos -> Shell_services.Protocol.list cctxt >>=? fun protos ->
Lwt_list.iter_s (fun ph -> cctxt#message "%a" Protocol_hash.pp ph) protos >>= fun () -> Lwt_list.iter_s (fun ph -> cctxt#message "%a" Protocol_hash.pp ph) protos >>= fun () ->
return () return ()
); );
@ -39,7 +39,7 @@ let commands () =
Lwt.catch Lwt.catch
(fun () -> (fun () ->
Lwt_utils_unix.Protocol.read_dir dirname >>=? fun (_hash, proto) -> Lwt_utils_unix.Protocol.read_dir dirname >>=? fun (_hash, proto) ->
Injection_services.protocol cctxt proto >>= function Shell_services.Injection.protocol cctxt proto >>= function
| Ok hash -> | Ok hash ->
cctxt#message "Injected protocol %a successfully" Protocol_hash.pp_short hash >>= fun () -> cctxt#message "Injected protocol %a successfully" Protocol_hash.pp_short hash >>= fun () ->
return () return ()
@ -59,7 +59,7 @@ let commands () =
@@ Protocol_hash.param ~name:"protocol hash" ~desc:"" @@ Protocol_hash.param ~name:"protocol hash" ~desc:""
@@ stop) @@ stop)
(fun () ph (cctxt : #Client_context.full) -> (fun () ph (cctxt : #Client_context.full) ->
Protocol_services.contents cctxt ph >>=? fun proto -> Shell_services.Protocol.contents cctxt ph >>=? fun proto ->
Lwt_utils_unix.Protocol.write_dir (Protocol_hash.to_short_b58check ph) ~hash:ph proto >>=? fun () -> Lwt_utils_unix.Protocol.write_dir (Protocol_hash.to_short_b58check ph) ~hash:ph proto >>=? fun () ->
cctxt#message "Extracted protocol %a" Protocol_hash.pp_short ph >>= fun () -> cctxt#message "Extracted protocol %a" Protocol_hash.pp_short ph >>= fun () ->
return () return ()

View File

@ -10,7 +10,7 @@
open Client_config open Client_config
let get_commands_for_version ctxt block protocol = let get_commands_for_version ctxt block protocol =
Block_services.Empty.Metadata.next_protocol_hash ctxt ~block () >>= function Shell_services.Blocks.Metadata.next_protocol_hash ctxt ~block () >>= function
| Ok version -> begin | Ok version -> begin
match protocol with match protocol with
| None -> | None ->

View File

@ -45,8 +45,8 @@ let wait_for_operation_inclusion
assumes that the block predecessor has been processed already. *) assumes that the block predecessor has been processed already. *)
let process block = let process block =
Block_services.Empty.hash ctxt ~chain ~block () >>=? fun hash -> Shell_services.Blocks.hash ctxt ~chain ~block () >>=? fun hash ->
Block_services.Empty.Header.Shell.predecessor Shell_services.Blocks.Header.Shell.predecessor
ctxt ~chain ~block () >>=? fun predecessor -> ctxt ~chain ~block () >>=? fun predecessor ->
match Block_hash.Table.find blocks predecessor with match Block_hash.Table.find blocks predecessor with
| Some n -> | Some n ->
@ -59,7 +59,7 @@ let wait_for_operation_inclusion
end else end else
return true return true
| None -> | None ->
Block_services.Empty.Operation_hash.operation_hashes Shell_services.Blocks.Operation_hash.operation_hashes
ctxt ~chain ~block () >>=? fun operations -> ctxt ~chain ~block () >>=? fun operations ->
let in_block = let in_block =
List.exists List.exists
@ -81,7 +81,7 @@ let wait_for_operation_inclusion
end end
end in end in
Monitor_services.heads ctxt chain >>=? fun (stream, stop) -> Shell_services.Monitor.heads ctxt chain >>=? fun (stream, stop) ->
Lwt_stream.get stream >>= function Lwt_stream.get stream >>= function
| None -> assert false | None -> assert false
| Some head -> | Some head ->

View File

@ -54,7 +54,7 @@ class type wallet = object
end end
class type block = object class type block = object
method block : Block_services.block method block : Shell_services.block
method confirmations : int option method confirmations : int option
end end

View File

@ -34,7 +34,7 @@ class type wallet = object
end end
class type block = object class type block = object
method block : Block_services.block method block : Shell_services.block
method confirmations : int option method confirmations : int option
end end

View File

@ -141,7 +141,7 @@ module Cfg_file = struct
end end
type cli_args = { type cli_args = {
block: Block_services.block ; block: Shell_services.block ;
confirmations: int option ; confirmations: int option ;
protocol: Protocol_hash.t option ; protocol: Protocol_hash.t option ;
print_timings: bool ; print_timings: bool ;

View File

@ -17,7 +17,7 @@ class unix_logger :
Client_context.printer Client_context.printer
class unix_full : class unix_full :
base_dir:string -> base_dir:string ->
block:Block_services.block -> block:Shell_services.block ->
confirmations:int option -> confirmations:int option ->
rpc_config:RPC_client.config -> rpc_config:RPC_client.config ->
Client_context.full Client_context.full

View File

@ -20,7 +20,7 @@ let commands () =
(fun () blocks (cctxt : #Client_context.full) -> (fun () blocks (cctxt : #Client_context.full) ->
iter_s iter_s
(fun block -> (fun block ->
Chain_services.Invalid_blocks.delete cctxt block >>=? fun () -> Shell_services.Invalid_blocks.delete cctxt block >>=? fun () ->
cctxt#message cctxt#message
"Block %a no longer marked invalid." "Block %a no longer marked invalid."
Block_hash.pp block >>= fun () -> Block_hash.pp block >>= fun () ->

View File

@ -26,7 +26,7 @@ let commands () = Clic.[
~desc: "the prefix of the hash to complete" @@ ~desc: "the prefix of the hash to complete" @@
stop) stop)
(fun unique prefix (cctxt : #Client_context.full) -> (fun unique prefix (cctxt : #Client_context.full) ->
Block_services.Empty.Helpers.complete Shell_services.Blocks.Helpers.complete
cctxt ~block:cctxt#block prefix >>=? fun completions -> cctxt ~block:cctxt#block prefix >>=? fun completions ->
match completions with match completions with
| [] -> Pervasives.exit 3 | [] -> Pervasives.exit 3

View File

@ -36,10 +36,10 @@ let commands () =
command ~group ~desc: "show global network status" command ~group ~desc: "show global network status"
no_options no_options
(prefixes ["p2p" ; "stat"] stop) begin fun () (cctxt : #Client_context.full) -> (prefixes ["p2p" ; "stat"] stop) begin fun () (cctxt : #Client_context.full) ->
P2p_services.stat cctxt >>=? fun stat -> Shell_services.P2p.stat cctxt >>=? fun stat ->
P2p_services.Connections.list cctxt >>=? fun conns -> Shell_services.P2p.Connections.list cctxt >>=? fun conns ->
P2p_services.Peers.list cctxt >>=? fun peers -> Shell_services.P2p.Peers.list cctxt >>=? fun peers ->
P2p_services.Points.list cctxt >>=? fun points -> Shell_services.P2p.Points.list cctxt >>=? fun points ->
cctxt#message "GLOBAL STATS" >>= fun () -> cctxt#message "GLOBAL STATS" >>= fun () ->
cctxt#message " %a" P2p_stat.pp stat >>= fun () -> cctxt#message " %a" P2p_stat.pp stat >>= fun () ->
cctxt#message "CONNECTIONS" >>= fun () -> cctxt#message "CONNECTIONS" >>= fun () ->

View File

@ -13,7 +13,7 @@ let skip_line ppf =
Format.pp_print_newline ppf (); Format.pp_print_newline ppf ();
return @@ Format.pp_print_newline ppf () return @@ Format.pp_print_newline ppf ()
let print_invalid_blocks ppf (b: Chain_services.invalid_block) = let print_invalid_blocks ppf (b: Shell_services.Chain.invalid_block) =
Format.fprintf ppf Format.fprintf ppf
"@[<v 2>Hash: %a\ "@[<v 2>Hash: %a\
@ Level: %ld\ @ Level: %ld\
@ -45,7 +45,7 @@ let commands () =
(args1 output_arg) (args1 output_arg)
(fixed [ "list" ; "heads" ]) (fixed [ "list" ; "heads" ])
(fun ppf cctxt -> (fun ppf cctxt ->
Chain_services.Blocks.list cctxt () >>=? fun heads -> Shell_services.Blocks.list cctxt () >>=? fun heads ->
Format.fprintf ppf "@[<v>%a@]@." Format.fprintf ppf "@[<v>%a@]@."
(Format.pp_print_list Block_hash.pp) (Format.pp_print_list Block_hash.pp)
(List.concat heads) ; (List.concat heads) ;
@ -54,7 +54,7 @@ let commands () =
(args1 output_arg) (args1 output_arg)
(fixed [ "list" ; "rejected" ; "blocks" ]) (fixed [ "list" ; "rejected" ; "blocks" ])
(fun ppf cctxt -> (fun ppf cctxt ->
Chain_services.Invalid_blocks.list cctxt () >>=? function Shell_services.Invalid_blocks.list cctxt () >>=? function
| [] -> | [] ->
Format.fprintf ppf "No invalid blocks." ; Format.fprintf ppf "No invalid blocks." ;
return () return ()

View File

@ -252,6 +252,10 @@ let rpc_directory
(* helpers *) (* helpers *)
register0 Shell_services.Blocks.S.Helpers.Forge.block_header begin fun _block () header ->
return (Data_encoding.Binary.to_bytes_exn Block_header.encoding header)
end ;
register0 S.Helpers.Preapply.block begin fun block q p -> register0 S.Helpers.Preapply.block begin fun block q p ->
let timestamp = let timestamp =
match q#timestamp with match q#timestamp with

View File

@ -141,7 +141,6 @@ let build_rpc_directory node =
merge (Protocol_directory.build_rpc_directory node.state) ; merge (Protocol_directory.build_rpc_directory node.state) ;
merge (Monitor_directory.build_rpc_directory merge (Monitor_directory.build_rpc_directory
node.validator node.mainchain_validator) ; node.validator node.mainchain_validator) ;
merge Shell_directory.rpc_directory ;
merge (Injection_directory.build_rpc_directory node.validator) ; merge (Injection_directory.build_rpc_directory node.validator) ;
merge (Chain_directory.build_rpc_directory node.validator) ; merge (Chain_directory.build_rpc_directory node.validator) ;
merge (P2p.build_rpc_directory node.p2p) ; merge (P2p.build_rpc_directory node.p2p) ;

View File

@ -1,20 +0,0 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let rpc_directory =
let dir : unit RPC_directory.t ref = ref RPC_directory.empty in
let register0 s f =
dir := RPC_directory.register !dir s (fun () p q -> f p q) in
register0 Shell_services.S.forge_block_header begin fun () header ->
return (Data_encoding.Binary.to_bytes_exn Block_header.encoding header)
end ;
!dir

View File

@ -1,10 +0,0 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
val rpc_directory: unit RPC_directory.t

View File

@ -9,6 +9,34 @@
open Data_encoding open Data_encoding
type chain = [
| `Main
| `Test
| `Hash of Chain_id.t
]
let parse_chain s =
try
match s with
| "main" -> Ok `Main
| "test" -> Ok `Test
| h -> Ok (`Hash (Chain_id.of_b58check_exn h))
with _ -> Error "Cannot parse block identifier."
let chain_to_string = function
| `Main -> "main"
| `Test -> "test"
| `Hash h -> Chain_id.to_b58check h
let chain_arg =
let name = "chain_id" in
let descr =
"A chain identifier. This is either a chain hash in Base58Check notation \
or a one the predefined aliases: 'main', 'test'." in
let construct = chain_to_string in
let destruct = parse_chain in
RPC_arg.make ~name ~descr ~construct ~destruct ()
type block = [ type block = [
| `Genesis | `Genesis
| `Head of int | `Head of int
@ -44,8 +72,12 @@ let blocks_arg =
let destruct = parse_block in let destruct = parse_block in
RPC_arg.make ~name ~descr ~construct ~destruct () RPC_arg.make ~name ~descr ~construct ~destruct ()
type prefix = (unit * Chain_services.chain) * block type chain_prefix = unit * chain
let path = RPC_path.(Chain_services.S.Blocks.path /: blocks_arg) type prefix = chain_prefix * block
let chain_path = RPC_path.(root / "chains" /: chain_arg)
let dir_path : (chain_prefix, chain_prefix) RPC_path.t =
RPC_path.(open_root / "blocks")
let path = RPC_path.(dir_path /: blocks_arg)
type operation_list_quota = { type operation_list_quota = {
max_size: int ; max_size: int ;
@ -524,6 +556,18 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
let path = RPC_path.(path / "context" / "helpers") let path = RPC_path.(path / "context" / "helpers")
module Forge = struct
let block_header =
RPC_service.post_service
~description: "Forge a block header"
~query: RPC_query.empty
~input: Block_header.encoding
~output: (obj1 (req "block" bytes))
RPC_path.(path / "forge_block_header")
end
module Preapply = struct module Preapply = struct
let path = RPC_path.(path / "preapply") let path = RPC_path.(path / "preapply")
@ -645,7 +689,7 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
end end
let path = RPC_path.prefix Chain_services.path path let path = RPC_path.prefix chain_path path
let make_call0 s ctxt a b q p = let make_call0 s ctxt a b q p =
let s = RPC_service.prefix path s in let s = RPC_service.prefix path s in
@ -846,6 +890,19 @@ module Make(Proto : PROTO)(Next_proto : PROTO) = struct
module S = S.Helpers module S = S.Helpers
module Forge = struct
module S = S.Forge
let block_header ctxt =
let f = make_call0 S.block_header ctxt in
fun
?(chain = `Main) ?(block = `Head 0)
header ->
f chain block () header
end
module Preapply = struct module Preapply = struct
module S = S.Preapply module S = S.Preapply

View File

@ -7,7 +7,19 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Chain_services type chain = [
| `Main
| `Test
| `Hash of Chain_id.t
]
type chain_prefix = unit * chain
val chain_path: (unit, chain_prefix) RPC_path.t
val parse_chain: string -> (chain, string) result
val chain_to_string: chain -> string
val chain_arg: chain RPC_arg.t
type block = [ type block = [
| `Genesis | `Genesis
@ -17,8 +29,9 @@ type block = [
val parse_block: string -> (block, string) result val parse_block: string -> (block, string) result
val to_string: block -> string val to_string: block -> string
type prefix = (unit * Chain_services.chain) * block type prefix = (unit * chain) * block
val path: (Chain_services.prefix, Chain_services.prefix * block) RPC_path.t val dir_path: (chain_prefix, chain_prefix) RPC_path.t
val path: (chain_prefix, chain_prefix * block) RPC_path.t
type operation_list_quota = { type operation_list_quota = {
max_size: int ; max_size: int ;
@ -55,7 +68,7 @@ end
module Make(Proto : PROTO)(Next_proto : PROTO) : sig module Make(Proto : PROTO)(Next_proto : PROTO) : sig
val path: (unit, Chain_services.prefix * block) RPC_path.t val path: (unit, chain_prefix * block) RPC_path.t
type raw_block_header = { type raw_block_header = {
shell: Block_header.shell_header ; shell: Block_header.shell_header ;
@ -222,6 +235,17 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
module Helpers : sig module Helpers : sig
module Forge : sig
val block_header:
#RPC_context.simple ->
?chain:chain ->
?block:block ->
Block_header.t ->
MBytes.t tzresult Lwt.t
end
module Preapply : sig module Preapply : sig
val block: val block:
@ -422,6 +446,14 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
module Helpers : sig module Helpers : sig
module Forge : sig
val block_header:
([ `POST ], prefix,
prefix, unit, Block_header.t, MBytes.t) RPC_service.service
end
module Preapply : sig module Preapply : sig
type block_param = { type block_param = {

View File

@ -15,30 +15,9 @@ type chain = [
| `Hash of Chain_id.t | `Hash of Chain_id.t
] ]
let parse_chain s = let chain_arg = Block_services.chain_arg
try let to_string = Block_services.chain_to_string
match s with let parse_chain = Block_services.parse_chain
| "main" -> Ok `Main
| "test" -> Ok `Test
| h -> Ok (`Hash (Chain_id.of_b58check_exn h))
with _ -> Error "Cannot parse block identifier."
let to_string = function
| `Main -> "main"
| `Test -> "test"
| `Hash h -> Chain_id.to_b58check h
let chain_arg =
let name = "chain_id" in
let descr =
"A chain identifier. This is either a chain hash in Base58Check notation \
or a one the predefined aliases: 'main', 'test'." in
let construct = to_string in
let destruct = parse_chain in
RPC_arg.make ~name ~descr ~construct ~destruct ()
type prefix = unit * chain
let path = RPC_path.(root / "chains" /: chain_arg)
type invalid_block = { type invalid_block = {
hash: Block_hash.t ; hash: Block_hash.t ;
@ -46,6 +25,9 @@ type invalid_block = {
errors: error list ; errors: error list ;
} }
type prefix = Block_services.chain_prefix
let path = Block_services.chain_path
let invalid_block_encoding = let invalid_block_encoding =
conv conv
(fun { hash ; level ; errors } -> (hash, level, errors)) (fun { hash ; level ; errors } -> (hash, level, errors))
@ -206,6 +188,8 @@ module Blocks = struct
end) end)
() ()
include Block_services.Empty
end end
module Invalid_blocks = struct module Invalid_blocks = struct

View File

@ -54,6 +54,8 @@ module Blocks : sig
?min_date:Time.t -> ?min_date:Time.t ->
unit -> Block_hash.t list list tzresult Lwt.t unit -> Block_hash.t list list tzresult Lwt.t
include (module type of Block_services.Empty)
end end
module Invalid_blocks : sig module Invalid_blocks : sig

View File

@ -7,21 +7,18 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
module S = struct type chain = Chain_services.chain
type block = Block_services.block
open Data_encoding module Chain = Chain_services
module Blocks = Chain.Blocks
module Invalid_blocks = Chain.Invalid_blocks
module Mempool = Chain.Mempool
let forge_block_header = module Protocol = Protocol_services
RPC_service.post_service
~description: "Forge a block header"
~query: RPC_query.empty
~input: Block_header.encoding
~output: (obj1 (req "block" bytes))
RPC_path.(root / "forge_block_header")
end module Monitor = Monitor_services
module Injection = Injection_services
open RPC_context module P2p = P2p_services
module Worker = Worker_services
let forge_block_header ctxt header =
make_call S.forge_block_header ctxt () () header

View File

@ -7,18 +7,18 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open RPC_context type chain = Chain_services.chain
type block = Block_services.block
val forge_block_header: module Chain = Chain_services
#simple -> module Blocks = Chain.Blocks
Block_header.t -> module Invalid_blocks = Chain.Invalid_blocks
MBytes.t tzresult Lwt.t module Mempool = Chain.Mempool
module S : sig module Protocol = Protocol_services
val forge_block_header: module Monitor = Monitor_services
([ `POST ], unit, module Injection = Injection_services
unit, unit, Block_header.t,
MBytes.t) RPC_service.t
end module P2p = P2p_services
module Worker = Worker_services

View File

@ -22,20 +22,20 @@ type block_info = {
} }
let info cctxt ?(chain = `Main) block = let info cctxt ?(chain = `Main) block =
Chain_services.chain_id cctxt ~chain () >>=? fun chain_id -> Shell_services.Chain.chain_id cctxt ~chain () >>=? fun chain_id ->
Block_services.hash cctxt ~chain ~block () >>=? fun hash -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun hash ->
Block_services.Header.shell_header cctxt ~chain ~block () >>=? fun header -> Shell_services.Blocks.Header.shell_header cctxt ~chain ~block () >>=? fun header ->
Block_services.Metadata.next_protocol_hash Shell_services.Blocks.Metadata.next_protocol_hash
cctxt ~chain ~block () >>=? fun next_protocol -> cctxt ~chain ~block () >>=? fun next_protocol ->
Block_services.Metadata.protocol_hash Shell_services.Blocks.Metadata.protocol_hash
cctxt ~chain ~block () >>=? fun protocol -> cctxt ~chain ~block () >>=? fun protocol ->
Block_services.Metadata.protocol_data cctxt ~chain ~block () >>=? fun { level } -> Alpha_block_services.Metadata.protocol_data cctxt ~chain ~block () >>=? fun { level } ->
let { Tezos_base.Block_header.predecessor ; fitness ; timestamp ; _ } = header in let { Tezos_base.Block_header.predecessor ; fitness ; timestamp ; _ } = header in
return { hash ; chain_id ; predecessor ; fitness ; return { hash ; chain_id ; predecessor ; fitness ;
timestamp ; protocol ; next_protocol ; level } timestamp ; protocol ; next_protocol ; level }
let monitor_valid_blocks cctxt ?chains ?protocols ?next_protocols () = let monitor_valid_blocks cctxt ?chains ?protocols ?next_protocols () =
Monitor_services.valid_blocks cctxt Shell_services.Monitor.valid_blocks cctxt
?chains ?protocols ?next_protocols () >>=? fun (block_stream, _stop) -> ?chains ?protocols ?next_protocols () >>=? fun (block_stream, _stop) ->
return (Lwt_stream.map_s return (Lwt_stream.map_s
(fun (chain, block) -> (fun (chain, block) ->
@ -49,11 +49,11 @@ let monitor_heads cctxt ?next_protocols chain =
block_stream) block_stream)
let blocks_from_cycle cctxt ?(chain = `Main) block cycle = let blocks_from_cycle cctxt ?(chain = `Main) block cycle =
Block_services.hash cctxt ~chain ~block () >>=? fun hash -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun hash ->
Block_services.Metadata.protocol_data cctxt ~chain ~block () >>=? fun { level } -> Alpha_block_services.Metadata.protocol_data cctxt ~chain ~block () >>=? fun { level } ->
Alpha_services.Helpers.levels cctxt (chain, block) cycle >>=? fun (first, last) -> Alpha_services.Helpers.levels cctxt (chain, block) cycle >>=? fun (first, last) ->
let length = Int32.to_int (Raw_level.diff level.level first) in let length = Int32.to_int (Raw_level.diff level.level first) in
Chain_services.Blocks.list cctxt ~heads:[hash] ~length () >>=? fun blocks -> Shell_services.Blocks.list cctxt ~heads:[hash] ~length () >>=? fun blocks ->
let blocks = let blocks =
List.remove List.remove
(length - (Int32.to_int (Raw_level.diff last first))) (length - (Int32.to_int (Raw_level.diff last first)))

View File

@ -95,7 +95,7 @@ let inject_endorsement
(cctxt : #Proto_alpha.full) (cctxt : #Proto_alpha.full)
?(chain = `Main) block level ?async ?(chain = `Main) block level ?async
src_sk slots = src_sk slots =
Block_services.hash cctxt ~chain ~block () >>=? fun hash -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun hash ->
Alpha_services.Forge.Consensus.endorsement cctxt Alpha_services.Forge.Consensus.endorsement cctxt
(chain, block) (chain, block)
~branch:hash ~branch:hash
@ -105,7 +105,7 @@ let inject_endorsement
() >>=? fun bytes -> () >>=? fun bytes ->
Client_keys.append Client_keys.append
src_sk ~watermark:Endorsement bytes >>=? fun signed_bytes -> src_sk ~watermark:Endorsement bytes >>=? fun signed_bytes ->
Injection_services.operation cctxt ?async ~chain signed_bytes >>=? fun oph -> Shell_services.Injection.operation cctxt ?async ~chain signed_bytes >>=? fun oph ->
iter_s iter_s
(fun slot -> (fun slot ->
State.record_endorsement cctxt level hash slot oph) State.record_endorsement cctxt level hash slot oph)
@ -130,7 +130,7 @@ let forge_endorsement (cctxt : #Proto_alpha.full)
?(chain = `Main) block ?(chain = `Main) block
~src_sk ?slots src_pk = ~src_sk ?slots src_pk =
let src_pkh = Signature.Public_key.hash src_pk in let src_pkh = Signature.Public_key.hash src_pk in
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
cctxt ~chain ~block () >>=? fun { level = { level } } -> cctxt ~chain ~block () >>=? fun { level = { level } } ->
begin begin
match slots with match slots with

View File

@ -71,7 +71,7 @@ let inject_block cctxt
let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in let block = `Hash (shell_header.Tezos_base.Block_header.predecessor, 0) in
forge_block_header cctxt ~chain block forge_block_header cctxt ~chain block
src_sk shell_header priority seed_nonce_hash >>=? fun signed_header -> src_sk shell_header priority seed_nonce_hash >>=? fun signed_header ->
Injection_services.block cctxt Shell_services.Injection.block cctxt
?force ~chain signed_header operations >>=? fun block_hash -> ?force ~chain signed_header operations >>=? fun block_hash ->
return block_hash return block_hash
@ -133,7 +133,7 @@ let forge_block cctxt ?(chain = `Main) block
begin begin
match operations with match operations with
| None -> | None ->
Chain_services.Mempool.pending_operations Shell_services.Mempool.pending_operations
cctxt ~chain () >>=? fun (ops, pendings) -> cctxt ~chain () >>=? fun (ops, pendings) ->
let ops = let ops =
List.map parse @@ List.map parse @@
@ -198,7 +198,7 @@ let forge_block cctxt ?(chain = `Main) block
let request = List.length operations in let request = List.length operations in
let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash in let protocol_data = forge_faked_protocol_data ~priority ~seed_nonce_hash in
let operations = classify_operations operations in let operations = classify_operations operations in
Block_services.Helpers.Preapply.block Alpha_block_services.Helpers.Preapply.block
cctxt ~block ~timestamp ~sort ~protocol_data operations >>=? cctxt ~block ~timestamp ~sort ~protocol_data operations >>=?
fun (shell_header, result) -> fun (shell_header, result) ->
let valid = let valid =
@ -403,7 +403,7 @@ let get_unrevealed_nonces
Client_baking_nonces.find cctxt hash >>=? function Client_baking_nonces.find cctxt hash >>=? function
| None -> return None | None -> return None
| Some nonce -> | Some nonce ->
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
cctxt ~chain ~block:(`Hash (hash, 0)) () >>=? fun { level } -> cctxt ~chain ~block:(`Hash (hash, 0)) () >>=? fun { level } ->
if force then if force then
return (Some (hash, (level.level, nonce))) return (Some (hash, (level.level, nonce)))
@ -501,7 +501,7 @@ let bake (cctxt : #Proto_alpha.full) state =
lwt_debug "Try baking after %a (slot %d) for %s (%a)" lwt_debug "Try baking after %a (slot %d) for %s (%a)"
Block_hash.pp_short bi.hash Block_hash.pp_short bi.hash
priority name Time.pp_hum timestamp >>= fun () -> priority name Time.pp_hum timestamp >>= fun () ->
Chain_services.Mempool.pending_operations Shell_services.Mempool.pending_operations
cctxt ~chain () >>=? fun (res, ops) -> cctxt ~chain () >>=? fun (res, ops) ->
let operations = let operations =
List.map parse @@ List.map parse @@
@ -518,7 +518,7 @@ let bake (cctxt : #Proto_alpha.full) state =
let protocol_data = let protocol_data =
forge_faked_protocol_data ~priority ~seed_nonce_hash in forge_faked_protocol_data ~priority ~seed_nonce_hash in
let operations = classify_operations operations in let operations = classify_operations operations in
Block_services.Helpers.Preapply.block Alpha_block_services.Helpers.Preapply.block
cctxt ~chain ~block cctxt ~chain ~block
~timestamp ~sort:true ~protocol_data operations >>= function ~timestamp ~sort:true ~protocol_data operations >>= function
| Error errs -> | Error errs ->
@ -602,7 +602,7 @@ let create
| None | Some (Error _) -> | None | Some (Error _) ->
cctxt#error "Can't fetch the current block head." cctxt#error "Can't fetch the current block head."
| Some (Ok bi) -> | Some (Ok bi) ->
Block_services.hash cctxt ~block:`Genesis () >>=? fun genesis_hash -> Shell_services.Blocks.hash cctxt ~block:`Genesis () >>=? fun genesis_hash ->
let last_get_block = ref None in let last_get_block = ref None in
let get_block () = let get_block () =
match !last_get_block with match !last_get_block with

View File

@ -15,17 +15,17 @@ let inject_seed_nonce_revelation rpc_config ?(chain = `Main) block ?async nonces
List.map List.map
(fun (level, nonce) -> (fun (level, nonce) ->
Seed_nonce_revelation { level ; nonce }) nonces in Seed_nonce_revelation { level ; nonce }) nonces in
Block_services.hash rpc_config ~chain ~block () >>=? fun branch -> Alpha_block_services.hash rpc_config ~chain ~block () >>=? fun branch ->
Alpha_services.Forge.Anonymous.operations rpc_config Alpha_services.Forge.Anonymous.operations rpc_config
(chain, block) ~branch operations >>=? fun bytes -> (chain, block) ~branch operations >>=? fun bytes ->
Injection_services.operation rpc_config ?async ~chain bytes >>=? fun oph -> Shell_services.Injection.operation rpc_config ?async ~chain bytes >>=? fun oph ->
return oph return oph
let forge_seed_nonce_revelation let forge_seed_nonce_revelation
(cctxt: #Proto_alpha.full) (cctxt: #Proto_alpha.full)
?(chain = `Main) ?(chain = `Main)
block nonces = block nonces =
Block_services.hash cctxt ~chain ~block () >>=? fun hash -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun hash ->
match nonces with match nonces with
| [] -> | [] ->
cctxt#message "No nonce to reveal for block %a" cctxt#message "No nonce to reveal for block %a"

View File

@ -147,11 +147,12 @@ let init ?exe ?vote ?rpc_port () =
return (pid, hash) return (pid, hash)
let level (chain, block) = let level (chain, block) =
Block_services.Metadata.protocol_data !rpc_ctxt ~chain ~block () >>=? fun { level } -> Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain ~block () >>=? fun { level } ->
return level return level
let rpc_raw_context block path depth = let rpc_raw_context block path depth =
Block_services.Context.Raw.read !rpc_ctxt ~block ~depth path Shell_services.Blocks.Context.Raw.read !rpc_ctxt ~block ~depth path
module Account = struct module Account = struct
@ -336,12 +337,12 @@ module Protocol = struct
open Account open Account
let voting_period_kind ?(block = `Head 0) () = let voting_period_kind ?(block = `Head 0) () =
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { voting_period_kind } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { voting_period_kind } ->
return voting_period_kind return voting_period_kind
let proposals ?(block = `Head 0) ~src:({ pkh; sk } : Account.t) proposals = let proposals ?(block = `Head 0) ~src:({ pkh; sk } : Account.t) proposals =
Block_services.hash !rpc_ctxt ~block () >>=? fun hash -> Shell_services.Blocks.hash !rpc_ctxt ~block () >>=? fun hash ->
Alpha_services.Helpers.level Alpha_services.Helpers.level
!rpc_ctxt ~offset:1l (`Main, block) >>=? fun next_level -> !rpc_ctxt ~offset:1l (`Main, block) >>=? fun next_level ->
let shell = { Tezos_base.Operation.branch = hash } in let shell = { Tezos_base.Operation.branch = hash } in
@ -353,7 +354,7 @@ module Protocol = struct
sign ~watermark:Generic_operation sk shell contents sign ~watermark:Generic_operation sk shell contents
let ballot ?(block = `Head 0) ~src:({ pkh; sk } : Account.t) ~proposal ballot = let ballot ?(block = `Head 0) ~src:({ pkh; sk } : Account.t) ~proposal ballot =
Block_services.hash !rpc_ctxt ~block () >>=? fun hash -> Shell_services.Blocks.hash !rpc_ctxt ~block () >>=? fun hash ->
Alpha_services.Helpers.level Alpha_services.Helpers.level
!rpc_ctxt ~offset:1l (`Main, block) >>=? fun next_level -> !rpc_ctxt ~offset:1l (`Main, block) >>=? fun next_level ->
let shell = { Tezos_base.Operation.branch = hash } in let shell = { Tezos_base.Operation.branch = hash } in
@ -489,7 +490,7 @@ module Assert = struct
end end
let check_protocol ?msg ~block h = let check_protocol ?msg ~block h =
Block_services.Metadata.next_protocol_hash Alpha_block_services.Metadata.next_protocol_hash
!rpc_ctxt ~block () >>=? fun block_proto -> !rpc_ctxt ~block () >>=? fun block_proto ->
return @@ equal return @@ equal
?msg ?msg
@ -498,7 +499,7 @@ module Assert = struct
block_proto h block_proto h
let check_voting_period_kind ?msg ~block kind = let check_voting_period_kind ?msg ~block kind =
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { voting_period_kind } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { voting_period_kind } ->
return @@ equal return @@ equal
?msg ?msg
@ -516,7 +517,8 @@ module Baking = struct
let bake block (contract: Account.t) operations = let bake block (contract: Account.t) operations =
let ctxt = (new wrap_full (no_write_context ~block !rpc_config)) in let ctxt = (new wrap_full (no_write_context ~block !rpc_config)) in
Alpha_services.Helpers.level ctxt ~offset:1l (`Main, block) >>=? fun level -> Alpha_services.Helpers.level
ctxt ~offset:1l (`Main, block) >>=? fun level ->
let seed_nonce_hash = let seed_nonce_hash =
if level.Level.expected_commitment then if level.Level.expected_commitment then
let seed_nonce = let seed_nonce =
@ -549,8 +551,8 @@ module Endorse = struct
block block
src_sk src_sk
slot = slot =
Block_services.hash !rpc_ctxt ~block () >>=? fun hash -> Shell_services.Blocks.hash !rpc_ctxt ~block () >>=? fun hash ->
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
let level = level.level in let level = level.level in
let shell = { Tezos_base.Operation.branch = hash } in let shell = { Tezos_base.Operation.branch = hash } in
@ -573,7 +575,7 @@ module Endorse = struct
?slot ?slot
(contract : Account.t) (contract : Account.t)
block = block =
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
let level = level.level in let level = level.level in
begin begin
@ -602,7 +604,7 @@ module Endorse = struct
| _ -> () in | _ -> () in
let { Account.b1 ; b2 ; b3 ; b4 ; b5 } = Account.bootstrap_accounts in let { Account.b1 ; b2 ; b3 ; b4 ; b5 } = Account.bootstrap_accounts in
let result = Array.make 32 b1 in let result = Array.make 32 b1 in
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
let level = level.level in let level = level.level in
get_endorser_list result b1 level block >>=? fun () -> get_endorser_list result b1 level block >>=? fun () ->
@ -614,7 +616,7 @@ module Endorse = struct
let endorsement_rights let endorsement_rights
(contract : Account.t) block = (contract : Account.t) block =
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
let level = level.level in let level = level.level in
let delegate = contract.pkh in let delegate = contract.pkh in
@ -629,7 +631,7 @@ module Endorse = struct
end end
let display_level block = let display_level block =
Block_services.Metadata.protocol_data Alpha_block_services.Metadata.protocol_data
!rpc_ctxt ~chain:`Main ~block () >>=? fun { level } -> !rpc_ctxt ~chain:`Main ~block () >>=? fun { level } ->
Format.eprintf "Level: %a@." Level.pp_full level ; Format.eprintf "Level: %a@." Level.pp_full level ;
return () return ()

View File

@ -12,36 +12,36 @@ open Alpha_context
val list_contract_labels: val list_contract_labels:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
(string * string * string) list tzresult Lwt.t (string * string * string) list tzresult Lwt.t
val get_storage: val get_storage:
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
Contract.t -> Contract.t ->
Script.expr option tzresult Lwt.t Script.expr option tzresult Lwt.t
val get_manager: val get_manager:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
Contract.t -> Contract.t ->
(string * public_key_hash * (string * public_key_hash *
public_key * Client_keys.sk_uri) tzresult Lwt.t public_key * Client_keys.sk_uri) tzresult Lwt.t
val get_balance: val get_balance:
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
Contract.t -> Contract.t ->
Tez.t tzresult Lwt.t Tez.t tzresult Lwt.t
val set_delegate: val set_delegate:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
fee:Tez.tez -> fee:Tez.tez ->
Contract.t -> Contract.t ->
@ -52,8 +52,8 @@ val set_delegate:
val register_as_delegate: val register_as_delegate:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
fee:Tez.tez -> fee:Tez.tez ->
manager_sk:Client_keys.sk_uri -> manager_sk:Client_keys.sk_uri ->
@ -62,15 +62,15 @@ val register_as_delegate:
val source_to_keys: val source_to_keys:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
Contract.t -> Contract.t ->
(public_key * Client_keys.sk_uri) tzresult Lwt.t (public_key * Client_keys.sk_uri) tzresult Lwt.t
val originate_account : val originate_account :
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
?branch:int -> ?branch:int ->
source:Contract.t -> source:Contract.t ->
@ -92,8 +92,8 @@ val save_contract :
val originate_contract: val originate_contract:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
?branch:int -> ?branch:int ->
fee:Tez.t -> fee:Tez.t ->
@ -113,8 +113,8 @@ val originate_contract:
val transfer : val transfer :
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
?branch:int -> ?branch:int ->
source:Contract.t -> source:Contract.t ->
@ -131,8 +131,8 @@ val transfer :
val reveal : val reveal :
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
?branch:int -> ?branch:int ->
source:Contract.t -> source:Contract.t ->
@ -143,8 +143,8 @@ val reveal :
val dictate : val dictate :
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
dictator_operation -> dictator_operation ->
Client_keys.sk_uri -> Client_keys.sk_uri ->
@ -163,8 +163,8 @@ val activation_key_encoding: activation_key Data_encoding.t
val claim_commitment: val claim_commitment:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
?encrypted:bool -> ?encrypted:bool ->
?force:bool -> ?force:bool ->

View File

@ -43,15 +43,15 @@ val list_contracts:
val get_manager: val get_manager:
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
Contract.t -> Contract.t ->
public_key_hash tzresult Lwt.t public_key_hash tzresult Lwt.t
val get_delegate: val get_delegate:
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
Contract.t -> Contract.t ->
public_key_hash option tzresult Lwt.t public_key_hash option tzresult Lwt.t

View File

@ -16,8 +16,8 @@ module Program : Client_aliases.Alias
val run : val run :
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
?chain:Chain_services.chain -> ?chain:Shell_services.chain ->
Block_services.block -> Shell_services.block ->
?contract:Contract.t -> ?contract:Contract.t ->
?amount:Tez.t -> ?amount:Tez.t ->
program:Michelson_v1_parser.parsed -> program:Michelson_v1_parser.parsed ->
@ -30,8 +30,8 @@ val run :
val trace : val trace :
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
?chain:Chain_services.chain -> ?chain:Shell_services.chain ->
Block_services.block -> Shell_services.block ->
?contract:Contract.t -> ?contract:Contract.t ->
?amount:Tez.t -> ?amount:Tez.t ->
program:Michelson_v1_parser.parsed -> program:Michelson_v1_parser.parsed ->
@ -63,8 +63,8 @@ val print_trace_result :
val hash_and_sign : val hash_and_sign :
#Proto_alpha.full -> #Proto_alpha.full ->
?chain:Chain_services.chain -> ?chain:Shell_services.chain ->
Block_services.block -> Shell_services.block ->
?gas:Z.t -> ?gas:Z.t ->
Michelson_v1_parser.parsed -> Michelson_v1_parser.parsed ->
Michelson_v1_parser.parsed -> Michelson_v1_parser.parsed ->
@ -73,8 +73,8 @@ val hash_and_sign :
val typecheck_data : val typecheck_data :
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
?chain:Chain_services.chain -> ?chain:Shell_services.chain ->
Block_services.block -> Shell_services.block ->
?gas:Z.t -> ?gas:Z.t ->
data:Michelson_v1_parser.parsed -> data:Michelson_v1_parser.parsed ->
ty:Michelson_v1_parser.parsed -> ty:Michelson_v1_parser.parsed ->
@ -83,8 +83,8 @@ val typecheck_data :
val typecheck_program : val typecheck_program :
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
?chain:Chain_services.chain -> ?chain:Shell_services.chain ->
Block_services.block -> Shell_services.block ->
?gas:Z.t -> ?gas:Z.t ->
Michelson_v1_parser.parsed -> Michelson_v1_parser.parsed ->
(Script_tc_errors.type_map * Gas.t) tzresult Lwt.t (Script_tc_errors.type_map * Gas.t) tzresult Lwt.t

View File

@ -20,7 +20,7 @@ let get_branch (rpc_config: #Proto_alpha.full)
| `Hash (h,n) -> return (`Hash (h,n+branch)) | `Hash (h,n) -> return (`Hash (h,n+branch))
| `Genesis -> return `Genesis | `Genesis -> return `Genesis
end >>=? fun block -> end >>=? fun block ->
Block_services.hash rpc_config ~chain ~block () >>=? fun hash -> Shell_services.Blocks.hash rpc_config ~chain ~block () >>=? fun hash ->
return hash return hash
type result = Operation_hash.t * operation * operation_result type result = Operation_hash.t * operation * operation_result
@ -51,8 +51,8 @@ let preapply
{ shell = { branch } ; { shell = { branch } ;
protocol_data = { contents ; signature } } in protocol_data = { contents ; signature } } in
let oph = Operation.hash op in let oph = Operation.hash op in
Block_services.Helpers.Preapply.operations cctxt ~chain ~block Alpha_block_services.Helpers.Preapply.operations
[op] >>=? function cctxt ~chain ~block [op] >>=? function
| [result] -> return (oph, op, result) | [result] -> return (oph, op, result)
| _ -> failwith "Unexpected result" | _ -> failwith "Unexpected result"
@ -176,7 +176,7 @@ let inject_operation
Lwt.return res Lwt.return res
end >>=? fun () -> end >>=? fun () ->
let bytes = Data_encoding.Binary.to_bytes_exn Operation.encoding op in let bytes = Data_encoding.Binary.to_bytes_exn Operation.encoding op in
Injection_services.operation cctxt ~chain bytes >>=? fun oph -> Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph ->
cctxt#message "Operation successfully injected in the node." >>= fun () -> cctxt#message "Operation successfully injected in the node." >>= fun () ->
cctxt#message "Operation hash is '%a'." Operation_hash.pp oph >>= fun () -> cctxt#message "Operation hash is '%a'." Operation_hash.pp oph >>= fun () ->
begin begin
@ -185,7 +185,7 @@ let inject_operation
| Some confirmations -> | Some confirmations ->
cctxt#message "Waiting for the operation to be included..." >>= fun () -> cctxt#message "Waiting for the operation to be included..." >>= fun () ->
Client_confirmations.wait_for_operation_inclusion Client_confirmations.wait_for_operation_inclusion
~confirmations cctxt ~chain oph >>=? fun () -> ~confirmations cctxt ~chain oph >>=? fun _ ->
return () return ()
end >>=? fun () -> end >>=? fun () ->
cctxt#message cctxt#message

View File

@ -15,8 +15,8 @@ type result = Operation_hash.t * operation * operation_result
val preapply: val preapply:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?branch:int -> ?branch:int ->
?src_sk:Client_keys.sk_uri -> ?src_sk:Client_keys.sk_uri ->
Operation.contents -> Operation.contents ->
@ -24,8 +24,8 @@ val preapply:
val inject_operation: val inject_operation:
#Proto_alpha.full -> #Proto_alpha.full ->
chain:Chain_services.chain -> chain:Shell_services.chain ->
block:Block_services.block -> block:Shell_services.block ->
?confirmations:int -> ?confirmations:int ->
?branch:int -> ?branch:int ->
?src_sk:Client_keys.sk_uri -> ?src_sk:Client_keys.sk_uri ->

View File

@ -10,15 +10,12 @@
module Name = struct let name = "alpha" end module Name = struct let name = "alpha" end
module Alpha_environment = Tezos_protocol_environment_faked.MakeV1(Name)() module Alpha_environment = Tezos_protocol_environment_faked.MakeV1(Name)()
module Proto = Tezos_protocol_alpha.Functor.Make(Alpha_environment) module Proto = Tezos_protocol_alpha.Functor.Make(Alpha_environment)
module Block_services = struct module Alpha_block_services = Block_services.Make(Proto)(Proto)
include Block_services
include Block_services.Make(Proto)(Proto)
end
include Proto include Proto
class type rpc_context = object class type rpc_context = object
inherit RPC_context.json inherit RPC_context.json
inherit [Chain_services.chain * Block_services.block] Alpha_environment.RPC_context.simple inherit [Shell_services.chain * Shell_services.block] Alpha_environment.RPC_context.simple
end end
class wrap_proto_context (t : RPC_context.json) : rpc_context = object class wrap_proto_context (t : RPC_context.json) : rpc_context = object
@ -32,20 +29,20 @@ class wrap_proto_context (t : RPC_context.json) : rpc_context = object
on_chunk: ('o -> unit) -> on_chunk: ('o -> unit) ->
on_close: (unit -> unit) -> on_close: (unit -> unit) ->
'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t = t#call_streamed_service 'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t = t#call_streamed_service
inherit [Chain_services.chain, inherit [Shell_services.chain,
Block_services.block] Alpha_environment.proto_rpc_context Shell_services.block] Alpha_environment.proto_rpc_context
(t :> RPC_context.t) (t :> RPC_context.t)
Block_services.path Shell_services.Blocks.path
end end
class type full = object class type full = object
inherit Client_context.full inherit Client_context.full
inherit [Chain_services.chain * Block_services.block] Alpha_environment.RPC_context.simple inherit [Shell_services.chain * Shell_services.block] Alpha_environment.RPC_context.simple
end end
class wrap_full (t : Client_context.full) : full = object class wrap_full (t : Client_context.full) : full = object
inherit Client_context.proxy_context t inherit Client_context.proxy_context t
inherit [Chain_services.chain, Block_services.block] Alpha_environment.proto_rpc_context inherit [Shell_services.chain, Shell_services.block] Alpha_environment.proto_rpc_context
(t :> RPC_context.t) (t :> RPC_context.t)
Block_services.path Shell_services.Blocks.path
end end

View File

@ -56,7 +56,7 @@ let commands () =
(switch ~doc:"output time in seconds" ~short:'s' ~long:"seconds" ())) (switch ~doc:"output time in seconds" ~short:'s' ~long:"seconds" ()))
(fixed [ "get" ; "timestamp" ]) (fixed [ "get" ; "timestamp" ])
begin fun seconds (cctxt : Proto_alpha.full) -> begin fun seconds (cctxt : Proto_alpha.full) ->
Block_services.Header.Shell.timestamp Shell_services.Blocks.Header.Shell.timestamp
cctxt ~block:cctxt#block () >>=? fun v -> cctxt ~block:cctxt#block () >>=? fun v ->
begin begin
if seconds if seconds

View File

@ -15,12 +15,12 @@ let protocol =
let bake cctxt ?(timestamp = Time.now ()) block command sk = let bake cctxt ?(timestamp = Time.now ()) block command sk =
let protocol_data = { command ; signature = Signature.zero } in let protocol_data = { command ; signature = Signature.zero } in
Block_services.Helpers.Preapply.block Genesis_block_services.Helpers.Preapply.block
cctxt ~block ~timestamp ~protocol_data cctxt ~block ~timestamp ~protocol_data
[] >>=? fun (shell_header, _) -> [] >>=? fun (shell_header, _) ->
let blk = Data.Command.forge shell_header command in let blk = Data.Command.forge shell_header command in
Client_keys.append sk blk >>=? fun signed_blk -> Client_keys.append sk blk >>=? fun signed_blk ->
Injection_services.block cctxt signed_blk [] Shell_services.Injection.block cctxt signed_blk []
let int64_parameter = let int64_parameter =
(Clic.parameter (fun _ p -> (Clic.parameter (fun _ p ->

View File

@ -12,7 +12,7 @@ open Proto_genesis
val bake: val bake:
#Client_context.full -> #Client_context.full ->
?timestamp: Time.t -> ?timestamp: Time.t ->
Block_services.block -> Shell_services.block ->
Data.Command.t -> Data.Command.t ->
Client_keys.sk_uri -> Client_keys.sk_uri ->
Block_hash.t tzresult Lwt.t Block_hash.t tzresult Lwt.t

View File

@ -10,8 +10,5 @@
module Name = struct let name = "genesis" end module Name = struct let name = "genesis" end
module Genesis_environment = Tezos_protocol_environment_faked.MakeV1(Name)() module Genesis_environment = Tezos_protocol_environment_faked.MakeV1(Name)()
module Proto = Tezos_protocol_genesis.Functor.Make(Genesis_environment) module Proto = Tezos_protocol_genesis.Functor.Make(Genesis_environment)
module Block_services = struct module Genesis_block_services = Block_services.Make(Proto)(Proto)
include Block_services
include Block_services.Make(Proto)(Proto)
end
include Proto include Proto