ligo/src/client/embedded/bootstrap/mining/client_mining_daemon.ml

40 lines
1.6 KiB
OCaml
Raw Normal View History

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. *)
(* *)
(**************************************************************************)
open Logging.Client.Mining
2016-09-21 18:22:43 +04:00
let run ?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
2016-09-21 18:22:43 +04:00
Client_mining_blocks.monitor ?min_date () >>= fun block_stream ->
2016-09-08 21:13:10 +04:00
Client_mining_endorsement.create ~delay delegates block_stream
else
Lwt.return_unit
in
let denunciation =
if Client_proto_args.Daemon.(!all || !denunciation) then
Client_mining_operations.monitor_endorsement () >>= fun endorsement_stream ->
Client_mining_denunciation.create endorsement_stream
else
Lwt.return_unit
in
let forge =
2016-09-21 18:22:43 +04:00
Client_mining_blocks.monitor ?min_date () >>= fun block_stream ->
2016-09-08 21:13:10 +04:00
Client_mining_operations.monitor_endorsement () >>= fun endorsement_stream ->
if Client_proto_args.Daemon.(!all || !mining) then
Client_mining_forge.create
?max_priority delegates block_stream endorsement_stream
else
Lwt.return_unit
in
denunciation >>= fun () ->
endorsement >>= fun () ->
forge