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. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2018-06-01 01:05:00 +04:00
|
|
|
include Logging.Make(struct let name = "client.denunciation" end)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2016-12-03 16:05:02 +04:00
|
|
|
let create cctxt endorsement_stream =
|
2018-06-19 10:03:10 +04:00
|
|
|
|
2018-06-20 07:20:50 +04:00
|
|
|
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 ()
|
2017-04-05 03:02:10 +04:00
|
|
|
in
|
2018-06-19 10:03:10 +04:00
|
|
|
|
2018-06-20 07:20:50 +04:00
|
|
|
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
|
|
|
|
|