2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
open Store_sigs
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type t
|
|
|
|
type global_store = t
|
|
|
|
|
|
|
|
(** Open or initialize a store at a given path. *)
|
|
|
|
val init: string -> t tzresult Lwt.t
|
|
|
|
|
|
|
|
|
|
|
|
(** {2 Net store} ************************************************************)
|
|
|
|
|
|
|
|
module Net : sig
|
|
|
|
|
|
|
|
val list: global_store -> Net_id.t list Lwt.t
|
|
|
|
val destroy: global_store -> Net_id.t -> unit Lwt.t
|
|
|
|
|
|
|
|
type store
|
|
|
|
val get: global_store -> Net_id.t -> store
|
|
|
|
|
2017-03-31 15:04:05 +04:00
|
|
|
module Genesis_hash : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Block_hash.t
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
module Genesis_time : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Time.t
|
|
|
|
|
|
|
|
module Genesis_protocol : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Protocol_hash.t
|
|
|
|
|
|
|
|
module Genesis_test_protocol : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Protocol_hash.t
|
|
|
|
|
|
|
|
module Expiration : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Time.t
|
|
|
|
|
|
|
|
module Forked_network_ttl : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Int64.t
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
(** {2 Chain data} ***********************************************************)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
module Chain : sig
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type store
|
|
|
|
val get: Net.store -> store
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
module Current_head : SINGLE_STORE
|
|
|
|
with type t := store
|
|
|
|
and type value := Block_hash.t
|
|
|
|
|
|
|
|
module Known_heads : BUFFERED_SET_STORE
|
|
|
|
with type t := store
|
|
|
|
and type elt := Block_hash.t
|
|
|
|
and module Set := Block_hash.Set
|
|
|
|
|
|
|
|
module Valid_successors : BUFFERED_SET_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type elt := Block_hash.t
|
|
|
|
and module Set := Block_hash.Set
|
|
|
|
|
|
|
|
module Invalid_successors : BUFFERED_SET_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type elt := Block_hash.t
|
|
|
|
and module Set := Block_hash.Set
|
|
|
|
|
|
|
|
module Successor_in_chain : SINGLE_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type value := Block_hash.t
|
|
|
|
|
|
|
|
module In_chain_insertion_time : SINGLE_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type value := Time.t
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
(** {2 Generic signature} *****************************************************)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
(** Generic signature for Operations, Block_header, and Protocol "tracked"
|
|
|
|
contents (i.e. with 'discovery_time', 'validtity', ...) *)
|
|
|
|
module type DATA_STORE = sig
|
|
|
|
|
|
|
|
type store
|
|
|
|
type key
|
|
|
|
type key_set
|
|
|
|
type value
|
|
|
|
|
|
|
|
val encoding: value Data_encoding.t
|
|
|
|
|
|
|
|
val compare: value -> value -> int
|
|
|
|
val equal: value -> value -> bool
|
|
|
|
|
|
|
|
val hash: value -> key
|
|
|
|
val hash_raw: MBytes.t -> key
|
|
|
|
|
|
|
|
module Discovery_time : MAP_STORE
|
|
|
|
with type t := store
|
|
|
|
and type key := key
|
|
|
|
and type value := Time.t
|
|
|
|
|
|
|
|
module Contents : SINGLE_STORE
|
|
|
|
with type t = store * key
|
|
|
|
and type value := value
|
|
|
|
|
|
|
|
module RawContents : SINGLE_STORE
|
|
|
|
with type t = store * key
|
|
|
|
and type value := MBytes.t
|
|
|
|
|
|
|
|
module Validation_time : SINGLE_STORE
|
|
|
|
with type t = store * key
|
|
|
|
and type value := Time.t
|
|
|
|
|
|
|
|
module Errors : MAP_STORE
|
|
|
|
with type t := store
|
|
|
|
and type key := key
|
|
|
|
and type value = error list
|
|
|
|
|
|
|
|
module Pending : BUFFERED_SET_STORE
|
|
|
|
with type t = store
|
|
|
|
and type elt := key
|
|
|
|
and type Set.t = key_set
|
|
|
|
|
|
|
|
end
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
(** {2 Operation store} *****************************************************)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
module Operation : sig
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type shell_header = {
|
|
|
|
net_id: Net_id.t ;
|
|
|
|
}
|
|
|
|
val shell_header_encoding: shell_header Data_encoding.t
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type t = {
|
|
|
|
shell: shell_header ;
|
|
|
|
proto: MBytes.t ;
|
|
|
|
}
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type store
|
|
|
|
val get: Net.store -> store
|
|
|
|
|
|
|
|
include DATA_STORE
|
|
|
|
with type store := store
|
2016-09-08 21:13:10 +04:00
|
|
|
and type key = Operation_hash.t
|
2017-02-24 20:17:53 +04:00
|
|
|
and type value = t
|
|
|
|
and type key_set = Operation_hash.Set.t
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
end
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
(** {2 Block header store} **************************************************)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
module Block_header : sig
|
2016-10-21 16:01:20 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type shell_header = {
|
|
|
|
net_id: Net_id.t ;
|
|
|
|
predecessor: Block_hash.t ;
|
|
|
|
timestamp: Time.t ;
|
2017-03-30 15:16:21 +04:00
|
|
|
operations: Operation_list_list_hash.t ;
|
2017-02-24 20:17:53 +04:00
|
|
|
fitness: MBytes.t list ;
|
|
|
|
}
|
|
|
|
val shell_header_encoding: shell_header Data_encoding.t
|
|
|
|
|
|
|
|
type t = {
|
|
|
|
shell: shell_header ;
|
|
|
|
proto: MBytes.t ;
|
|
|
|
}
|
|
|
|
|
|
|
|
type store
|
|
|
|
val get: Net.store -> store
|
|
|
|
|
|
|
|
include DATA_STORE
|
|
|
|
with type store := store
|
|
|
|
and type key = Block_hash.t
|
|
|
|
and type value = t
|
|
|
|
and type key_set = Block_hash.Set.t
|
2016-10-21 16:01:20 +04:00
|
|
|
|
2017-03-30 15:16:21 +04:00
|
|
|
module Operation_list_count : SINGLE_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type value = int
|
|
|
|
|
|
|
|
module Operation_list : MAP_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type key = int
|
|
|
|
and type value = Operation_hash.t list
|
|
|
|
|
|
|
|
module Operation_list_path : MAP_STORE
|
|
|
|
with type t = store * Block_hash.t
|
|
|
|
and type key = int
|
|
|
|
and type value = Operation_list_list_hash.path
|
|
|
|
|
2016-10-21 16:01:20 +04:00
|
|
|
end
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
(** {2 Protocol store} ******************************************************)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
module Protocol : sig
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type t = Tezos_compiler.Protocol.t
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
type store
|
|
|
|
val get: global_store -> store
|
2016-09-08 21:13:10 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
include DATA_STORE
|
|
|
|
with type store := store
|
|
|
|
and type key = Protocol_hash.t
|
|
|
|
and type value = t
|
|
|
|
and type key_set = Protocol_hash.Set.t
|
2016-10-21 16:01:20 +04:00
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
end
|