diff --git a/src/node/shell/distributed_db.ml b/src/node/shell/distributed_db.ml index 615f128e3..9a313c757 100644 --- a/src/node/shell/distributed_db.ml +++ b/src/node/shell/distributed_db.ml @@ -343,7 +343,9 @@ let noop_callback = { type t = db -let state { net_state } = net_state +let state { disk } = disk +let net_state { net_state } = net_state +let db { global_db } = global_db module P2p_reader = struct diff --git a/src/node/shell/distributed_db.mli b/src/node/shell/distributed_db.mli index 586b786fc..5adf9ed85 100644 --- a/src/node/shell/distributed_db.mli +++ b/src/node/shell/distributed_db.mli @@ -16,11 +16,13 @@ module Metadata = Distributed_db_metadata type p2p = (Message.t, Metadata.t) P2p.net val create: State.t -> p2p -> t +val state: db -> State.t val shutdown: t -> unit Lwt.t type net_db -val state: net_db -> State.Net.t +val net_state: net_db -> State.Net.t +val db: net_db -> db type callback = { notify_branch: P2p.Peer_id.t -> Block_locator.t -> unit ; diff --git a/src/node/shell/node.ml b/src/node/shell/node.ml index 20b22a930..fefe7558d 100644 --- a/src/node/shell/node.ml +++ b/src/node/shell/node.ml @@ -441,7 +441,7 @@ module RPC = struct | None -> Lwt.return (Prevalidation.empty_result, Operation_hash.Set.empty) | Some (validator, net_db) -> - let net_state = Distributed_db.state net_db in + let net_state = Distributed_db.net_state net_db in let prevalidator = Validator.prevalidator validator in State.Block.read_exn net_state h >>= fun block -> Prevalidator.pending ~block prevalidator >|= fun ops -> @@ -540,7 +540,7 @@ module RPC = struct match Validator.test_validator node.mainnet_validator with | None -> Lwt.return_nil | Some (_, net_db) -> - Chain.known_heads (Distributed_db.state net_db) + Chain.known_heads (Distributed_db.net_state net_db) end >>= fun test_heads -> Lwt_list.fold_left_s (fun map block -> diff --git a/src/node/shell/prevalidator.ml b/src/node/shell/prevalidator.ml index ab159f1ae..f29d7a114 100644 --- a/src/node/shell/prevalidator.ml +++ b/src/node/shell/prevalidator.ml @@ -66,7 +66,7 @@ let merge _key a b = let create net_db = - let net_state = Distributed_db.state net_db in + let net_state = Distributed_db.net_state net_db in let cancelation, cancel, _on_cancel = Lwt_utils.canceler () in let push_to_worker, worker_waiter = Lwt_utils.queue () in @@ -351,7 +351,7 @@ let context pv = pv.context () let shutdown pv = pv.shutdown () let inject_operation pv ?(force = false) (op: Operation.t) = - let net_id = State.Net.id (Distributed_db.state pv.net_db) in + let net_id = State.Net.id (Distributed_db.net_state pv.net_db) in let wrap_error h map = begin try return (Operation_hash.Map.find h map) diff --git a/src/node/shell/validator.ml b/src/node/shell/validator.ml index 78e61eb2d..ba8553dd2 100644 --- a/src/node/shell/validator.ml +++ b/src/node/shell/validator.ml @@ -474,7 +474,7 @@ module Context_db = struct Lwt.return_unit let process (v: net_validator) ~get_context ~set_context hash block = - let net_state = Distributed_db.state v.net_db in + let net_state = Distributed_db.net_state v.net_db in get_context v block.Block_header.shell.predecessor >>= function | Error _ as error -> Lwt_unix.yield () >>= fun () -> @@ -561,7 +561,7 @@ module Context_db = struct | Some b -> Int64.to_float (Time.diff b.Block_header.shell.timestamp time) let create net_db = - let net_state = Distributed_db.state net_db in + let net_state = Distributed_db.net_state net_db in let tbl = Block_hash.Table.create 50 in let canceler = Lwt_utils.Canceler.create () in let worker_trigger, worker_waiter = Lwt_utils.trigger () in