Client/test: minor code simplification
This commit is contained in:
parent
3b95f77225
commit
4a1da9407e
@ -21,8 +21,10 @@ let rpc_config = ref {
|
||||
logger = RPC_client.null_logger ;
|
||||
}
|
||||
|
||||
let rpc_ctxt =
|
||||
ref (new RPC_client.http_ctxt !rpc_config Media_type.all_media_types)
|
||||
let build_rpc_context config =
|
||||
new RPC_client.http_ctxt config Media_type.all_media_types
|
||||
|
||||
let rpc_ctxt = ref (build_rpc_context !rpc_config)
|
||||
|
||||
(* Context that does not write to alias files *)
|
||||
let no_write_context config block : Client_commands.full_context = object
|
||||
@ -54,8 +56,7 @@ let init ?exe ?(sandbox = "sandbox.json") ?rpc_port () =
|
||||
| None -> ()
|
||||
| Some port ->
|
||||
rpc_config := { !rpc_config with port } ;
|
||||
rpc_ctxt :=
|
||||
new RPC_client.http_ctxt !rpc_config Media_type.all_media_types ;
|
||||
rpc_ctxt := build_rpc_context !rpc_config ;
|
||||
end ;
|
||||
let pid =
|
||||
Node_helpers.fork_node
|
||||
@ -253,10 +254,9 @@ module Protocol = struct
|
||||
return (Tezos_base.Operation.of_bytes_exn signed_bytes)
|
||||
|
||||
let ballot ?(block = `Prevalidation) ~src:({ pk; sk } : Account.t) ~proposal ballot =
|
||||
let rpc = new RPC_client.http_ctxt !rpc_config Media_type.all_media_types in
|
||||
Block_services.info rpc block >>=? fun block_info ->
|
||||
Client_proto_rpcs.Context.next_level rpc block >>=? fun next_level ->
|
||||
Client_proto_rpcs.Helpers.Forge.Delegate.ballot rpc block
|
||||
Block_services.info !rpc_ctxt block >>=? fun block_info ->
|
||||
Client_proto_rpcs.Context.next_level !rpc_ctxt block >>=? fun next_level ->
|
||||
Client_proto_rpcs.Helpers.Forge.Delegate.ballot !rpc_ctxt block
|
||||
~branch:block_info.hash
|
||||
~source:pk
|
||||
~period:next_level.voting_period
|
||||
@ -464,9 +464,8 @@ module Endorse = struct
|
||||
source
|
||||
slot =
|
||||
let block = Block_services.last_baked_block block in
|
||||
let rpc = new RPC_client.http_ctxt !rpc_config Media_type.all_media_types in
|
||||
Block_services.info rpc block >>=? fun { hash ; _ } ->
|
||||
Client_proto_rpcs.Helpers.Forge.Delegate.endorsement rpc
|
||||
Block_services.info !rpc_ctxt block >>=? fun { hash ; _ } ->
|
||||
Client_proto_rpcs.Helpers.Forge.Delegate.endorsement !rpc_ctxt
|
||||
block
|
||||
~branch:hash
|
||||
~source
|
||||
@ -532,12 +531,11 @@ module Endorse = struct
|
||||
let endorsement_rights
|
||||
?(max_priority = 1024)
|
||||
(contract : Account.t) block =
|
||||
let rpc = new RPC_client.http_ctxt !rpc_config Media_type.all_media_types in
|
||||
Client_proto_rpcs.Context.level rpc block >>=? fun level ->
|
||||
Client_proto_rpcs.Context.level !rpc_ctxt block >>=? fun level ->
|
||||
let delegate = contract.pkh in
|
||||
let level = level.level in
|
||||
Client_proto_rpcs.Helpers.Rights.endorsement_rights_for_delegate
|
||||
rpc
|
||||
!rpc_ctxt
|
||||
~max_priority
|
||||
~first_level:level
|
||||
~last_level:level
|
||||
|
Loading…
Reference in New Issue
Block a user