Shell: do not validate blocks that don't increase the timestamp or fitness.
This commit is contained in:
parent
cb90e3e5c5
commit
85055aace6
@ -102,7 +102,10 @@ let rec may_set_head v (block: State.Valid_block.t) =
|
||||
|
||||
(** Block validation *)
|
||||
|
||||
type error += Invalid_operation of Operation_hash.t
|
||||
type error +=
|
||||
| Invalid_operation of Operation_hash.t
|
||||
| Non_increasing_timestamp
|
||||
| Non_increasing_fitness
|
||||
|
||||
let apply_block net db
|
||||
(pred: State.Valid_block.t) hash (block: State.Block_header.t) =
|
||||
@ -125,6 +128,18 @@ let apply_block net db
|
||||
failwith "This test network expired..."
|
||||
| None | Some _ -> return ()
|
||||
end >>=? fun () ->
|
||||
begin
|
||||
if Time.(pred.timestamp >= block.shell.timestamp) then
|
||||
fail Non_increasing_timestamp
|
||||
else
|
||||
return ()
|
||||
end >>=? fun () ->
|
||||
begin
|
||||
if Fitness.compare pred.fitness block.shell.fitness >= 0 then
|
||||
fail Non_increasing_fitness
|
||||
else
|
||||
return ()
|
||||
end >>=? fun () ->
|
||||
begin
|
||||
match pred.protocol with
|
||||
| None -> fail (State.Unknown_protocol pred.protocol_hash)
|
||||
|
@ -16,6 +16,10 @@ val notify_block: worker -> Block_hash.t -> State.Block_header.t -> unit Lwt.t
|
||||
|
||||
type t
|
||||
|
||||
type error +=
|
||||
| Non_increasing_timestamp
|
||||
| Non_increasing_fitness
|
||||
|
||||
val activate: worker -> State.Net.t -> t Lwt.t
|
||||
val get: worker -> State.Net_id.t -> t tzresult Lwt.t
|
||||
val get_exn: worker -> State.Net_id.t -> t Lwt.t
|
||||
|
Loading…
Reference in New Issue
Block a user