Client/RPC: rename wait into async

This commit is contained in:
Grégoire Henry 2017-03-30 13:08:33 +02:00
parent e273cfa07f
commit 618fb64129
9 changed files with 25 additions and 26 deletions

View File

@ -135,12 +135,12 @@ let forge_block cctxt ?net ?predecessor ?timestamp fitness ops header =
(net, predecessor, timestamp, fitness, ops, header) (net, predecessor, timestamp, fitness, ops, header)
let validate_block cctxt net block = let validate_block cctxt net block =
call_service0 cctxt Services.validate_block (net, block) call_service0 cctxt Services.validate_block (net, block)
let inject_block cctxt ?(wait = true) ?force block = let inject_block cctxt ?(async = false) ?force block =
call_service0 cctxt Services.inject_block (block, wait, force) call_service0 cctxt Services.inject_block (block, not async, force)
let inject_operation cctxt ?(wait = true) ?force operation = let inject_operation cctxt ?(async = false) ?force operation =
call_service0 cctxt Services.inject_operation (operation, wait, force) call_service0 cctxt Services.inject_operation (operation, not async, force)
let inject_protocol cctxt ?(wait = true) ?force protocol = let inject_protocol cctxt ?(async = false) ?force protocol =
call_service0 cctxt Services.inject_protocol (protocol, wait, force) call_service0 cctxt Services.inject_protocol (protocol, not async, force)
let bootstrapped cctxt = let bootstrapped cctxt =
call_streamed_service0 cctxt Services.bootstrapped () call_streamed_service0 cctxt Services.bootstrapped ()
let complete cctxt ?block prefix = let complete cctxt ?block prefix =

View File

@ -33,24 +33,24 @@ val validate_block:
val inject_block: val inject_block:
Client_commands.context -> Client_commands.context ->
?wait:bool -> ?force:bool -> ?async:bool -> ?force:bool ->
MBytes.t -> MBytes.t ->
Block_hash.t tzresult Lwt.t Block_hash.t tzresult Lwt.t
(** [inject_block cctxt ?wait ?force raw_block] tries to inject (** [inject_block cctxt ?async ?force raw_block] tries to inject
[raw_block] inside the node. If [?wait] is [true], [raw_block] [raw_block] inside the node. If [?async] is [true], [raw_block]
will be validated before the result is returned. If [?force] is will be validated before the result is returned. If [?force] is
true, the block will be injected even on non strictly increasing true, the block will be injected even on non strictly increasing
fitness. *) fitness. *)
val inject_operation: val inject_operation:
Client_commands.context -> Client_commands.context ->
?wait:bool -> ?force:bool -> ?async:bool -> ?force:bool ->
MBytes.t -> MBytes.t ->
Operation_hash.t tzresult Lwt.t Operation_hash.t tzresult Lwt.t
val inject_protocol: val inject_protocol:
Client_commands.context -> Client_commands.context ->
?wait:bool -> ?force:bool -> ?async:bool -> ?force:bool ->
Tezos_compiler.Protocol.t -> Tezos_compiler.Protocol.t ->
Protocol_hash.t tzresult Lwt.t Protocol_hash.t tzresult Lwt.t

View File

@ -116,7 +116,7 @@ let get_signing_slots cctxt ?max_priority block delegate level =
return slots return slots
let inject_endorsement cctxt let inject_endorsement cctxt
block level ?wait ?force block level ?async ?force
src_sk source slot = src_sk source slot =
Client_blocks.get_block_hash cctxt block >>= fun block_hash -> Client_blocks.get_block_hash cctxt block >>= fun block_hash ->
Client_node_rpcs.Blocks.net cctxt block >>= fun net -> Client_node_rpcs.Blocks.net cctxt block >>= fun net ->
@ -129,7 +129,7 @@ let inject_endorsement cctxt
() >>=? fun bytes -> () >>=? fun bytes ->
let signed_bytes = Ed25519.Signature.append src_sk bytes in let signed_bytes = Ed25519.Signature.append src_sk bytes in
Client_node_rpcs.inject_operation Client_node_rpcs.inject_operation
cctxt ?force ?wait signed_bytes >>=? fun oph -> cctxt ?force ?async signed_bytes >>=? fun oph ->
State.record_endorsement cctxt level block_hash slot oph >>=? fun () -> State.record_endorsement cctxt level block_hash slot oph >>=? fun () ->
return oph return oph
@ -173,7 +173,7 @@ let forge_endorsement cctxt
else check_endorsement cctxt level slot else check_endorsement cctxt level slot
end >>=? fun () -> end >>=? fun () ->
inject_endorsement cctxt inject_endorsement cctxt
block level ~wait:true ~force block level ~force
src_sk src_pk slot src_sk src_pk slot
@ -316,7 +316,7 @@ let endorse cctxt state =
lwt_debug "Endorsing %a for %s (slot %d)!" lwt_debug "Endorsing %a for %s (slot %d)!"
Block_hash.pp_short hash name slot >>= fun () -> Block_hash.pp_short hash name slot >>= fun () ->
inject_endorsement cctxt inject_endorsement cctxt
b level ~wait:false ~force:true b level ~async:true ~force:true
sk pk slot >>=? fun oph -> sk pk slot >>=? fun oph ->
cctxt.message cctxt.message
"Injected endorsement for block '%a' \ "Injected endorsement for block '%a' \

View File

@ -65,7 +65,7 @@ let inject_block cctxt block
() >>=? fun unsigned_header -> () >>=? fun unsigned_header ->
let signed_header = Ed25519.Signature.append src_sk unsigned_header in let signed_header = Ed25519.Signature.append src_sk unsigned_header in
Client_node_rpcs.inject_block cctxt Client_node_rpcs.inject_block cctxt
~wait:true ?force signed_header >>=? fun block_hash -> ?force signed_header >>=? fun block_hash ->
return block_hash return block_hash
let forge_block cctxt block let forge_block cctxt block

View File

@ -11,7 +11,7 @@ open Cli_entries
open Tezos_context open Tezos_context
open Logging.Client.Revelation open Logging.Client.Revelation
let inject_seed_nonce_revelation cctxt block ?force ?wait nonces = let inject_seed_nonce_revelation cctxt block ?force ?async nonces =
let operations = let operations =
List.map List.map
(fun (level, nonce) -> (fun (level, nonce) ->
@ -19,7 +19,7 @@ let inject_seed_nonce_revelation cctxt block ?force ?wait nonces =
Client_node_rpcs.Blocks.net cctxt block >>= fun net -> Client_node_rpcs.Blocks.net cctxt block >>= fun net ->
Client_proto_rpcs.Helpers.Forge.Anonymous.operations cctxt Client_proto_rpcs.Helpers.Forge.Anonymous.operations cctxt
block ~net operations >>=? fun bytes -> block ~net operations >>=? fun bytes ->
Client_node_rpcs.inject_operation cctxt ?force ?wait bytes >>=? fun oph -> Client_node_rpcs.inject_operation cctxt ?force ?async bytes >>=? fun oph ->
return oph return oph
type Error_monad.error += Bad_revelation type Error_monad.error += Bad_revelation
@ -34,8 +34,7 @@ let forge_seed_nonce_revelation
Block_hash.pp_short hash >>= fun () -> Block_hash.pp_short hash >>= fun () ->
return () return ()
| _ -> | _ ->
inject_seed_nonce_revelation cctxt inject_seed_nonce_revelation cctxt block ~force nonces >>=? fun oph ->
block ~force ~wait:true nonces >>=? fun oph ->
cctxt.answer cctxt.answer
"Operation successfully injected %d revelation(s) for %a." "Operation successfully injected %d revelation(s) for %a."
(List.length nonces) (List.length nonces)

View File

@ -11,7 +11,7 @@ val inject_seed_nonce_revelation:
Client_commands.context -> Client_commands.context ->
Client_proto_rpcs.block -> Client_proto_rpcs.block ->
?force:bool -> ?force:bool ->
?wait:bool -> ?async:bool ->
(Raw_level.t * Nonce.t) list -> (Raw_level.t * Nonce.t) list ->
Operation_hash.t tzresult Lwt.t Operation_hash.t tzresult Lwt.t

View File

@ -104,7 +104,7 @@ let transfer cctxt
let oph = Operation_hash.hash_bytes [ signed_bytes ] in let oph = Operation_hash.hash_bytes [ signed_bytes ] in
Client_proto_rpcs.Helpers.apply_operation cctxt block Client_proto_rpcs.Helpers.apply_operation cctxt block
predecessor oph bytes (Some signature) >>=? fun contracts -> predecessor oph bytes (Some signature) >>=? fun contracts ->
Client_node_rpcs.inject_operation cctxt ?force ~wait:true signed_bytes >>=? fun injected_oph -> Client_node_rpcs.inject_operation cctxt ?force signed_bytes >>=? fun injected_oph ->
assert (Operation_hash.equal oph injected_oph) ; assert (Operation_hash.equal oph injected_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 () ->
@ -121,7 +121,7 @@ let originate cctxt ?force ~block ?signature bytes =
Client_proto_rpcs.Helpers.apply_operation cctxt block Client_proto_rpcs.Helpers.apply_operation cctxt block
predecessor oph bytes signature >>=? function predecessor oph bytes signature >>=? function
| [ contract ] -> | [ contract ] ->
Client_node_rpcs.inject_operation cctxt ?force ~wait:true signed_bytes >>=? fun injected_oph -> Client_node_rpcs.inject_operation cctxt ?force signed_bytes >>=? fun injected_oph ->
assert (Operation_hash.equal oph injected_oph) ; assert (Operation_hash.equal oph injected_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 () ->
@ -176,7 +176,7 @@ let dictate cctxt block command seckey =
let signature = Ed25519.sign seckey bytes in let signature = Ed25519.sign seckey bytes in
let signed_bytes = MBytes.concat bytes signature in let signed_bytes = MBytes.concat bytes signature in
let oph = Operation_hash.hash_bytes [ signed_bytes ] in let oph = Operation_hash.hash_bytes [ signed_bytes ] in
Client_node_rpcs.inject_operation cctxt ~wait:true signed_bytes >>=? fun injected_oph -> Client_node_rpcs.inject_operation cctxt signed_bytes >>=? fun injected_oph ->
assert (Operation_hash.equal oph injected_oph) ; assert (Operation_hash.equal oph injected_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 () ->

View File

@ -53,7 +53,7 @@ let mine cctxt =
Client_node_rpcs.forge_block cctxt Client_node_rpcs.forge_block cctxt
~net:bi.net ~predecessor:bi.hash ~net:bi.net ~predecessor:bi.hash
fitness [] (MBytes.create 0) >>= fun bytes -> fitness [] (MBytes.create 0) >>= fun bytes ->
Client_node_rpcs.inject_block cctxt ~wait:true bytes >>=? fun hash -> Client_node_rpcs.inject_block cctxt bytes >>=? fun hash ->
cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () -> cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () ->
return () return ()

View File

@ -29,7 +29,7 @@ let mine cctxt ?timestamp block command fitness seckey =
Client_blocks.get_block_info cctxt block >>= fun bi -> Client_blocks.get_block_info cctxt block >>= fun bi ->
forge_block cctxt ?timestamp block bi.net command fitness >>= fun blk -> forge_block cctxt ?timestamp block bi.net command fitness >>= fun blk ->
let signed_blk = Environment.Ed25519.Signature.append seckey blk in let signed_blk = Environment.Ed25519.Signature.append seckey blk in
Client_node_rpcs.inject_block cctxt ~wait:true signed_blk >>=? fun hash -> Client_node_rpcs.inject_block cctxt signed_blk >>=? fun hash ->
cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () -> cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () ->
return () return ()