Node: allow invalid block errors to be stored
This commit is contained in:
parent
059e4cac79
commit
42e29c8f4a
@ -152,7 +152,7 @@ module Block = struct
|
||||
|
||||
type invalid_block = {
|
||||
level: int32 ;
|
||||
(* errors: Error_monad.error list ; *)
|
||||
errors: Error_monad.error list ;
|
||||
}
|
||||
|
||||
module Invalid_block =
|
||||
@ -166,9 +166,9 @@ module Block = struct
|
||||
let encoding =
|
||||
let open Data_encoding in
|
||||
conv
|
||||
(fun { level } -> (level))
|
||||
(fun (level) -> { level })
|
||||
int32
|
||||
(fun { level ; errors } -> (level, errors))
|
||||
(fun (level, errors) -> { level ; errors })
|
||||
(tup2 int32 (list Error_monad.error_encoding))
|
||||
end))
|
||||
|
||||
let register s =
|
||||
|
@ -115,7 +115,7 @@ module Block : sig
|
||||
|
||||
type invalid_block = {
|
||||
level: int32 ;
|
||||
(* errors: Error_monad.error list ; *)
|
||||
errors: Error_monad.error list ;
|
||||
}
|
||||
|
||||
module Invalid_block : MAP_STORE
|
||||
|
@ -792,9 +792,9 @@ let commit_block net_db hash header operations result =
|
||||
clear_block net_db hash header.shell.validation_passes ;
|
||||
return res
|
||||
|
||||
let commit_invalid_block net_db hash header _err =
|
||||
let commit_invalid_block net_db hash header errors =
|
||||
assert (Block_hash.equal hash (Block_header.hash header)) ;
|
||||
State.Block.store_invalid net_db.net_state header >>=? fun res ->
|
||||
State.Block.store_invalid net_db.net_state header errors >>=? fun res ->
|
||||
clear_block net_db hash header.shell.validation_passes ;
|
||||
return res
|
||||
|
||||
|
@ -376,6 +376,10 @@ module Block = struct
|
||||
Shared.use net_state.block_store begin fun store ->
|
||||
Store.Block.Invalid_block.known store hash
|
||||
end
|
||||
let read_invalid net_state hash =
|
||||
Shared.use net_state.block_store begin fun store ->
|
||||
Store.Block.Invalid_block.read_opt store hash
|
||||
end
|
||||
|
||||
let known net_state hash =
|
||||
Shared.use net_state.block_store begin fun store ->
|
||||
@ -478,7 +482,7 @@ module Block = struct
|
||||
end
|
||||
end
|
||||
|
||||
let store_invalid net_state block_header =
|
||||
let store_invalid net_state block_header errors =
|
||||
let bytes = Block_header.to_bytes block_header in
|
||||
let hash = Block_header.hash_raw bytes in
|
||||
Shared.use net_state.block_store begin fun store ->
|
||||
@ -489,7 +493,7 @@ module Block = struct
|
||||
return false
|
||||
else
|
||||
Store.Block.Invalid_block.store store hash
|
||||
{ level = block_header.shell.level } >>= fun () ->
|
||||
{ level = block_header.shell.level ; errors } >>= fun () ->
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -97,6 +97,7 @@ module Block : sig
|
||||
val known: Net.t -> Block_hash.t -> bool Lwt.t
|
||||
val known_valid: Net.t -> Block_hash.t -> bool Lwt.t
|
||||
val known_invalid: Net.t -> Block_hash.t -> bool Lwt.t
|
||||
val read_invalid: Net.t -> Block_hash.t -> Store.Block.invalid_block option Lwt.t
|
||||
|
||||
val read: Net.t -> Block_hash.t -> block tzresult Lwt.t
|
||||
val read_opt: Net.t -> Block_hash.t -> block option Lwt.t
|
||||
@ -112,6 +113,7 @@ module Block : sig
|
||||
val store_invalid:
|
||||
Net.t ->
|
||||
Block_header.t ->
|
||||
error list ->
|
||||
bool tzresult Lwt.t
|
||||
|
||||
val compare: t -> t -> int
|
||||
|
Loading…
Reference in New Issue
Block a user