ligo/src/client/embedded/alpha/client_mining_daemon.ml

48 lines
1.8 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 Client_commands
2016-09-08 21:13:10 +04:00
open Logging.Client.Mining
let run cctxt ?max_priority ~delay ?min_date delegates ~endorsement ~denunciation ~mining =
2016-09-08 21:13:10 +04:00
(* TODO really detach... *)
let endorsement =
if endorsement then
2017-02-15 20:20:10 +04:00
Client_mining_blocks.monitor
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
return ()
2016-09-08 21:13:10 +04:00
in
let denunciation =
if denunciation then
2017-02-15 20:20:10 +04:00
Client_mining_operations.monitor_endorsement
cctxt.rpc_config >>=? fun endorsement_stream ->
Client_mining_denunciation.create cctxt endorsement_stream >>= fun () ->
return ()
2016-09-08 21:13:10 +04:00
else
return ()
2016-09-08 21:13:10 +04:00
in
let forge =
if mining then begin
2017-03-09 17:35:43 +04:00
Client_mining_blocks.monitor
cctxt.rpc_config ?min_date ~min_heads:1 () >>=? fun block_stream ->
Client_mining_operations.monitor_endorsement
cctxt.rpc_config >>=? fun endorsement_stream ->
Client_mining_forge.create cctxt
?max_priority delegates block_stream endorsement_stream >>=? fun () ->
return ()
2017-03-09 17:35:43 +04:00
end else
return ()
2016-09-08 21:13:10 +04:00
in
denunciation >>=? fun () ->
endorsement >>=? fun () ->
2016-09-08 21:13:10 +04:00
forge