Shell: Quick and dirty allowance of time shift

The right solution being to wait for the messages to be valid.
This commit is contained in:
Pierre Chambart 2018-06-13 22:56:48 +02:00 committed by Benjamin Canou
parent 663c4e223e
commit 2aeba212a7
2 changed files with 3 additions and 3 deletions

View File

@ -35,7 +35,7 @@ let assert_acceptable_header pipeline
?(first = false) hash (header : Block_header.t) = ?(first = false) hash (header : Block_header.t) =
let chain_state = Distributed_db.chain_state pipeline.chain_db in let chain_state = Distributed_db.chain_state pipeline.chain_db in
fail_unless fail_unless
(Time.(now () >= header.shell.timestamp)) (Time.(add (now ()) 15L >= header.shell.timestamp))
(Future_block_header hash) >>=? fun () -> (Future_block_header hash) >>=? fun () ->
State.Chain.checkpoint chain_state >>= fun (level, checkpoint) -> State.Chain.checkpoint chain_state >>= fun (level, checkpoint) ->
fail_when fail_when

View File

@ -494,7 +494,7 @@ module P2p_reader = struct
(* TODO Kick *) (* TODO Kick *)
P2p.greylist_peer global_db.p2p state.gid ; P2p.greylist_peer global_db.p2p state.gid ;
Lwt.return_unit Lwt.return_unit
end else if Time.(now () < head.shell.timestamp) then begin end else if Time.(add (now ()) 15L < head.shell.timestamp) then begin
(* TODO some penalty *) (* TODO some penalty *)
lwt_log_notice "Received future block %a from peer %a." lwt_log_notice "Received future block %a from peer %a."
Block_hash.pp_short (Block_header.hash head) Block_hash.pp_short (Block_header.hash head)
@ -545,7 +545,7 @@ module P2p_reader = struct
(* TODO Kick *) (* TODO Kick *)
P2p.greylist_peer global_db.p2p state.gid ; P2p.greylist_peer global_db.p2p state.gid ;
Lwt.return_unit Lwt.return_unit
end else if Time.(now () < header.shell.timestamp) then begin end else if Time.(add (now ()) 15L < header.shell.timestamp) then begin
(* TODO some penalty *) (* TODO some penalty *)
lwt_log_notice "Received future block %a from peer %a." lwt_log_notice "Received future block %a from peer %a."
Block_hash.pp_short head Block_hash.pp_short head