alpha-baker: Rename client_baking -> delegate
This commit is contained in:
parent
5a3492ea8b
commit
9d4be9caba
@ -11,6 +11,6 @@ let select_commands _ _ =
|
||||
return
|
||||
(List.map
|
||||
(Clic.map_command (new Proto_alpha.wrap_full))
|
||||
(Client_baking_commands.commands ()))
|
||||
(Delegate_commands.commands ()))
|
||||
|
||||
let () = Client_main_run.run select_commands
|
||||
|
@ -1,53 +0,0 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2018. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
let run (cctxt : #Proto_alpha.full) ?max_priority ~delay delegates ~endorsement ~denunciation ~baking =
|
||||
begin
|
||||
match delegates with
|
||||
| [] ->
|
||||
Tezos_signer_backends.Encrypted.decrypt_all cctxt
|
||||
| _ :: _ ->
|
||||
iter_s
|
||||
(fun k ->
|
||||
Client_keys.get_key cctxt k >>=? fun (_, _, sk_uri) ->
|
||||
Client_keys.neuterize sk_uri >>=? fun _ ->
|
||||
return ())
|
||||
delegates
|
||||
end >>=? fun () ->
|
||||
(* TODO really detach... *)
|
||||
let endorsement =
|
||||
if endorsement then
|
||||
Client_baking_blocks.monitor_heads cctxt `Main >>=? fun block_stream ->
|
||||
Client_baking_endorsement.create cctxt ~delay delegates block_stream >>= fun () ->
|
||||
return ()
|
||||
else
|
||||
return ()
|
||||
in
|
||||
let denunciation =
|
||||
if denunciation then
|
||||
Client_baking_operations.monitor_endorsement
|
||||
cctxt >>=? fun endorsement_stream ->
|
||||
Client_baking_denunciation.create cctxt endorsement_stream >>= fun () ->
|
||||
return ()
|
||||
else
|
||||
return ()
|
||||
in
|
||||
let forge =
|
||||
if baking then begin
|
||||
Client_baking_blocks.monitor_heads
|
||||
cctxt `Main >>=? fun block_stream ->
|
||||
Client_baking_forge.create cctxt
|
||||
?max_priority delegates block_stream >>=? fun () ->
|
||||
return ()
|
||||
end else
|
||||
return ()
|
||||
in
|
||||
denunciation >>=? fun () ->
|
||||
endorsement >>=? fun () ->
|
||||
forge
|
@ -98,13 +98,35 @@ let reveal_block_nonces (cctxt : #Proto_alpha.full) block_hashes =
|
||||
do_reveal cctxt cctxt#block blocks
|
||||
|
||||
let reveal_nonces cctxt () =
|
||||
let block = Block_services.last_baked_block cctxt#block in
|
||||
Client_baking_forge.get_unrevealed_nonces
|
||||
cctxt cctxt#block >>=? fun nonces ->
|
||||
do_reveal cctxt cctxt#block nonces
|
||||
|
||||
let run_daemon cctxt ?max_priority ~endorsement_delay delegates ~endorsement ~baking ~denunciation =
|
||||
Client_baking_daemon.run cctxt
|
||||
?max_priority
|
||||
let endorser =
|
||||
if endorsement then
|
||||
Client_daemon.Endorser.run cctxt
|
||||
~delay:endorsement_delay
|
||||
~endorsement ~baking ~denunciation
|
||||
delegates
|
||||
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
|
||||
(List.map snd delegates) >>=? fun () -> return ()
|
||||
else return ()
|
||||
in
|
||||
let baker =
|
||||
if baking then
|
||||
Client_daemon.Baker.run cctxt
|
||||
?max_priority
|
||||
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
|
||||
(List.map snd delegates) >>=? fun () -> return ()
|
||||
else return ()
|
||||
in
|
||||
let accuser =
|
||||
if denunciation then
|
||||
Client_daemon.Accuser.run cctxt >>=? fun () -> return ()
|
||||
else
|
||||
return ()
|
||||
in
|
||||
endorser >>=? fun () ->
|
||||
baker >>=? fun () ->
|
||||
accuser >>=? fun () ->
|
||||
return ()
|
||||
|
41
src/proto_alpha/lib_baking/client_daemon.ml
Normal file
41
src/proto_alpha/lib_baking/client_daemon.ml
Normal file
@ -0,0 +1,41 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2018. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
module Endorser = struct
|
||||
|
||||
let run (cctxt : #Proto_alpha.full) ~delay ?min_date delegates =
|
||||
Client_baking_blocks.monitor
|
||||
cctxt ?min_date ~min_heads:1 () >>=? fun block_stream ->
|
||||
Client_baking_endorsement.create cctxt ~delay delegates block_stream >>= fun () ->
|
||||
return ()
|
||||
|
||||
end
|
||||
|
||||
module Accuser = struct
|
||||
|
||||
let run (cctxt : #Proto_alpha.full) =
|
||||
Client_baking_operations.monitor_endorsement
|
||||
cctxt >>=? fun endorsement_stream ->
|
||||
Client_baking_denunciation.create cctxt endorsement_stream >>= fun () ->
|
||||
return ()
|
||||
|
||||
end
|
||||
|
||||
module Baker = struct
|
||||
|
||||
let run (cctxt : #Proto_alpha.full) ?max_priority ?min_date delegates =
|
||||
Client_baking_blocks.monitor
|
||||
cctxt ?min_date ~min_heads:1 () >>=? fun block_stream ->
|
||||
Client_baking_operations.monitor_endorsement
|
||||
cctxt >>=? fun endorsement_stream ->
|
||||
Client_baking_forge.create cctxt
|
||||
?max_priority delegates block_stream endorsement_stream >>=? fun () ->
|
||||
return ()
|
||||
|
||||
end
|
@ -10,11 +10,23 @@
|
||||
open Proto_alpha
|
||||
open Alpha_context
|
||||
|
||||
module Endorser : sig
|
||||
val run:
|
||||
#Proto_alpha.full ->
|
||||
delay: int ->
|
||||
?min_date: Time.t ->
|
||||
public_key_hash list -> unit tzresult Lwt.t
|
||||
end
|
||||
|
||||
module Baker : sig
|
||||
val run:
|
||||
#Proto_alpha.full ->
|
||||
?max_priority: int ->
|
||||
delay: int ->
|
||||
public_key_hash list ->
|
||||
endorsement:bool ->
|
||||
denunciation:bool ->
|
||||
baking:bool -> unit tzresult Lwt.t
|
||||
?min_date: Time.t ->
|
||||
public_key_hash list -> unit tzresult Lwt.t
|
||||
end
|
||||
|
||||
module Accuser : sig
|
||||
val run:
|
||||
#Proto_alpha.full -> unit tzresult Lwt.t
|
||||
end
|
@ -11,7 +11,7 @@ open Client_proto_args
|
||||
open Client_baking_lib
|
||||
|
||||
let group =
|
||||
{ Clic.name = "delegate" ;
|
||||
{ Cli_entries.name = "delegate" ;
|
||||
title = "Commands related to delegate operations." }
|
||||
|
||||
let commands () =
|
||||
@ -21,14 +21,31 @@ let commands () =
|
||||
(args5 max_priority_arg endorsement_delay_arg
|
||||
Daemon.baking_switch Daemon.endorsement_switch Daemon.denunciation_switch)
|
||||
(prefixes [ "launch" ; "daemon" ]
|
||||
@@ seq_of_param Client_keys.Public_key_hash.source_param)
|
||||
(fun (max_priority, endorsement_delay, baking, endorsement, denunciation) delegates cctxt ->
|
||||
let (endorsement, baking, denunciation) =
|
||||
if (not endorsement) && (not baking) && (not denunciation)
|
||||
then (true, true, true)
|
||||
else (endorsement, baking, denunciation) in
|
||||
iter_s (fun d -> Client_keys.get_key cctxt d >>|? fun _ -> ()) delegates >>=? fun () ->
|
||||
run_daemon cctxt ?max_priority ~endorsement_delay ~endorsement ~baking ~denunciation delegates) ;
|
||||
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
|
||||
(fun max_priority delegates cctxt ->
|
||||
Client_daemon.Baker.run cctxt
|
||||
?max_priority
|
||||
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
|
||||
(List.map snd delegates)
|
||||
) ;
|
||||
|
||||
command ~group ~desc: "Launch the accuser daemon"
|
||||
no_options
|
||||
(prefixes [ "launch" ; "accuser" ]
|
||||
@@ stop)
|
||||
(fun () cctxt -> Client_daemon.Accuser.run cctxt) ;
|
||||
|
||||
command ~group ~desc: "Launch the endorser daemon"
|
||||
(args1 endorsement_delay_arg )
|
||||
(prefixes [ "launch" ; "endorser" ]
|
||||
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
|
||||
(fun endorsement_delay delegates cctxt ->
|
||||
Client_daemon.Endorser.run cctxt
|
||||
~delay:endorsement_delay
|
||||
~min_date:((Time.add (Time.now ()) (Int64.neg 1800L)))
|
||||
(List.map snd delegates)
|
||||
) ;
|
||||
|
||||
command ~group ~desc: "Forge and inject an endorsement operation."
|
||||
no_options
|
||||
(prefixes [ "endorse"; "for" ]
|
@ -10,4 +10,4 @@
|
||||
let () =
|
||||
Client_commands.register Proto_alpha.hash @@
|
||||
List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@
|
||||
Client_baking_commands.commands ()
|
||||
Delegate_commands.commands ()
|
@ -12,7 +12,9 @@
|
||||
tezos-client-commands
|
||||
tezos-rpc))
|
||||
(library_flags (:standard -linkall))
|
||||
(modules (:standard \ client_baking_commands client_baking_commands_registration))
|
||||
(modules (:standard \
|
||||
delegate_commands
|
||||
delegate_commands_registration))
|
||||
(flags (:standard -w -9+27-30-32-40@8
|
||||
-safe-string
|
||||
-open Tezos_base__TzPervasives
|
||||
@ -34,7 +36,7 @@
|
||||
tezos-client-commands
|
||||
tezos-baking-alpha))
|
||||
(library_flags (:standard -linkall))
|
||||
(modules (client_baking_commands))
|
||||
(modules (delegate_commands))
|
||||
(flags (:standard -w -9+27-30-32-40@8
|
||||
-safe-string
|
||||
-open Tezos_base__TzPervasives
|
||||
@ -59,7 +61,7 @@
|
||||
tezos-baking-alpha-commands
|
||||
tezos-rpc))
|
||||
(library_flags (:standard -linkall))
|
||||
(modules (client_baking_commands_registration))
|
||||
(modules (delegate_commands_registration))
|
||||
(flags (:standard -w -9+27-30-32-40@8
|
||||
-safe-string
|
||||
-open Tezos_base__TzPervasives
|
||||
|
Loading…
Reference in New Issue
Block a user