2017-02-24 20:17:53 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
type t
|
|
|
|
type db = t
|
|
|
|
|
|
|
|
module Message = Distributed_db_message
|
|
|
|
module Metadata = Distributed_db_metadata
|
|
|
|
|
|
|
|
type p2p = (Message.t, Metadata.t) P2p.net
|
|
|
|
|
|
|
|
val create: State.t -> p2p -> t
|
2017-11-09 14:26:25 +04:00
|
|
|
val state: db -> State.t
|
2017-02-24 20:17:53 +04:00
|
|
|
val shutdown: t -> unit Lwt.t
|
|
|
|
|
2017-04-19 23:46:10 +04:00
|
|
|
type net_db
|
2017-02-24 20:17:53 +04:00
|
|
|
|
2017-11-09 14:26:25 +04:00
|
|
|
val net_state: net_db -> State.Net.t
|
|
|
|
val db: net_db -> db
|
2017-02-24 20:17:53 +04:00
|
|
|
|
|
|
|
type callback = {
|
2017-11-11 06:34:12 +04:00
|
|
|
notify_branch:
|
|
|
|
P2p.Peer_id.t -> Block_locator.t -> unit ;
|
|
|
|
notify_head:
|
|
|
|
P2p.Peer_id.t -> Block_header.t -> Operation_hash.t list -> unit ;
|
2017-02-24 20:17:53 +04:00
|
|
|
disconnection: P2p.Peer_id.t -> unit ;
|
|
|
|
}
|
|
|
|
|
2017-09-29 20:43:13 +04:00
|
|
|
val activate: t -> State.Net.t -> net_db
|
|
|
|
val set_callback: net_db -> callback -> unit
|
2017-04-19 23:46:10 +04:00
|
|
|
val deactivate: net_db -> unit Lwt.t
|
|
|
|
|
2017-09-29 20:43:13 +04:00
|
|
|
val disconnect: net_db -> P2p.Peer_id.t -> unit Lwt.t
|
|
|
|
|
2017-04-19 23:46:10 +04:00
|
|
|
type operation =
|
|
|
|
| Blob of Operation.t
|
|
|
|
| Hash of Operation_hash.t
|
|
|
|
|
|
|
|
val resolve_operation:
|
|
|
|
net_db -> operation -> (Operation_hash.t * Operation.t) tzresult Lwt.t
|
|
|
|
|
|
|
|
val commit_block:
|
2017-09-29 20:43:13 +04:00
|
|
|
net_db -> Block_hash.t -> Updater.validation_result ->
|
2017-04-19 23:46:10 +04:00
|
|
|
State.Block.t option tzresult Lwt.t
|
|
|
|
val commit_invalid_block:
|
2017-09-29 20:43:13 +04:00
|
|
|
net_db -> Block_hash.t ->
|
2017-04-19 23:46:10 +04:00
|
|
|
bool tzresult Lwt.t
|
|
|
|
val inject_block:
|
|
|
|
t -> MBytes.t -> operation list list ->
|
|
|
|
(Block_hash.t * Block_header.t) tzresult Lwt.t
|
2017-06-09 19:54:08 +04:00
|
|
|
val clear_block: net_db -> Block_hash.t -> int -> unit
|
2017-04-19 23:46:10 +04:00
|
|
|
|
|
|
|
val inject_operation:
|
|
|
|
net_db -> Operation_hash.t -> Operation.t -> bool tzresult Lwt.t
|
|
|
|
|
|
|
|
val commit_protocol:
|
|
|
|
db -> Protocol_hash.t -> bool tzresult Lwt.t
|
|
|
|
val inject_protocol:
|
|
|
|
db -> Protocol_hash.t -> Protocol.t -> bool Lwt.t
|
|
|
|
|
|
|
|
val watch_block_header:
|
|
|
|
t -> (Block_hash.t * Block_header.t) Lwt_stream.t * Watcher.stopper
|
|
|
|
val watch_operation:
|
|
|
|
t -> (Operation_hash.t * Operation.t) Lwt_stream.t * Watcher.stopper
|
|
|
|
val watch_protocol:
|
|
|
|
t -> (Protocol_hash.t * Protocol.t) Lwt_stream.t * Watcher.stopper
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
|
|
|
|
module type DISTRIBUTED_DB = sig
|
|
|
|
type t
|
|
|
|
type key
|
|
|
|
type value
|
2017-04-19 23:46:10 +04:00
|
|
|
type param
|
2017-02-24 20:17:53 +04:00
|
|
|
val known: t -> key -> bool Lwt.t
|
2017-04-19 23:46:10 +04:00
|
|
|
type error += Missing_data of key
|
2017-11-08 15:42:09 +04:00
|
|
|
type error += Canceled of key
|
2017-11-08 15:52:10 +04:00
|
|
|
type error += Timeout of key
|
2017-04-19 23:46:10 +04:00
|
|
|
val read: t -> key -> value tzresult Lwt.t
|
|
|
|
val read_opt: t -> key -> value option Lwt.t
|
2017-02-24 20:17:53 +04:00
|
|
|
val read_exn: t -> key -> value Lwt.t
|
|
|
|
val watch: t -> (key * value) Lwt_stream.t * Watcher.stopper
|
2017-11-10 23:30:29 +04:00
|
|
|
val prefetch:
|
|
|
|
t ->
|
|
|
|
?peer:P2p.Peer_id.t ->
|
|
|
|
?timeout:float ->
|
|
|
|
key -> param -> unit
|
2017-11-08 15:42:09 +04:00
|
|
|
val fetch:
|
2017-11-08 15:52:10 +04:00
|
|
|
t ->
|
|
|
|
?peer:P2p.Peer_id.t ->
|
|
|
|
?timeout:float ->
|
|
|
|
key -> param -> value tzresult Lwt.t
|
2017-11-06 18:23:06 +04:00
|
|
|
val clear_or_cancel: t -> key -> unit
|
2017-02-24 20:17:53 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
module Block_header :
|
2017-04-19 23:46:10 +04:00
|
|
|
DISTRIBUTED_DB with type t = net_db
|
2017-02-24 20:17:53 +04:00
|
|
|
and type key := Block_hash.t
|
2017-04-19 21:21:23 +04:00
|
|
|
and type value := Block_header.t
|
2017-04-19 23:46:10 +04:00
|
|
|
and type param := unit
|
|
|
|
|
|
|
|
module Operations :
|
|
|
|
DISTRIBUTED_DB with type t = net_db
|
|
|
|
and type key = Block_hash.t * int
|
|
|
|
and type value = Operation.t list
|
|
|
|
and type param := Operation_list_list_hash.t
|
|
|
|
|
|
|
|
module Operation_hashes :
|
|
|
|
DISTRIBUTED_DB with type t = net_db
|
|
|
|
and type key = Block_hash.t * int
|
|
|
|
and type value = Operation_hash.t list
|
|
|
|
and type param := Operation_list_list_hash.t
|
|
|
|
|
|
|
|
module Operation :
|
|
|
|
DISTRIBUTED_DB with type t = net_db
|
|
|
|
and type key := Operation_hash.t
|
|
|
|
and type value := Operation.t
|
|
|
|
and type param := unit
|
2017-02-24 20:17:53 +04:00
|
|
|
|
|
|
|
module Protocol :
|
|
|
|
DISTRIBUTED_DB with type t = db
|
|
|
|
and type key := Protocol_hash.t
|
2017-04-19 21:21:23 +04:00
|
|
|
and type value := Protocol.t
|
2017-04-19 23:46:10 +04:00
|
|
|
and type param := unit
|
2017-02-24 20:17:53 +04:00
|
|
|
|
|
|
|
module Raw : sig
|
|
|
|
val encoding: Message.t P2p.Raw.t Data_encoding.t
|
|
|
|
val supported_versions: P2p_types.Version.t list
|
|
|
|
end
|
2017-11-11 06:34:12 +04:00
|
|
|
|
|
|
|
module Request : sig
|
|
|
|
val current_branch: net_db -> ?peer:P2p.Peer_id.t -> unit -> unit
|
|
|
|
val current_head: net_db -> ?peer:P2p.Peer_id.t -> unit -> unit
|
|
|
|
end
|
|
|
|
|
|
|
|
module Advertise : sig
|
|
|
|
val current_head:
|
|
|
|
net_db -> ?peer:P2p.Peer_id.t ->
|
|
|
|
?mempool:Operation_hash.t list -> State.Block.t -> unit
|
|
|
|
val current_branch:
|
|
|
|
net_db -> ?peer:P2p.Peer_id.t ->
|
|
|
|
State.Block.t -> unit Lwt.t
|
|
|
|
end
|
|
|
|
|