Client/Endorser: check blocks timestamps
This commit is contained in:
parent
8e40873a51
commit
c0a47a5b6f
@ -235,11 +235,19 @@ let schedule_endorsements (cctxt : #Proto_alpha.full) ~(max_past:Time.t) state b
|
|||||||
in
|
in
|
||||||
let time = Time.(add (now ()) state.delay) in
|
let time = Time.(add (now ()) state.delay) in
|
||||||
get_delegates cctxt state >>=? fun delegates ->
|
get_delegates cctxt state >>=? fun delegates ->
|
||||||
|
iter_p
|
||||||
ignore max_past;
|
(fun delegate ->
|
||||||
|
iter_p
|
||||||
iter_s
|
(fun (bi : Client_baking_blocks.block_info) ->
|
||||||
(fun delegate -> may_endorse bis delegate time)
|
if Time.compare bi.timestamp (Time.now ()) > 0 then
|
||||||
|
lwt_log_info "Ignore block %a: forged in the future"
|
||||||
|
Block_hash.pp_short bi.hash >>= return
|
||||||
|
else if Time.(min (now ()) bi.timestamp > max_past) then
|
||||||
|
lwt_log_info "Ignore block %a: forged too far the past"
|
||||||
|
Block_hash.pp_short bi.hash >>= return
|
||||||
|
else
|
||||||
|
may_endorse bi delegate time)
|
||||||
|
bis)
|
||||||
delegates
|
delegates
|
||||||
|
|
||||||
let schedule_endorsements (cctxt : #Proto_alpha.full) ~max_past state bis =
|
let schedule_endorsements (cctxt : #Proto_alpha.full) ~max_past state bis =
|
||||||
@ -317,7 +325,7 @@ let create (cctxt : #Proto_alpha.full) ?(max_past=(Time.of_seconds 110L)) ~delay
|
|||||||
| `Hash (Some (Ok bi)) ->
|
| `Hash (Some (Ok bi)) ->
|
||||||
Lwt.cancel timeout ;
|
Lwt.cancel timeout ;
|
||||||
last_get_block := None ;
|
last_get_block := None ;
|
||||||
schedule_endorsements cctxt ~max_past state bi >>= fun () ->
|
schedule_endorsements cctxt ~max_past state [ bi ] >>= fun () ->
|
||||||
worker_loop ()
|
worker_loop ()
|
||||||
| `Timeout ->
|
| `Timeout ->
|
||||||
begin
|
begin
|
||||||
@ -329,7 +337,7 @@ let create (cctxt : #Proto_alpha.full) ?(max_past=(Time.of_seconds 110L)) ~delay
|
|||||||
errs >>= fun () ->
|
errs >>= fun () ->
|
||||||
Lwt.return_unit
|
Lwt.return_unit
|
||||||
end >>= fun () ->
|
end >>= fun () ->
|
||||||
worker_loop () in
|
worker_loop ()
|
||||||
|
in
|
||||||
schedule_endorsements cctxt ~max_past state head >>= fun () ->
|
schedule_endorsements cctxt ~max_past state [ head ] >>= fun () ->
|
||||||
worker_loop ()
|
worker_loop ()
|
||||||
|
Loading…
Reference in New Issue
Block a user