pub struct ChannelGraph {
pub(crate) me: OffchainPublicKey,
pub(crate) edge_penalty: f64,
pub(crate) min_ack_rate: f64,
pub(crate) inner: Arc<RwLock<InnerGraph>>,
}Expand description
A directed graph representing logical channels between nodes.
The graph is directed, with nodes representing the physical nodes in the network using
their [OffchainPublicKey] as identifier and edges representing the logical channels
between them. Each logical channel aggregates different weighted properties, like
channel capacity (calculated from the on-chain channel balance, ticket price and ticket probability)
and evaluated transport network properties between the nodes.
Interior mutability is provided via an internal [RwLock] so that all trait
methods (which take &self) can safely read and write the graph. In production
code, the graph is expected to be shared behind an Arc<ChannelGraph>.
Fields§
§me: OffchainPublicKey§edge_penalty: f64§min_ack_rate: f64§inner: Arc<RwLock<InnerGraph>>Implementations§
Source§impl ChannelGraph
impl ChannelGraph
Sourcepub fn new(me: OffchainPublicKey) -> Self
pub fn new(me: OffchainPublicKey) -> Self
Creates a new channel graph with the given self identity and default edge scoring parameters (edge_penalty = 0.5, min_ack_rate = 0.1).
The me key represents the local node which is automatically added
to the graph as the first node.
Production code should prefer with_edge_params to
receive values from PathPlannerConfig.
Sourcepub fn with_edge_params(
me: OffchainPublicKey,
edge_penalty: f64,
min_ack_rate: f64,
) -> Self
pub fn with_edge_params( me: OffchainPublicKey, edge_penalty: f64, min_ack_rate: f64, ) -> Self
Creates a new channel graph with custom edge scoring parameters.
me– offchain public key of the local node (added as the first graph node).edge_penalty– penalty multiplier for edges lacking probe-based quality observations.min_ack_rate– minimum acceptable message acknowledgment rate for path selection.
Trait Implementations§
Source§impl Clone for ChannelGraph
impl Clone for ChannelGraph
Source§fn clone(&self) -> ChannelGraph
fn clone(&self) -> ChannelGraph
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelGraph
impl Debug for ChannelGraph
Source§impl NetworkGraphConnectivity for ChannelGraph
impl NetworkGraphConnectivity for ChannelGraph
Source§type Observed = Observations
type Observed = Observations
Source§fn connected_edges(
&self,
) -> Vec<(OffchainPublicKey, OffchainPublicKey, Observations)>
fn connected_edges( &self, ) -> Vec<(OffchainPublicKey, OffchainPublicKey, Observations)>
(source, destination, observations) triples. Read moreSource§fn reachable_edges(
&self,
) -> Vec<(OffchainPublicKey, OffchainPublicKey, Observations)>
fn reachable_edges( &self, ) -> Vec<(OffchainPublicKey, OffchainPublicKey, Observations)>
Source§impl NetworkGraphTraverse for ChannelGraph
impl NetworkGraphTraverse for ChannelGraph
Source§type Observed = Observations
type Observed = Observations
Source§fn simple_paths<C: ValueFn<Weight = Self::Observed>>(
&self,
source: &Self::NodeId,
destination: &Self::NodeId,
length: usize,
take_count: Option<usize>,
value_fn: C,
) -> Vec<(Vec<Self::NodeId>, PathId, C::Value)>
fn simple_paths<C: ValueFn<Weight = Self::Observed>>( &self, source: &Self::NodeId, destination: &Self::NodeId, length: usize, take_count: Option<usize>, value_fn: C, ) -> Vec<(Vec<Self::NodeId>, PathId, C::Value)>
Source§fn simple_paths_from<C: ValueFn<Weight = Self::Observed>>(
&self,
source: &Self::NodeId,
length: usize,
take_count: Option<usize>,
value_fn: C,
) -> Vec<(Vec<Self::NodeId>, PathId, C::Value)>
fn simple_paths_from<C: ValueFn<Weight = Self::Observed>>( &self, source: &Self::NodeId, length: usize, take_count: Option<usize>, value_fn: C, ) -> Vec<(Vec<Self::NodeId>, PathId, C::Value)>
Source§impl NetworkGraphUpdate for ChannelGraph
impl NetworkGraphUpdate for ChannelGraph
Source§fn record_edge<N, P>(&self, update: MeasurableEdge<N, P>)
fn record_edge<N, P>(&self, update: MeasurableEdge<N, P>)
Source§impl NetworkGraphView for ChannelGraph
impl NetworkGraphView for ChannelGraph
Source§type Observed = Observations
type Observed = Observations
Source§fn node_count(&self) -> usize
fn node_count(&self) -> usize
Source§fn contains_node(&self, key: &OffchainPublicKey) -> bool
fn contains_node(&self, key: &OffchainPublicKey) -> bool
Source§fn nodes(&self) -> BoxStream<'static, Self::NodeId>
fn nodes(&self) -> BoxStream<'static, Self::NodeId>
Source§fn has_edge(&self, src: &OffchainPublicKey, dest: &OffchainPublicKey) -> bool
fn has_edge(&self, src: &OffchainPublicKey, dest: &OffchainPublicKey) -> bool
Source§impl NetworkGraphWrite for ChannelGraph
impl NetworkGraphWrite for ChannelGraph
Source§fn upsert_edge<F>(
&self,
src: &OffchainPublicKey,
dest: &OffchainPublicKey,
f: F,
)where
F: FnOnce(&mut Observations),
fn upsert_edge<F>(
&self,
src: &OffchainPublicKey,
dest: &OffchainPublicKey,
f: F,
)where
F: FnOnce(&mut Observations),
Mutably updates the edge observations between two nodes.
If the edge does not exist, it gets created first.
If the nodes do not exist, they are added as well.
Source§type Error = ChannelGraphError
type Error = ChannelGraphError
Source§type Observed = Observations
type Observed = Observations
Source§fn add_node(&self, key: OffchainPublicKey)
fn add_node(&self, key: OffchainPublicKey)
Source§fn remove_node(&self, key: &OffchainPublicKey)
fn remove_node(&self, key: &OffchainPublicKey)
Source§fn add_edge(
&self,
src: &OffchainPublicKey,
dest: &OffchainPublicKey,
) -> Result<(), ChannelGraphError>
fn add_edge( &self, src: &OffchainPublicKey, dest: &OffchainPublicKey, ) -> Result<(), ChannelGraphError>
Source§fn remove_edge(&self, src: &OffchainPublicKey, dest: &OffchainPublicKey)
fn remove_edge(&self, src: &OffchainPublicKey, dest: &OffchainPublicKey)
Auto Trait Implementations§
impl Freeze for ChannelGraph
impl !RefUnwindSafe for ChannelGraph
impl Send for ChannelGraph
impl Sync for ChannelGraph
impl Unpin for ChannelGraph
impl !UnwindSafe for ChannelGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, N> HoprGraphApi for Twhere
T: NetworkGraphUpdate + NetworkGraphWrite<NodeId = N> + NetworkGraphTraverse<NodeId = N> + NetworkGraphView<NodeId = N>,
N: Send,
impl<T, N> HoprGraphApi for Twhere
T: NetworkGraphUpdate + NetworkGraphWrite<NodeId = N> + NetworkGraphTraverse<NodeId = N> + NetworkGraphView<NodeId = N>,
N: Send,
type HoprNodeId = N
§impl<T, N> HoprGraphReadApi for Twhere
T: NetworkGraphView<NodeId = N> + NetworkGraphTraverse<NodeId = N>,
N: Send,
impl<T, N> HoprGraphReadApi for Twhere
T: NetworkGraphView<NodeId = N> + NetworkGraphTraverse<NodeId = N>,
N: Send,
type HoprNodeId = N
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more