ligo/src/proto_alpha/lib_delegate/client_baking_denunciation.ml

46 lines
1.7 KiB
OCaml
Raw Normal View History

2016-09-08 21:13:10 +04:00
(**************************************************************************)
(* *)
2018-02-06 00:17:03 +04:00
(* Copyright (c) 2014 - 2018. *)
2016-09-08 21:13:10 +04:00
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
include Logging.Make(struct let name = "client.denunciation" end)
2016-09-08 21:13:10 +04:00
let create cctxt endorsement_stream =
let never_ends = Lwt_utils.never_ending () in
let event_k cctxt () e =
(* TODO: more than just logging *)
Client_keys.Public_key_hash.name
cctxt
e.Client_baking_operations.source >>= function
| Ok source ->
lwt_debug
"Discovered endorsement for block %a by %s (slot @[<h>%a@])"
Block_hash.pp_short e.block
source
Format.(pp_print_list pp_print_int) e.slots >>= fun () ->
return ()
| Error errs ->
lwt_log_error "Error whilst checking the endorsment %a/%a:@\n%a"
Block_hash.pp_short e.block
Format.(pp_print_list pp_print_int) e.slots
pp_print_error errs >>= fun () ->
return ()
in
Client_baking_scheduling.main
~name:"denunciator"
~cctxt
~stream:endorsement_stream
~state_maker:(fun _ _ -> return ())
~pre_loop:(fun _ _ _ -> return ())
~compute_timeout:(fun () -> never_ends)
~timeout_k:(fun _ _ () -> return ())
~event_k