nodes: RwLock<BTreeMap<PublicKey, NodeInfo>>,
}
+impl Clone for NetworkGraph {
+ fn clone(&self) -> Self {
+ let channels = self.channels.read().unwrap();
+ let nodes = self.nodes.read().unwrap();
+ Self {
+ genesis_hash: self.genesis_hash.clone(),
+ channels: RwLock::new(channels.clone()),
+ nodes: RwLock::new(nodes.clone()),
+ }
+ }
+}
+
/// A read-only view of [`NetworkGraph`].
pub struct ReadOnlyNetworkGraph<'a> {
channels: RwLockReadGuard<'a, BTreeMap<u64, ChannelInfo>>,
impl<C: Deref, L: Deref> EventHandler for NetGraphMsgHandler<C, L>
where C::Target: chain::Access, L::Target: Logger {
fn handle_event(&self, event: &Event) {
- if let Event::PaymentFailed { payment_hash: _, rejected_by_dest: _, network_update, .. } = event {
+ if let Event::PaymentPathFailed { payment_hash: _, rejected_by_dest: _, network_update, .. } = event {
if let Some(network_update) = network_update {
self.handle_network_update(network_update);
}
/// Provides interface to help with initial routing sync by
/// serving historical announcements.
///
-/// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentFailed`] to the
+/// Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
/// [`NetworkGraph`].
pub struct NetGraphMsgHandler<C: Deref, L: Deref>
where C::Target: chain::Access, L::Target: Logger
assert!(network_graph.read_only().channels().get(&short_channel_id).unwrap().one_to_two.is_none());
- net_graph_msg_handler.handle_event(&Event::PaymentFailed {
+ net_graph_msg_handler.handle_event(&Event::PaymentPathFailed {
payment_hash: PaymentHash([0; 32]),
rejected_by_dest: false,
all_paths_failed: true,
+ path: vec![],
network_update: Some(NetworkUpdate::ChannelUpdateMessage {
msg: valid_channel_update,
}),
}
};
- net_graph_msg_handler.handle_event(&Event::PaymentFailed {
+ net_graph_msg_handler.handle_event(&Event::PaymentPathFailed {
payment_hash: PaymentHash([0; 32]),
rejected_by_dest: false,
all_paths_failed: true,
+ path: vec![],
network_update: Some(NetworkUpdate::ChannelClosed {
short_channel_id,
is_permanent: false,
// Permanent closing deletes a channel
{
- net_graph_msg_handler.handle_event(&Event::PaymentFailed {
+ net_graph_msg_handler.handle_event(&Event::PaymentPathFailed {
payment_hash: PaymentHash([0; 32]),
rejected_by_dest: false,
all_paths_failed: true,
+ path: vec![],
network_update: Some(NetworkUpdate::ChannelClosed {
short_channel_id,
is_permanent: true,