Client/genesis: option to set the timestamp of the activation block.
This commit is contained in:
parent
ccfdaa6bd0
commit
3b483811f5
@ -25,9 +25,9 @@ let forge_block
|
|||||||
Services.Forge.block block
|
Services.Forge.block block
|
||||||
((net_id, pred, timestamp, fitness), command)
|
((net_id, pred, timestamp, fitness), command)
|
||||||
|
|
||||||
let mine cctxt block command fitness seckey =
|
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 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 ~wait:true signed_blk >>=? fun hash ->
|
||||||
cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () ->
|
cctxt.answer "Injected %a" Block_hash.pp_short hash >>= fun () ->
|
||||||
@ -41,9 +41,14 @@ let handle_error cctxt = function
|
|||||||
cctxt.Client_commands.error "%s" "cannot continue"
|
cctxt.Client_commands.error "%s" "cannot continue"
|
||||||
|
|
||||||
let commands () =
|
let commands () =
|
||||||
|
let timestamp = ref None in
|
||||||
|
let args =
|
||||||
|
[ "-timestamp",
|
||||||
|
Arg.String (fun t -> timestamp := Some (Time.of_notation_exn t)),
|
||||||
|
"Set the timestamp of the block (and initial time of the chain)" ] in
|
||||||
let open Cli_entries in
|
let open Cli_entries in
|
||||||
[
|
[
|
||||||
command ~desc: "Activate a protocol" begin
|
command ~args ~desc: "Activate a protocol" begin
|
||||||
prefixes [ "activate" ; "protocol" ] @@
|
prefixes [ "activate" ; "protocol" ] @@
|
||||||
param ~name:"version" ~desc:"Protocol version (b58check)"
|
param ~name:"version" ~desc:"Protocol version (b58check)"
|
||||||
(fun _ p -> Lwt.return @@ Protocol_hash.of_b58check p) @@
|
(fun _ p -> Lwt.return @@ Protocol_hash.of_b58check p) @@
|
||||||
@ -57,12 +62,14 @@ let commands () =
|
|||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
(fun hash fitness seckey cctxt ->
|
(fun hash fitness seckey cctxt ->
|
||||||
|
let timestamp = !timestamp in
|
||||||
let block = Client_config.block () in
|
let block = Client_config.block () in
|
||||||
let fitness =
|
let fitness =
|
||||||
Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in
|
Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in
|
||||||
mine cctxt block (Activate hash) fitness seckey >>= handle_error cctxt)
|
mine cctxt ?timestamp block (Activate hash) fitness seckey >>=
|
||||||
|
handle_error cctxt)
|
||||||
;
|
;
|
||||||
command ~desc: "Fork a test protocol" begin
|
command ~args ~desc: "Fork a test protocol" begin
|
||||||
prefixes [ "fork" ; "test" ; "protocol" ] @@
|
prefixes [ "fork" ; "test" ; "protocol" ] @@
|
||||||
param ~name:"version" ~desc:"Protocol version (b58check)"
|
param ~name:"version" ~desc:"Protocol version (b58check)"
|
||||||
(fun _ p -> Lwt.return (Protocol_hash.of_b58check p)) @@
|
(fun _ p -> Lwt.return (Protocol_hash.of_b58check p)) @@
|
||||||
@ -77,10 +84,12 @@ let commands () =
|
|||||||
stop
|
stop
|
||||||
end
|
end
|
||||||
(fun hash fitness seckey cctxt ->
|
(fun hash fitness seckey cctxt ->
|
||||||
|
let timestamp = !timestamp in
|
||||||
let block = Client_config.block () in
|
let block = Client_config.block () in
|
||||||
let fitness =
|
let fitness =
|
||||||
Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in
|
Client_embedded_proto_alpha.Fitness_repr.from_int64 fitness in
|
||||||
mine cctxt block (Activate_testnet hash) fitness seckey >>= handle_error cctxt) ;
|
mine cctxt ?timestamp block (Activate_testnet hash) fitness seckey >>=
|
||||||
|
handle_error cctxt) ;
|
||||||
]
|
]
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
val mine:
|
val mine:
|
||||||
Client_commands.context ->
|
Client_commands.context ->
|
||||||
|
?timestamp: Time.t ->
|
||||||
Client_node_rpcs.Blocks.block ->
|
Client_node_rpcs.Blocks.block ->
|
||||||
Data.Command.t ->
|
Data.Command.t ->
|
||||||
Fitness.fitness ->
|
Fitness.fitness ->
|
||||||
|
Loading…
Reference in New Issue
Block a user