Shell: minor doc improvement in RPC.
This commit is contained in:
parent
bda80bf613
commit
69ebe7d0cc
@ -454,7 +454,7 @@ module RPC = struct
|
|||||||
|
|
||||||
type info = {
|
type info = {
|
||||||
trusted : bool ;
|
trusted : bool ;
|
||||||
greylisted_end : Time.t ;
|
greylisted_until : Time.t ;
|
||||||
state : state ;
|
state : state ;
|
||||||
peer_id : Peer_id.t option ;
|
peer_id : Peer_id.t option ;
|
||||||
last_failed_connection : Time.t option ;
|
last_failed_connection : Time.t option ;
|
||||||
@ -468,21 +468,21 @@ module RPC = struct
|
|||||||
let info_encoding =
|
let info_encoding =
|
||||||
let open Data_encoding in
|
let open Data_encoding in
|
||||||
conv
|
conv
|
||||||
(fun { trusted ; greylisted_end ; state ; peer_id ;
|
(fun { trusted ; greylisted_until ; state ; peer_id ;
|
||||||
last_failed_connection ; last_rejected_connection ;
|
last_failed_connection ; last_rejected_connection ;
|
||||||
last_established_connection ; last_disconnection ;
|
last_established_connection ; last_disconnection ;
|
||||||
last_seen ; last_miss ;
|
last_seen ; last_miss ;
|
||||||
} ->
|
} ->
|
||||||
(trusted, greylisted_end, state, peer_id,
|
(trusted, greylisted_until, state, peer_id,
|
||||||
last_failed_connection, last_rejected_connection,
|
last_failed_connection, last_rejected_connection,
|
||||||
last_established_connection, last_disconnection,
|
last_established_connection, last_disconnection,
|
||||||
last_seen, last_miss)
|
last_seen, last_miss)
|
||||||
)
|
)
|
||||||
(fun (trusted, greylisted_end, state, peer_id,
|
(fun (trusted, greylisted_until, state, peer_id,
|
||||||
last_failed_connection, last_rejected_connection,
|
last_failed_connection, last_rejected_connection,
|
||||||
last_established_connection, last_disconnection,
|
last_established_connection, last_disconnection,
|
||||||
last_seen, last_miss) ->
|
last_seen, last_miss) ->
|
||||||
{ trusted ; greylisted_end ; state ; peer_id ;
|
{ trusted ; greylisted_until ; state ; peer_id ;
|
||||||
last_failed_connection ; last_rejected_connection ;
|
last_failed_connection ; last_rejected_connection ;
|
||||||
last_established_connection ; last_disconnection ;
|
last_established_connection ; last_disconnection ;
|
||||||
last_seen ; last_miss ;
|
last_seen ; last_miss ;
|
||||||
@ -490,7 +490,7 @@ module RPC = struct
|
|||||||
)
|
)
|
||||||
(obj10
|
(obj10
|
||||||
(req "trusted" bool)
|
(req "trusted" bool)
|
||||||
(dft "greylisted_end" Time.encoding Time.epoch)
|
(dft "greylisted_until" Time.encoding Time.epoch)
|
||||||
(req "state" state_encoding)
|
(req "state" state_encoding)
|
||||||
(opt "peer_id" Peer_id.encoding)
|
(opt "peer_id" Peer_id.encoding)
|
||||||
(opt "last_failed_connection" Time.encoding)
|
(opt "last_failed_connection" Time.encoding)
|
||||||
@ -511,7 +511,7 @@ module RPC = struct
|
|||||||
Point_info.{
|
Point_info.{
|
||||||
trusted = trusted i ;
|
trusted = trusted i ;
|
||||||
state ; peer_id ;
|
state ; peer_id ;
|
||||||
greylisted_end = greylisted_end i ;
|
greylisted_until = greylisted_until i ;
|
||||||
last_failed_connection = last_failed_connection i ;
|
last_failed_connection = last_failed_connection i ;
|
||||||
last_rejected_connection = last_rejected_connection i ;
|
last_rejected_connection = last_rejected_connection i ;
|
||||||
last_established_connection = last_established_connection i ;
|
last_established_connection = last_established_connection i ;
|
||||||
@ -621,7 +621,7 @@ module RPC = struct
|
|||||||
(req "score" float)
|
(req "score" float)
|
||||||
(req "trusted" bool)
|
(req "trusted" bool)
|
||||||
(req "state" state_encoding)
|
(req "state" state_encoding)
|
||||||
(opt "id_point" Id_point.encoding)
|
(opt "reachable_at" Id_point.encoding)
|
||||||
(req "stat" Stat.encoding))
|
(req "stat" Stat.encoding))
|
||||||
(obj6
|
(obj6
|
||||||
(opt "last_failed_connection" (tup2 Id_point.encoding Time.encoding))
|
(opt "last_failed_connection" (tup2 Id_point.encoding Time.encoding))
|
||||||
|
@ -217,7 +217,7 @@ module RPC : sig
|
|||||||
|
|
||||||
type info = {
|
type info = {
|
||||||
trusted : bool ;
|
trusted : bool ;
|
||||||
greylisted_end : Time.t ;
|
greylisted_until : Time.t ;
|
||||||
state : state ;
|
state : state ;
|
||||||
peer_id : Peer_id.t option ;
|
peer_id : Peer_id.t option ;
|
||||||
last_failed_connection : Time.t option ;
|
last_failed_connection : Time.t option ;
|
||||||
|
@ -201,9 +201,9 @@ module LogEvent : sig
|
|||||||
(** The connection was closed for external reason. *)
|
(** The connection was closed for external reason. *)
|
||||||
|
|
||||||
| Gc_points
|
| Gc_points
|
||||||
(** Garbage correction of known point table has been triggered. *)
|
(** Garbage collection of known point table has been triggered. *)
|
||||||
| Gc_peer_ids
|
| Gc_peer_ids
|
||||||
(** Garbage correction of known peer_ids table has been triggered. *)
|
(** Garbage collection of known peer_ids table has been triggered. *)
|
||||||
|
|
||||||
val encoding : t Data_encoding.t
|
val encoding : t Data_encoding.t
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ module Point_info = struct
|
|||||||
let branch_encoding name obj =
|
let branch_encoding name obj =
|
||||||
conv (fun x -> (), x) (fun ((), x) -> x)
|
conv (fun x -> (), x) (fun ((), x) -> x)
|
||||||
(merge_objs
|
(merge_objs
|
||||||
(obj1 (req "event" (constant name))) obj) in
|
(obj1 (req "event_kind" (constant name))) obj) in
|
||||||
union ~tag_size:`Uint8 [
|
union ~tag_size:`Uint8 [
|
||||||
case ~tag:0 (branch_encoding "outgoing_request" empty)
|
case ~tag:0 (branch_encoding "outgoing_request" empty)
|
||||||
(function Outgoing_request -> Some () | _ -> None)
|
(function Outgoing_request -> Some () | _ -> None)
|
||||||
@ -140,7 +140,7 @@ module Point_info = struct
|
|||||||
let last_rejected_connection s = s.last_rejected_connection
|
let last_rejected_connection s = s.last_rejected_connection
|
||||||
let greylisted ?(now = Time.now ()) s =
|
let greylisted ?(now = Time.now ()) s =
|
||||||
Time.compare now s.greylisting_end <= 0
|
Time.compare now s.greylisting_end <= 0
|
||||||
let greylisted_end s = s.greylisting_end
|
let greylisted_until s = s.greylisting_end
|
||||||
|
|
||||||
let recent a1 a2 =
|
let recent a1 a2 =
|
||||||
match a1, a2 with
|
match a1, a2 with
|
||||||
|
@ -68,7 +68,7 @@ module Point_info : sig
|
|||||||
val greylisted :
|
val greylisted :
|
||||||
?now:Time.t -> 'conn point_info -> bool
|
?now:Time.t -> 'conn point_info -> bool
|
||||||
|
|
||||||
val greylisted_end : 'conn point_info -> Time.t
|
val greylisted_until : 'conn point_info -> Time.t
|
||||||
|
|
||||||
val point : 'conn point_info -> Point.t
|
val point : 'conn point_info -> Point.t
|
||||||
|
|
||||||
|
@ -485,7 +485,9 @@ module Protocols = struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Network = struct
|
module Network = struct
|
||||||
|
|
||||||
open P2p_types
|
open P2p_types
|
||||||
|
|
||||||
let (peer_id_arg : P2p_types.Peer_id.t RPC.Arg.arg) =
|
let (peer_id_arg : P2p_types.Peer_id.t RPC.Arg.arg) =
|
||||||
RPC.Arg.make
|
RPC.Arg.make
|
||||||
~name:"peer_id"
|
~name:"peer_id"
|
||||||
@ -528,8 +530,10 @@ module Network = struct
|
|||||||
let monitor_encoding = obj1 (dft "monitor" bool false)
|
let monitor_encoding = obj1 (dft "monitor" bool false)
|
||||||
|
|
||||||
module Connection = struct
|
module Connection = struct
|
||||||
|
|
||||||
let list =
|
let list =
|
||||||
RPC.service
|
RPC.service
|
||||||
|
~description:"List the running P2P connection."
|
||||||
~input: empty
|
~input: empty
|
||||||
~output: (list P2p.Connection_info.encoding)
|
~output: (list P2p.Connection_info.encoding)
|
||||||
RPC.Path.(root / "network" / "connection")
|
RPC.Path.(root / "network" / "connection")
|
||||||
@ -538,58 +542,73 @@ module Network = struct
|
|||||||
RPC.service
|
RPC.service
|
||||||
~input: empty
|
~input: empty
|
||||||
~output: (option P2p.Connection_info.encoding)
|
~output: (option P2p.Connection_info.encoding)
|
||||||
|
~description:"Details about the current P2P connection to the given peer."
|
||||||
RPC.Path.(root / "network" / "connection" /: peer_id_arg)
|
RPC.Path.(root / "network" / "connection" /: peer_id_arg)
|
||||||
|
|
||||||
let kick =
|
let kick =
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: (obj1 (req "wait" bool))
|
~input: (obj1 (req "wait" bool))
|
||||||
~output: empty
|
~output: empty
|
||||||
|
~description:"Forced close of the current P2P connection to the given peer."
|
||||||
RPC.Path.(root / "network" / "connection" /: peer_id_arg / "kick")
|
RPC.Path.(root / "network" / "connection" /: peer_id_arg / "kick")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Point = struct
|
module Point = struct
|
||||||
|
|
||||||
let infos =
|
let infos =
|
||||||
let filter =
|
let filter =
|
||||||
obj1 (dft "filter" (list P2p.RPC.Point.state_encoding) []) in
|
obj1 (dft "filter" (list P2p.RPC.Point.state_encoding) []) in
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: filter
|
~input: filter
|
||||||
~output: (list (tup2 P2p.Point.encoding P2p.RPC.Point.info_encoding))
|
~output: (list (tup2 P2p.Point.encoding P2p.RPC.Point.info_encoding))
|
||||||
|
~description:"List the pool of known `IP:port` \
|
||||||
|
used for establishing P2P connections ."
|
||||||
RPC.Path.(root / "network" / "point")
|
RPC.Path.(root / "network" / "point")
|
||||||
|
|
||||||
let info =
|
let info =
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: empty
|
~input: empty
|
||||||
~output: (option P2p.RPC.Point.info_encoding)
|
~output: (option P2p.RPC.Point.info_encoding)
|
||||||
|
~description: "Details about a given `IP:addr`."
|
||||||
RPC.Path.(root / "network" / "point" /: point_arg)
|
RPC.Path.(root / "network" / "point" /: point_arg)
|
||||||
|
|
||||||
let events =
|
let events =
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: monitor_encoding
|
~input: monitor_encoding
|
||||||
~output: (list P2p.RPC.Point.Event.encoding)
|
~output: (list P2p.RPC.Point.Event.encoding)
|
||||||
|
~description: "Monitor network events related to an `IP:addr`."
|
||||||
RPC.Path.(root / "network" / "point" /: point_arg / "log")
|
RPC.Path.(root / "network" / "point" /: point_arg / "log")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Peer_id = struct
|
module Peer_id = struct
|
||||||
|
|
||||||
let infos =
|
let infos =
|
||||||
let filter =
|
let filter =
|
||||||
obj1 (dft "filter" (list P2p.RPC.Peer_id.state_encoding) []) in
|
obj1 (dft "filter" (list P2p.RPC.Peer_id.state_encoding) []) in
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: filter
|
~input: filter
|
||||||
~output: (list (tup2 P2p.Peer_id.encoding P2p.RPC.Peer_id.info_encoding))
|
~output: (list (tup2 P2p.Peer_id.encoding P2p.RPC.Peer_id.info_encoding))
|
||||||
|
~description:"List the peers the node ever met."
|
||||||
RPC.Path.(root / "network" / "peer_id")
|
RPC.Path.(root / "network" / "peer_id")
|
||||||
|
|
||||||
let info =
|
let info =
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: empty
|
~input: empty
|
||||||
~output: (option P2p.RPC.Peer_id.info_encoding)
|
~output: (option P2p.RPC.Peer_id.info_encoding)
|
||||||
|
~description:"Details about a given peer."
|
||||||
RPC.Path.(root / "network" / "peer_id" /: peer_id_arg)
|
RPC.Path.(root / "network" / "peer_id" /: peer_id_arg)
|
||||||
|
|
||||||
let events =
|
let events =
|
||||||
RPC.service
|
RPC.service
|
||||||
~input: monitor_encoding
|
~input: monitor_encoding
|
||||||
~output: (list P2p.RPC.Peer_id.Event.encoding)
|
~output: (list P2p.RPC.Peer_id.Event.encoding)
|
||||||
|
~description:"Monitor network events related to a given peer."
|
||||||
RPC.Path.(root / "network" / "peer_id" /: peer_id_arg / "log")
|
RPC.Path.(root / "network" / "peer_id" /: peer_id_arg / "log")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let forge_block =
|
let forge_block =
|
||||||
|
Loading…
Reference in New Issue
Block a user