Alpha/Endorser: use Client_baking_scheduling function and add log
This commit is contained in:
parent
98120cf068
commit
b99d3be1cc
@ -103,7 +103,6 @@ type state = {
|
|||||||
|
|
||||||
and endorsements = {
|
and endorsements = {
|
||||||
time: Time.t ;
|
time: Time.t ;
|
||||||
timeout: unit Lwt.t ;
|
|
||||||
delegates: public_key_hash list ;
|
delegates: public_key_hash list ;
|
||||||
block: Client_baking_blocks.block_info ;
|
block: Client_baking_blocks.block_info ;
|
||||||
}
|
}
|
||||||
@ -188,12 +187,10 @@ let prepare_endorsement ~(max_past:int64) () (cctxt : #Proto_alpha.full) state b
|
|||||||
-% t event "endorsement_got_block"
|
-% t event "endorsement_got_block"
|
||||||
-% a Block_hash.Logging.tag bi.hash) >>= fun () ->
|
-% a Block_hash.Logging.tag bi.hash) >>= fun () ->
|
||||||
let time = Time.(add (now ()) state.delay) in
|
let time = Time.(add (now ()) state.delay) in
|
||||||
let timeout = Lwt_unix.sleep (Int64.to_float state.delay) in
|
|
||||||
get_delegates cctxt state >>=? fun delegates ->
|
get_delegates cctxt state >>=? fun delegates ->
|
||||||
filter_p (allowed_to_endorse cctxt bi) delegates >>=? fun delegates ->
|
filter_p (allowed_to_endorse cctxt bi) delegates >>=? fun delegates ->
|
||||||
state.pending <- Some {
|
state.pending <- Some {
|
||||||
time ;
|
time ;
|
||||||
timeout ;
|
|
||||||
block = bi ;
|
block = bi ;
|
||||||
delegates ;
|
delegates ;
|
||||||
} ;
|
} ;
|
||||||
@ -202,9 +199,15 @@ let prepare_endorsement ~(max_past:int64) () (cctxt : #Proto_alpha.full) state b
|
|||||||
let compute_timeout state =
|
let compute_timeout state =
|
||||||
match state.pending with
|
match state.pending with
|
||||||
| None -> Lwt_utils.never_ending ()
|
| None -> Lwt_utils.never_ending ()
|
||||||
| Some { timeout ; block ; delegates } ->
|
| Some { time ; block ; delegates } ->
|
||||||
timeout >>= fun () ->
|
match Client_baking_scheduling.sleep_until time with
|
||||||
Lwt.return (block, delegates)
|
| None -> Lwt.return (block, delegates)
|
||||||
|
| Some timeout ->
|
||||||
|
lwt_log_info Tag.DSL.(fun f ->
|
||||||
|
f "Waiting until %a to inject endorsements"
|
||||||
|
-% t event "wait_before_injecting"
|
||||||
|
-% a timestamp_tag time) >>= fun () ->
|
||||||
|
timeout >>= fun () -> Lwt.return (block, delegates)
|
||||||
|
|
||||||
let create
|
let create
|
||||||
(cctxt: #Proto_alpha.full)
|
(cctxt: #Proto_alpha.full)
|
||||||
@ -223,6 +226,7 @@ let create
|
|||||||
state.pending <- None ;
|
state.pending <- None ;
|
||||||
iter_p (endorse_for_delegate cctxt block) delegates
|
iter_p (endorse_for_delegate cctxt block) delegates
|
||||||
in
|
in
|
||||||
|
|
||||||
let event_k cctxt state bi =
|
let event_k cctxt state bi =
|
||||||
state.pending <- None ;
|
state.pending <- None ;
|
||||||
prepare_endorsement ~max_past () cctxt state bi
|
prepare_endorsement ~max_past () cctxt state bi
|
||||||
|
Loading…
Reference in New Issue
Block a user