Proto: return the maximum TTL for operations
This commit is contained in:
parent
747cdb1963
commit
8d5155cf32
@ -86,6 +86,7 @@ module Block = struct
|
||||
header: Block_header.t ;
|
||||
message: string ;
|
||||
operation_list_count: int ;
|
||||
max_operations_ttl: int ;
|
||||
}
|
||||
|
||||
module Contents =
|
||||
@ -97,13 +98,16 @@ module Block = struct
|
||||
let encoding =
|
||||
let open Data_encoding in
|
||||
conv
|
||||
(fun { header ; message ; operation_list_count } ->
|
||||
(message, operation_list_count, header))
|
||||
(fun (message, operation_list_count, header) ->
|
||||
{ header ; message ; operation_list_count })
|
||||
(obj3
|
||||
(fun { header ; message ; operation_list_count ;
|
||||
max_operations_ttl } ->
|
||||
(message, operation_list_count, max_operations_ttl, header))
|
||||
(fun (message, operation_list_count,
|
||||
max_operations_ttl, header) ->
|
||||
{ header ; message ; max_operations_ttl ; operation_list_count })
|
||||
(obj4
|
||||
(req "message" string)
|
||||
(req "operation_list_count" uint8)
|
||||
(req "max_operations_ttl" uint16)
|
||||
(req "header" Block_header.encoding))
|
||||
end))
|
||||
|
||||
|
@ -89,6 +89,7 @@ module Block : sig
|
||||
header: Block_header.t ;
|
||||
message: string ;
|
||||
operation_list_count: int ;
|
||||
max_operations_ttl: int ;
|
||||
}
|
||||
|
||||
module Contents : SINGLE_STORE
|
||||
|
@ -108,7 +108,7 @@ module Locked_block = struct
|
||||
let header : Block_header.t = { shell ; proto = MBytes.create 0 } in
|
||||
Store.Block.Contents.store (store, genesis.block)
|
||||
{ Store.Block.header ; message = "Genesis" ;
|
||||
operation_list_count = 0 } >>= fun () ->
|
||||
operation_list_count = 0 ; max_operations_ttl = 0 } >>= fun () ->
|
||||
Context.commit_genesis
|
||||
context_index
|
||||
~id:genesis.block
|
||||
@ -342,7 +342,7 @@ module Block = struct
|
||||
|
||||
let store
|
||||
net_state block_header operations
|
||||
{ Updater.context ; fitness ; message } =
|
||||
{ Updater.context ; fitness ; message ; max_operations_ttl } =
|
||||
let bytes = Block_header.to_bytes block_header in
|
||||
let hash = Block_header.hash_raw bytes in
|
||||
(* let's the validator check the consistency... of fitness, level, ... *)
|
||||
@ -358,6 +358,7 @@ module Block = struct
|
||||
Store.Block.header = block_header ;
|
||||
message ;
|
||||
operation_list_count = List.length operations ;
|
||||
max_operations_ttl ;
|
||||
} in
|
||||
Shared.use net_state.block_store begin fun store ->
|
||||
Store.Block.Invalid_block.known store hash >>= fun known_invalid ->
|
||||
|
@ -17,6 +17,7 @@ type validation_result = {
|
||||
context: Context.t ;
|
||||
fitness: Fitness.t ;
|
||||
message: string option ;
|
||||
max_operations_ttl: int ;
|
||||
}
|
||||
|
||||
type rpc_context = {
|
||||
|
@ -15,6 +15,7 @@ type validation_result = Protocol_sigs.validation_result = {
|
||||
context: Context.t ;
|
||||
fitness: Fitness.t ;
|
||||
message: string option ;
|
||||
max_operations_ttl: int ;
|
||||
}
|
||||
|
||||
type rpc_context = Protocol_sigs.rpc_context = {
|
||||
|
@ -13,6 +13,7 @@ type validation_result = Protocol_sigs.validation_result = {
|
||||
context: Context.t ;
|
||||
fitness: Fitness.t ;
|
||||
message: string option ;
|
||||
max_operations_ttl: int ;
|
||||
}
|
||||
|
||||
type rpc_context = Protocol_sigs.rpc_context = {
|
||||
|
@ -116,7 +116,7 @@ let init = Init_storage.may_initialize
|
||||
let finalize ?commit_message:message c =
|
||||
let fitness = Fitness.from_int64 (Fitness.current c) in
|
||||
let context = Storage.recover c in
|
||||
{ Updater.context ; fitness ; message }
|
||||
{ Updater.context ; fitness ; message ; max_operations_ttl = 60 }
|
||||
|
||||
let configure_sandbox = Init_storage.configure_sandbox
|
||||
|
||||
|
@ -87,7 +87,8 @@ let finalize_block ctxt =
|
||||
let fitness = Fitness.get ctxt in
|
||||
let message = Some (Format.asprintf "fitness <- %Ld" fitness) in
|
||||
let fitness = Fitness.from_int64 fitness in
|
||||
return { Updater.message ; context = ctxt.context ; fitness }
|
||||
return { Updater.message ; context = ctxt.context ; fitness ;
|
||||
max_operations_ttl = 0 }
|
||||
|
||||
let rpc_services = Services.rpc_services
|
||||
|
||||
|
@ -7,6 +7,7 @@ type validation_result = {
|
||||
context: Context.t ;
|
||||
fitness: Fitness.t ;
|
||||
message: string option ;
|
||||
max_operations_ttl: int ;
|
||||
}
|
||||
|
||||
type rpc_context = {
|
||||
|
@ -93,13 +93,15 @@ let begin_application
|
||||
let message =
|
||||
Some (Format.asprintf "activate %a" Protocol_hash.pp_short hash) in
|
||||
Updater.activate ctxt hash >>= fun ctxt ->
|
||||
return { Updater.message ; context = ctxt ; fitness }
|
||||
return { Updater.message ; context = ctxt ;
|
||||
fitness ; max_operations_ttl = 0 }
|
||||
| Activate_testnet (hash, delay) ->
|
||||
let message =
|
||||
Some (Format.asprintf "activate testnet %a" Protocol_hash.pp_short hash) in
|
||||
let expiration = Time.add raw_block.shell.timestamp delay in
|
||||
Updater.fork_test_network ctxt hash expiration >>= fun ctxt ->
|
||||
return { Updater.message ; context = ctxt ; fitness }
|
||||
return { Updater.message ; context = ctxt ; fitness ;
|
||||
max_operations_ttl = 0 }
|
||||
|
||||
let begin_construction
|
||||
~predecessor_context:context
|
||||
@ -111,7 +113,8 @@ let begin_construction
|
||||
?proto_header:_
|
||||
() =
|
||||
(* Dummy result. *)
|
||||
return { Updater.message = None ; context ; fitness }
|
||||
return { Updater.message = None ; context ;
|
||||
fitness ; max_operations_ttl = 0 }
|
||||
|
||||
let apply_operation _vctxt _ =
|
||||
Lwt.return (Error []) (* absurd *)
|
||||
|
@ -89,7 +89,8 @@ let lolblock ?(operations = []) header =
|
||||
proto = MBytes.of_string header ;
|
||||
} ;
|
||||
operation_list_count = Random.int 32 ;
|
||||
message = ""
|
||||
max_operations_ttl = 0 ;
|
||||
message = "" ;
|
||||
}
|
||||
|
||||
let b1 = lolblock "Blop !"
|
||||
|
Loading…
Reference in New Issue
Block a user