Alpha/Client: add --mempool
to command bake for <delegate>
.
This commit is contained in:
parent
bb82702fd6
commit
2f6896a6f3
@ -400,6 +400,8 @@ module Make(Proto : PROTO)(Next_proto : PROTO) : sig
|
||||
|
||||
module Mempool : sig
|
||||
|
||||
val encoding: Mempool.t Data_encoding.t
|
||||
|
||||
val pending_operations:
|
||||
('a, 'b) RPC_path.t ->
|
||||
([ `GET ], 'a,
|
||||
|
@ -291,11 +291,19 @@ let ops_of_mempool (ops : Alpha_block_services.Mempool.t) =
|
||||
List.rev_map (fun (_, op) -> op) ops.applied
|
||||
)
|
||||
|
||||
let unopt_operations cctxt chain = function
|
||||
let unopt_operations cctxt chain mempool = function
|
||||
| None -> begin
|
||||
match mempool with
|
||||
| None ->
|
||||
Alpha_block_services.Mempool.pending_operations cctxt ~chain () >>=? fun mpool ->
|
||||
let ops = ops_of_mempool mpool in
|
||||
return ops
|
||||
| Some file ->
|
||||
Tezos_stdlib_unix.Lwt_utils_unix.Json.read_file file >>=? fun json ->
|
||||
let mpool = Data_encoding.Json.destruct Alpha_block_services.S.Mempool.encoding json in
|
||||
let ops = ops_of_mempool mpool in
|
||||
return ops
|
||||
end
|
||||
| Some operations ->
|
||||
return operations
|
||||
|
||||
@ -379,11 +387,12 @@ let forge_block cctxt ?(chain = `Main) block
|
||||
?(sort = best_effort)
|
||||
?(fee_threshold = Tez.zero)
|
||||
?timestamp
|
||||
?mempool
|
||||
~priority
|
||||
?seed_nonce_hash ~src_sk () =
|
||||
|
||||
(* making the arguments usable *)
|
||||
unopt_operations cctxt chain operations >>=? fun operations_arg ->
|
||||
unopt_operations cctxt chain mempool operations >>=? fun operations_arg ->
|
||||
decode_priority cctxt chain block priority >>=? fun (priority, minimal_timestamp) ->
|
||||
unopt_timestamp timestamp minimal_timestamp >>=? fun timestamp ->
|
||||
|
||||
|
@ -61,6 +61,7 @@ val forge_block:
|
||||
?sort:bool ->
|
||||
?fee_threshold:Tez.t ->
|
||||
?timestamp:Time.t ->
|
||||
?mempool:string ->
|
||||
priority:[`Set of int | `Auto of (public_key_hash * int option)] ->
|
||||
?seed_nonce_hash:Nonce_hash.t ->
|
||||
src_sk:Client_keys.sk_uri ->
|
||||
|
@ -29,7 +29,7 @@ open Alpha_context
|
||||
let bake_block (cctxt : #Proto_alpha.full)
|
||||
?(chain = `Main) block
|
||||
?fee_threshold
|
||||
?force ?max_priority ?(minimal_timestamp=false)
|
||||
?force ?max_priority ?(minimal_timestamp=false) ?mempool
|
||||
?src_sk ?src_pk delegate =
|
||||
begin
|
||||
match src_sk with
|
||||
@ -59,6 +59,7 @@ let bake_block (cctxt : #Proto_alpha.full)
|
||||
?fee_threshold
|
||||
?force
|
||||
?seed_nonce_hash ~src_sk block
|
||||
?mempool
|
||||
~priority:(`Auto (delegate, max_priority)) () >>=? fun block_hash ->
|
||||
let src_pkh = Signature.Public_key.hash src_pk in
|
||||
Client_baking_forge.State.record cctxt src_pkh level.level >>=? fun () ->
|
||||
|
@ -35,6 +35,7 @@ val bake_block:
|
||||
?force:bool ->
|
||||
?max_priority: int ->
|
||||
?minimal_timestamp: bool ->
|
||||
?mempool: string ->
|
||||
?src_sk:Client_keys.sk_uri ->
|
||||
?src_pk:Signature.public_key ->
|
||||
public_key_hash ->
|
||||
|
@ -37,18 +37,25 @@ let directory_parameter =
|
||||
else
|
||||
return p)
|
||||
|
||||
let mempool_arg =
|
||||
Clic.arg
|
||||
~long:"mempool"
|
||||
~placeholder:"file"
|
||||
~doc:"When used the client will read the mempool in the provided file instead of querying the node through an RPC (useful for debugging only)."
|
||||
string_parameter
|
||||
|
||||
let delegate_commands () =
|
||||
let open Clic in
|
||||
[
|
||||
command ~group ~desc: "Forge and inject block using the delegate rights."
|
||||
(args4 max_priority_arg fee_threshold_arg force_switch minimal_timestamp_switch)
|
||||
(args5 max_priority_arg fee_threshold_arg force_switch minimal_timestamp_switch mempool_arg)
|
||||
(prefixes [ "bake"; "for" ]
|
||||
@@ Client_keys.Public_key_hash.source_param
|
||||
~name:"baker" ~desc: "name of the delegate owning the baking right"
|
||||
@@ stop)
|
||||
(fun (max_priority, fee_threshold, force, minimal_timestamp) delegate cctxt ->
|
||||
(fun (max_priority, fee_threshold, force, minimal_timestamp, mempool) delegate cctxt ->
|
||||
bake_block cctxt cctxt#block
|
||||
?fee_threshold ~force ?max_priority ~minimal_timestamp delegate) ;
|
||||
?fee_threshold ~force ?max_priority ~minimal_timestamp ?mempool delegate) ;
|
||||
command ~group ~desc: "Forge and inject a seed-nonce revelation operation."
|
||||
no_options
|
||||
(prefixes [ "reveal"; "nonce"; "for" ]
|
||||
|
Loading…
Reference in New Issue
Block a user