Distributed_db: export disconnect
This commit is contained in:
parent
06e4ec4d9b
commit
0c3a54c2f9
@ -201,6 +201,8 @@ module Real = struct
|
|||||||
~init:[] ~f:(fun _peer_id c acc -> c :: acc)
|
~init:[] ~f:(fun _peer_id c acc -> c :: acc)
|
||||||
let find_connection { pool } peer_id =
|
let find_connection { pool } peer_id =
|
||||||
P2p_connection_pool.Connection.find_by_peer_id pool peer_id
|
P2p_connection_pool.Connection.find_by_peer_id pool peer_id
|
||||||
|
let disconnect ?wait conn =
|
||||||
|
P2p_connection_pool.disconnect ?wait conn
|
||||||
let connection_info _net conn =
|
let connection_info _net conn =
|
||||||
P2p_connection_pool.Connection.info conn
|
P2p_connection_pool.Connection.info conn
|
||||||
let connection_stat _net conn =
|
let connection_stat _net conn =
|
||||||
@ -319,6 +321,7 @@ type ('msg, 'meta) t = {
|
|||||||
shutdown : unit -> unit Lwt.t ;
|
shutdown : unit -> unit Lwt.t ;
|
||||||
connections : unit -> ('msg, 'meta) connection list ;
|
connections : unit -> ('msg, 'meta) connection list ;
|
||||||
find_connection : Peer_id.t -> ('msg, 'meta) connection option ;
|
find_connection : Peer_id.t -> ('msg, 'meta) connection option ;
|
||||||
|
disconnect : ?wait:bool -> ('msg, 'meta) connection -> unit Lwt.t ;
|
||||||
connection_info : ('msg, 'meta) connection -> Connection_info.t ;
|
connection_info : ('msg, 'meta) connection -> Connection_info.t ;
|
||||||
connection_stat : ('msg, 'meta) connection -> Stat.t ;
|
connection_stat : ('msg, 'meta) connection -> Stat.t ;
|
||||||
global_stat : unit -> Stat.t ;
|
global_stat : unit -> Stat.t ;
|
||||||
@ -385,6 +388,7 @@ let create ~config ~limits meta_cfg msg_cfg =
|
|||||||
shutdown = Real.shutdown net ;
|
shutdown = Real.shutdown net ;
|
||||||
connections = Real.connections net ;
|
connections = Real.connections net ;
|
||||||
find_connection = Real.find_connection net ;
|
find_connection = Real.find_connection net ;
|
||||||
|
disconnect = Real.disconnect ;
|
||||||
connection_info = Real.connection_info net ;
|
connection_info = Real.connection_info net ;
|
||||||
connection_stat = Real.connection_stat net ;
|
connection_stat = Real.connection_stat net ;
|
||||||
global_stat = Real.global_stat net ;
|
global_stat = Real.global_stat net ;
|
||||||
@ -408,6 +412,7 @@ let faked_network meta_config = {
|
|||||||
shutdown = Lwt.return ;
|
shutdown = Lwt.return ;
|
||||||
connections = (fun () -> []) ;
|
connections = (fun () -> []) ;
|
||||||
find_connection = (fun _ -> None) ;
|
find_connection = (fun _ -> None) ;
|
||||||
|
disconnect = (fun ?wait:_ _ -> Lwt.return_unit) ;
|
||||||
connection_info = (fun _ -> Fake.connection_info) ;
|
connection_info = (fun _ -> Fake.connection_info) ;
|
||||||
connection_stat = (fun _ -> Fake.empty_stat) ;
|
connection_stat = (fun _ -> Fake.empty_stat) ;
|
||||||
global_stat = (fun () -> Fake.empty_stat) ;
|
global_stat = (fun () -> Fake.empty_stat) ;
|
||||||
@ -429,6 +434,7 @@ let maintain net = net.maintain ()
|
|||||||
let roll net = net.roll ()
|
let roll net = net.roll ()
|
||||||
let shutdown net = net.shutdown ()
|
let shutdown net = net.shutdown ()
|
||||||
let connections net = net.connections ()
|
let connections net = net.connections ()
|
||||||
|
let disconnect net = net.disconnect
|
||||||
let find_connection net = net.find_connection
|
let find_connection net = net.find_connection
|
||||||
let connection_info net = net.connection_info
|
let connection_info net = net.connection_info
|
||||||
let connection_stat net = net.connection_stat
|
let connection_stat net = net.connection_stat
|
||||||
|
@ -171,6 +171,11 @@ val connection_info :
|
|||||||
('msg, 'meta) net -> ('msg, 'meta) connection -> Connection_info.t
|
('msg, 'meta) net -> ('msg, 'meta) connection -> Connection_info.t
|
||||||
val connection_stat :
|
val connection_stat :
|
||||||
('msg, 'meta) net -> ('msg, 'meta) connection -> Stat.t
|
('msg, 'meta) net -> ('msg, 'meta) connection -> Stat.t
|
||||||
|
|
||||||
|
(** Cleanly closes a connection. *)
|
||||||
|
val disconnect :
|
||||||
|
('msg, 'meta) net -> ?wait:bool -> ('msg, 'meta) connection -> unit Lwt.t
|
||||||
|
|
||||||
val global_stat : ('msg, 'meta) net -> Stat.t
|
val global_stat : ('msg, 'meta) net -> Stat.t
|
||||||
|
|
||||||
(** Accessors for meta information about a global identifier *)
|
(** Accessors for meta information about a global identifier *)
|
||||||
|
@ -707,6 +707,11 @@ let get_net { active_nets } net_id =
|
|||||||
try Some (Net_id.Table.find active_nets net_id)
|
try Some (Net_id.Table.find active_nets net_id)
|
||||||
with Not_found -> None
|
with Not_found -> None
|
||||||
|
|
||||||
|
let disconnect { global_db = { p2p } } peer_id =
|
||||||
|
match P2p.find_connection p2p peer_id with
|
||||||
|
| None -> Lwt.return_unit
|
||||||
|
| Some conn -> P2p.disconnect p2p conn
|
||||||
|
|
||||||
let shutdown { p2p ; p2p_readers ; active_nets } =
|
let shutdown { p2p ; p2p_readers ; active_nets } =
|
||||||
P2p.Peer_id.Table.fold
|
P2p.Peer_id.Table.fold
|
||||||
(fun _peer_id reader acc ->
|
(fun _peer_id reader acc ->
|
||||||
|
@ -32,6 +32,8 @@ val activate: t -> State.Net.t -> net_db
|
|||||||
val set_callback: net_db -> callback -> unit
|
val set_callback: net_db -> callback -> unit
|
||||||
val deactivate: net_db -> unit Lwt.t
|
val deactivate: net_db -> unit Lwt.t
|
||||||
|
|
||||||
|
val disconnect: net_db -> P2p.Peer_id.t -> unit Lwt.t
|
||||||
|
|
||||||
val broadcast_head:
|
val broadcast_head:
|
||||||
net_db -> Block_hash.t -> Operation_hash.t list -> unit
|
net_db -> Block_hash.t -> Operation_hash.t list -> unit
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user