2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2017-04-05 01:35:41 +04:00
|
|
|
open Client_commands
|
2016-09-08 21:13:10 +04:00
|
|
|
open Logging.Client.Mining
|
|
|
|
|
2016-12-03 16:05:02 +04:00
|
|
|
let run cctxt ?max_priority ~delay ?min_date delegates =
|
2016-09-08 21:13:10 +04:00
|
|
|
(* TODO really detach... *)
|
|
|
|
let endorsement =
|
|
|
|
if Client_proto_args.Daemon.(!all || !endorsement) then
|
2017-02-15 20:20:10 +04:00
|
|
|
Client_mining_blocks.monitor
|
2017-04-05 01:35:41 +04:00
|
|
|
cctxt.rpc_config ?min_date ~min_heads:1 () >>=? fun block_stream ->
|
|
|
|
Client_mining_endorsement.create cctxt ~delay delegates block_stream >>= fun () ->
|
|
|
|
return ()
|
2016-09-08 21:13:10 +04:00
|
|
|
else
|
2017-04-05 01:35:41 +04:00
|
|
|
return ()
|
2016-09-08 21:13:10 +04:00
|
|
|
in
|
|
|
|
let denunciation =
|
|
|
|
if Client_proto_args.Daemon.(!all || !denunciation) then
|
2017-02-15 20:20:10 +04:00
|
|
|
Client_mining_operations.monitor_endorsement
|
2017-04-05 01:35:41 +04:00
|
|
|
cctxt.rpc_config >>=? fun endorsement_stream ->
|
|
|
|
Client_mining_denunciation.create cctxt endorsement_stream >>= fun () ->
|
|
|
|
return ()
|
2016-09-08 21:13:10 +04:00
|
|
|
else
|
2017-04-05 01:35:41 +04:00
|
|
|
return ()
|
2016-09-08 21:13:10 +04:00
|
|
|
in
|
|
|
|
let forge =
|
2017-03-09 17:35:43 +04:00
|
|
|
if Client_proto_args.Daemon.(!all || !mining) then begin
|
|
|
|
Client_mining_blocks.monitor
|
2017-04-05 01:35:41 +04:00
|
|
|
cctxt.rpc_config ?min_date ~min_heads:1 () >>=? fun block_stream ->
|
2017-03-09 17:35:43 +04:00
|
|
|
(* Temporary desactivate the monitoring of endorsement:
|
|
|
|
too slow for now. *)
|
|
|
|
(* Client_mining_operations.monitor_endorsement *)
|
2017-02-15 23:37:13 +04:00
|
|
|
(* cctxt >>= fun endorsement_stream -> *)
|
2017-03-09 17:35:43 +04:00
|
|
|
let endorsement_stream, _push = Lwt_stream.create () in
|
2016-12-03 16:05:02 +04:00
|
|
|
Client_mining_forge.create cctxt
|
2017-04-05 01:35:41 +04:00
|
|
|
?max_priority delegates block_stream endorsement_stream >>=? fun () ->
|
|
|
|
return ()
|
2017-03-09 17:35:43 +04:00
|
|
|
end else
|
2017-04-05 01:35:41 +04:00
|
|
|
return ()
|
2016-09-08 21:13:10 +04:00
|
|
|
in
|
2017-04-05 01:35:41 +04:00
|
|
|
denunciation >>=? fun () ->
|
|
|
|
endorsement >>=? fun () ->
|
2016-09-08 21:13:10 +04:00
|
|
|
forge
|