Shell: store the last allowed fork level

This commit is contained in:
Grégoire Henry 2018-05-10 16:10:25 +02:00 committed by Benjamin Canou
parent a43ee47ee1
commit d02892b810
5 changed files with 18 additions and 6 deletions

View File

@ -221,8 +221,9 @@ module Locked_block = struct
let header : Block_header.t = { shell ; protocol_data = MBytes.create 0 } in
Store.Block.Contents.store (store, genesis.block)
{ Store.Block.header ; message = Some "Genesis" ;
max_operations_ttl = 0 ;
context ; metadata = MBytes.create 0 ;
max_operations_ttl = 0 ; context ;
metadata = MBytes.create 0 ;
last_allowed_fork_level = 0l ;
} >>= fun () ->
Lwt.return header
@ -442,6 +443,8 @@ module Block = struct
let message { contents = { message } } = message
let max_operations_ttl { contents = { max_operations_ttl } } =
max_operations_ttl
let last_allowed_fork_level { contents = { last_allowed_fork_level } } =
last_allowed_fork_level
let is_genesis b = Block_hash.equal b.hash b.chain_state.genesis.block
@ -540,7 +543,7 @@ module Block = struct
chain_state block_header block_header_metadata
operations operations_metadata
{ Tezos_protocol_environment_shell.context ; message ;
max_operations_ttl } =
max_operations_ttl ; last_allowed_fork_level } =
let bytes = Block_header.to_bytes block_header in
let hash = Block_header.hash_raw bytes in
fail_unless
@ -577,6 +580,7 @@ module Block = struct
block_header ;
message ;
max_operations_ttl ;
last_allowed_fork_level ;
context = commit ;
metadata = block_header_metadata ;
} in

View File

@ -120,6 +120,7 @@ module Block : sig
val message: t -> string option
val max_operations_ttl: t -> int
val metadata: t -> MBytes.t
val last_allowed_fork_level: t -> Int32.t
val is_genesis: t -> bool
val predecessor: t -> block option Lwt.t

View File

@ -84,6 +84,7 @@ module Block = struct
header: Block_header.t ;
message: string option ;
max_operations_ttl: int ;
last_allowed_fork_level: Int32.t ;
context: Context_hash.t ;
metadata: MBytes.t ;
}
@ -98,16 +99,19 @@ module Block = struct
let open Data_encoding in
conv
(fun { header ; message ; max_operations_ttl ;
last_allowed_fork_level ;
context ; metadata } ->
(message, max_operations_ttl,
(message, max_operations_ttl, last_allowed_fork_level,
context, metadata, header ))
(fun (message, max_operations_ttl,
(fun (message, max_operations_ttl, last_allowed_fork_level,
context, metadata, header ) ->
{ header ; message ; max_operations_ttl ;
last_allowed_fork_level ;
context ; metadata })
(obj5
(obj6
(opt "message" string)
(req "max_operations_ttl" uint16)
(req "last_allowed_fork_level" int32)
(req "context" Context_hash.encoding)
(req "metadata" bytes)
(req "header" Block_header.encoding))

View File

@ -89,6 +89,7 @@ module Block : sig
header: Block_header.t ;
message: string option ;
max_operations_ttl: int ;
last_allowed_fork_level: Int32.t ;
context: Context_hash.t ;
metadata: MBytes.t ;
}

View File

@ -93,6 +93,8 @@ let lolblock ?(operations = []) header =
max_operations_ttl = 0 ;
message = None ;
context = Context_hash.zero ;
max_operation_data_length = 0 ;
last_allowed_fork_level = 0l ;
}
let b1 = lolblock "Blop !"