Move network_graph.rs to gossip.rs

The routing::network_graph module contains a few structs related to p2p
gossip. So renaming the module to 'gossip' seems more appropriate.
This commit is contained in:
Jeffrey Czyz 2022-06-02 12:53:34 -07:00
parent ac35492877
commit 574870e9f8
No known key found for this signature in database
GPG Key ID: 3A4E08275D5E96D2
24 changed files with 43 additions and 43 deletions

View File

@ -37,7 +37,7 @@ use lightning::ln::channelmanager::{ChainParameters, ChannelManager};
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
use lightning::ln::msgs::DecodeError;
use lightning::ln::script::ShutdownScript;
use lightning::routing::network_graph::{P2PGossipSync, NetworkGraph};
use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
use lightning::routing::router::{find_route, PaymentParameters, RouteParameters};
use lightning::routing::scoring::FixedPenaltyScorer;
use lightning::util::config::UserConfig;

View File

@ -5,7 +5,7 @@ use utils::test_logger;
/// Actual fuzz test, method signature and name are fixed
fn do_test(data: &[u8]) {
let block_hash = bitcoin::BlockHash::default();
let network_graph = lightning::routing::network_graph::NetworkGraph::new(block_hash);
let network_graph = lightning::routing::gossip::NetworkGraph::new(block_hash);
let rapid_sync = RapidGossipSync::new(&network_graph);
let _ = rapid_sync.update_network_graph(data);
}

View File

@ -16,11 +16,11 @@ use lightning::chain::transaction::OutPoint;
use lightning::ln::channelmanager::{ChannelDetails, ChannelCounterparty};
use lightning::ln::features::InitFeatures;
use lightning::ln::msgs;
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
use lightning::routing::router::{find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
use lightning::routing::scoring::FixedPenaltyScorer;
use lightning::util::logger::Logger;
use lightning::util::ser::Readable;
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
use bitcoin::hashes::Hash;
use bitcoin::secp256k1::PublicKey;

View File

@ -18,7 +18,7 @@ use lightning::chain::keysinterface::{Sign, KeysInterface};
use lightning::ln::channelmanager::ChannelManager;
use lightning::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler};
use lightning::ln::peer_handler::{CustomMessageHandler, PeerManager, SocketDescriptor};
use lightning::routing::network_graph::{NetworkGraph, P2PGossipSync};
use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
use lightning::routing::scoring::WriteableScore;
use lightning::util::events::{Event, EventHandler, EventsProvider};
use lightning::util::logger::Logger;
@ -162,8 +162,8 @@ impl BackgroundProcessor {
/// [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
/// [`Persister::persist_manager`]: lightning::util::persist::Persister::persist_manager
/// [`Persister::persist_graph`]: lightning::util::persist::Persister::persist_graph
/// [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph
/// [`NetworkGraph::write`]: lightning::routing::network_graph::NetworkGraph#impl-Writeable
/// [`NetworkGraph`]: lightning::routing::gossip::NetworkGraph
/// [`NetworkGraph::write`]: lightning::routing::gossip::NetworkGraph#impl-Writeable
pub fn start<
'a,
Signer: 'static + Sign,
@ -408,7 +408,7 @@ mod tests {
use lightning::ln::features::{ChannelFeatures, InitFeatures};
use lightning::ln::msgs::{ChannelMessageHandler, Init};
use lightning::ln::peer_handler::{PeerManager, MessageHandler, SocketDescriptor, IgnoringMessageHandler};
use lightning::routing::network_graph::{NetworkGraph, P2PGossipSync};
use lightning::routing::gossip::{NetworkGraph, P2PGossipSync};
use lightning::util::config::UserConfig;
use lightning::util::events::{Event, MessageSendEventsProvider, MessageSendEvent};
use lightning::util::ser::Writeable;

View File

@ -13,7 +13,7 @@ use bitcoin_hashes::Hash;
use bitcoin_hashes::sha256;
use crate::prelude::*;
use lightning::ln::PaymentSecret;
use lightning::routing::network_graph::RoutingFees;
use lightning::routing::gossip::RoutingFees;
use lightning::routing::router::{RouteHint, RouteHintHop};
use num_traits::{CheckedAdd, CheckedMul};
@ -909,7 +909,7 @@ mod test {
#[test]
fn test_parse_route() {
use lightning::routing::network_graph::RoutingFees;
use lightning::routing::gossip::RoutingFees;
use lightning::routing::router::{RouteHint, RouteHintHop};
use ::PrivateRoute;
use bech32::FromBase32;

View File

@ -45,7 +45,7 @@ use bitcoin_hashes::sha256;
use lightning::ln::PaymentSecret;
use lightning::ln::features::InvoiceFeatures;
#[cfg(any(doc, test))]
use lightning::routing::network_graph::RoutingFees;
use lightning::routing::gossip::RoutingFees;
use lightning::routing::router::RouteHint;
use lightning::util::invoice::construct_invoice_preimage;

View File

@ -38,7 +38,7 @@
//! # use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
//! # use lightning::ln::channelmanager::{ChannelDetails, PaymentId, PaymentSendFailure};
//! # use lightning::ln::msgs::LightningError;
//! # use lightning::routing::network_graph::NodeId;
//! # use lightning::routing::gossip::NodeId;
//! # use lightning::routing::router::{Route, RouteHop, RouteParameters};
//! # use lightning::routing::scoring::{ChannelUsage, Score};
//! # use lightning::util::events::{Event, EventHandler, EventsProvider};
@ -602,7 +602,7 @@ mod tests {
use lightning::ln::features::{ChannelFeatures, NodeFeatures, InitFeatures};
use lightning::ln::functional_test_utils::*;
use lightning::ln::msgs::{ChannelMessageHandler, ErrorAction, LightningError};
use lightning::routing::network_graph::NodeId;
use lightning::routing::gossip::NodeId;
use lightning::routing::router::{PaymentParameters, Route, RouteHop};
use lightning::routing::scoring::ChannelUsage;
use lightning::util::test_utils::TestLogger;

View File

@ -15,9 +15,9 @@ use lightning::ln::channelmanager::{ChannelDetails, ChannelManager, PaymentId, P
use lightning::ln::channelmanager::{PhantomRouteHints, MIN_CLTV_EXPIRY_DELTA};
use lightning::ln::inbound_payment::{create, create_from_hash, ExpandedKey};
use lightning::ln::msgs::LightningError;
use lightning::routing::scoring::Score;
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
use lightning::routing::router::{Route, RouteHint, RouteHintHop, RouteParameters, find_route};
use lightning::routing::scoring::Score;
use lightning::util::logger::Logger;
use secp256k1::PublicKey;
use core::ops::Deref;

View File

@ -9,8 +9,8 @@ use bitcoin_hashes::hex::FromHex;
use bitcoin_hashes::{sha256, Hash};
use bech32::u5;
use lightning::ln::PaymentSecret;
use lightning::routing::gossip::RoutingFees;
use lightning::routing::router::{RouteHint, RouteHintHop};
use lightning::routing::network_graph::RoutingFees;
use lightning_invoice::*;
use secp256k1::PublicKey;
use secp256k1::ecdsa::{RecoverableSignature, RecoveryId};

View File

@ -29,7 +29,7 @@
//! ```
//! use bitcoin::blockdata::constants::genesis_block;
//! use bitcoin::Network;
//! use lightning::routing::network_graph::NetworkGraph;
//! use lightning::routing::gossip::NetworkGraph;
//! use lightning_rapid_gossip_sync::RapidGossipSync;
//!
//! let block_hash = genesis_block(Network::Bitcoin).header.block_hash();
@ -62,7 +62,7 @@ use std::fs::File;
use std::ops::Deref;
use std::sync::atomic::{AtomicBool, Ordering};
use lightning::routing::network_graph::NetworkGraph;
use lightning::routing::gossip::NetworkGraph;
use crate::error::GraphSyncError;
@ -127,7 +127,7 @@ mod tests {
use bitcoin::Network;
use lightning::ln::msgs::DecodeError;
use lightning::routing::network_graph::NetworkGraph;
use lightning::routing::gossip::NetworkGraph;
use crate::RapidGossipSync;
#[test]
@ -253,7 +253,7 @@ pub mod bench {
use bitcoin::Network;
use lightning::ln::msgs::DecodeError;
use lightning::routing::network_graph::NetworkGraph;
use lightning::routing::gossip::NetworkGraph;
use crate::RapidGossipSync;

View File

@ -10,7 +10,7 @@ use bitcoin::secp256k1::PublicKey;
use lightning::ln::msgs::{
DecodeError, ErrorAction, LightningError, OptionalField, UnsignedChannelUpdate,
};
use lightning::routing::network_graph::NetworkGraph;
use lightning::routing::gossip::NetworkGraph;
use lightning::util::ser::{BigSize, Readable};
use crate::error::GraphSyncError;
@ -235,7 +235,7 @@ mod tests {
use bitcoin::Network;
use lightning::ln::msgs::DecodeError;
use lightning::routing::network_graph::NetworkGraph;
use lightning::routing::gossip::NetworkGraph;
use crate::error::GraphSyncError;
use crate::RapidGossipSync;

View File

@ -7567,7 +7567,7 @@ pub mod bench {
use ln::features::{InitFeatures, InvoiceFeatures};
use ln::functional_test_utils::*;
use ln::msgs::{ChannelMessageHandler, Init};
use routing::network_graph::NetworkGraph;
use routing::gossip::NetworkGraph;
use routing::router::{PaymentParameters, get_route};
use util::test_utils;
use util::config::UserConfig;

View File

@ -15,7 +15,7 @@ use chain::channelmonitor::ChannelMonitor;
use chain::transaction::OutPoint;
use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use ln::channelmanager::{ChainParameters, ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentSendFailure, PaymentId, MIN_CLTV_EXPIRY_DELTA};
use routing::network_graph::{P2PGossipSync, NetworkGraph};
use routing::gossip::{P2PGossipSync, NetworkGraph};
use routing::router::{PaymentParameters, Route, get_route};
use ln::features::{InitFeatures, InvoiceFeatures};
use ln::msgs;
@ -1506,13 +1506,13 @@ macro_rules! expect_payment_failed_conditions {
if let Some(chan_closed) = $conditions.expected_blamed_chan_closed {
match network_update {
&Some($crate::routing::network_graph::NetworkUpdate::ChannelUpdateMessage { ref msg }) if !chan_closed => {
&Some($crate::routing::gossip::NetworkUpdate::ChannelUpdateMessage { ref msg }) if !chan_closed => {
if let Some(scid) = $conditions.expected_blamed_scid {
assert_eq!(msg.contents.short_channel_id, scid);
}
assert_eq!(msg.contents.flags & 2, 0);
},
&Some($crate::routing::network_graph::NetworkUpdate::ChannelFailure { short_channel_id, is_permanent }) if chan_closed => {
&Some($crate::routing::gossip::NetworkUpdate::ChannelFailure { short_channel_id, is_permanent }) if chan_closed => {
if let Some(scid) = $conditions.expected_blamed_scid {
assert_eq!(short_channel_id, scid);
}

View File

@ -19,7 +19,7 @@
//! call into your [`P2PGossipSync`].
//!
//! [`ChannelManager`]: channelmanager::ChannelManager
//! [`P2PGossipSync`]: crate::routing::network_graph::P2PGossipSync
//! [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync
#[cfg(any(test, feature = "_test_utils"))]
#[macro_use]

View File

@ -16,7 +16,7 @@ use chain::keysinterface::{KeysInterface, Recipient};
use ln::{PaymentHash, PaymentSecret};
use ln::channelmanager::{HTLCForwardInfo, CLTV_FAR_FAR_AWAY, MIN_CLTV_EXPIRY_DELTA, PendingHTLCInfo, PendingHTLCRouting};
use ln::onion_utils;
use routing::network_graph::{NetworkUpdate, RoutingFees, NodeId};
use routing::gossip::{NetworkUpdate, RoutingFees, NodeId};
use routing::router::{get_route, PaymentParameters, Route, RouteHint, RouteHintHop};
use ln::features::{InitFeatures, InvoiceFeatures, NodeFeatures};
use ln::msgs;

View File

@ -11,7 +11,7 @@ use ln::{PaymentHash, PaymentPreimage, PaymentSecret};
use ln::channelmanager::HTLCSource;
use ln::msgs;
use ln::wire::Encode;
use routing::network_graph::NetworkUpdate;
use routing::gossip::NetworkUpdate;
use routing::router::RouteHop;
use util::chacha20::{ChaCha20, ChaChaReader};
use util::errors::{self, APIError};

View File

@ -25,10 +25,10 @@ use util::ser::{VecWriter, Writeable, Writer};
use ln::peer_channel_encryptor::{PeerChannelEncryptor,NextNoiseStep};
use ln::wire;
use ln::wire::Encode;
use routing::gossip::{NetworkGraph, P2PGossipSync};
use util::atomic_counter::AtomicCounter;
use util::events::{MessageSendEvent, MessageSendEventsProvider};
use util::logger::Logger;
use routing::network_graph::{NetworkGraph, P2PGossipSync};
use prelude::*;
use io;
@ -210,7 +210,7 @@ pub struct MessageHandler<CM: Deref, RM: Deref> where
/// A message handler which handles messages updating our knowledge of the network channel
/// graph. Usually this is just a [`P2PGossipSync`] object or an [`IgnoringMessageHandler`].
///
/// [`P2PGossipSync`]: crate::routing::network_graph::P2PGossipSync
/// [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync
pub route_handler: RM,
}

View File

@ -15,7 +15,7 @@ use chain::{ChannelMonitorUpdateErr, Watch};
use chain::channelmonitor::ChannelMonitor;
use chain::keysinterface::{Recipient, KeysInterface};
use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, MIN_CLTV_EXPIRY_DELTA};
use routing::network_graph::RoutingFees;
use routing::gossip::RoutingFees;
use routing::router::{PaymentParameters, RouteHint, RouteHintHop};
use ln::features::{InitFeatures, InvoiceFeatures};
use ln::msgs;

View File

@ -1643,7 +1643,7 @@ mod tests {
use chain;
use ln::PaymentHash;
use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
use routing::network_graph::{P2PGossipSync, NetworkGraph, NetworkUpdate, MAX_EXCESS_BYTES_FOR_RELAY};
use routing::gossip::{P2PGossipSync, NetworkGraph, NetworkUpdate, MAX_EXCESS_BYTES_FOR_RELAY};
use ln::msgs::{Init, OptionalField, RoutingMessageHandler, UnsignedNodeAnnouncement, NodeAnnouncement,
UnsignedChannelAnnouncement, ChannelAnnouncement, UnsignedChannelUpdate, ChannelUpdate,
ReplyChannelRange, QueryChannelRange, QueryShortChannelIds, MAX_VALUE_MSAT};

View File

@ -9,6 +9,6 @@
//! Structs and impls for receiving messages about the network and storing the topology live here.
pub mod network_graph;
pub mod gossip;
pub mod router;
pub mod scoring;

View File

@ -17,8 +17,8 @@ use bitcoin::secp256k1::PublicKey;
use ln::channelmanager::ChannelDetails;
use ln::features::{ChannelFeatures, InvoiceFeatures, NodeFeatures};
use ln::msgs::{DecodeError, ErrorAction, LightningError, MAX_VALUE_MSAT};
use routing::gossip::{DirectedChannelInfoWithUpdate, EffectiveCapacity, NetworkGraph, ReadOnlyNetworkGraph, NodeId, RoutingFees};
use routing::scoring::{ChannelUsage, Score};
use routing::network_graph::{DirectedChannelInfoWithUpdate, EffectiveCapacity, NetworkGraph, ReadOnlyNetworkGraph, NodeId, RoutingFees};
use util::ser::{Writeable, Readable, Writer};
use util::logger::{Level, Logger};
use util::chacha20::ChaCha20;
@ -1858,7 +1858,7 @@ fn build_route_from_hops_internal<L: Deref>(
#[cfg(test)]
mod tests {
use routing::network_graph::{NetworkGraph, P2PGossipSync, NodeId};
use routing::gossip::{NetworkGraph, P2PGossipSync, NodeId};
use routing::router::{get_route, build_route_from_hops_internal, add_random_cltv_offset, default_node_features,
PaymentParameters, Route, RouteHint, RouteHintHop, RouteHop, RoutingFees,
DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA, MAX_PATH_LENGTH_ESTIMATE};

View File

@ -17,7 +17,7 @@
//! ```
//! # extern crate bitcoin;
//! #
//! # use lightning::routing::network_graph::NetworkGraph;
//! # use lightning::routing::gossip::NetworkGraph;
//! # use lightning::routing::router::{RouteParameters, find_route};
//! # use lightning::routing::scoring::{ProbabilisticScorer, ProbabilisticScoringParameters};
//! # use lightning::chain::keysinterface::{KeysManager, KeysInterface};
@ -55,7 +55,7 @@
//! [`find_route`]: crate::routing::router::find_route
use ln::msgs::DecodeError;
use routing::network_graph::{EffectiveCapacity, NetworkGraph, NodeId};
use routing::gossip::{EffectiveCapacity, NetworkGraph, NodeId};
use routing::router::RouteHop;
use util::ser::{Readable, ReadableArgs, Writeable, Writer};
use util::logger::Logger;
@ -1120,9 +1120,9 @@ mod tests {
use ln::features::{ChannelFeatures, NodeFeatures};
use ln::msgs::{ChannelAnnouncement, ChannelUpdate, OptionalField, UnsignedChannelAnnouncement, UnsignedChannelUpdate};
use routing::scoring::{ChannelUsage, Score};
use routing::network_graph::{EffectiveCapacity, NetworkGraph, NodeId};
use routing::gossip::{EffectiveCapacity, NetworkGraph, NodeId};
use routing::router::RouteHop;
use routing::scoring::{ChannelUsage, Score};
use util::ser::{ReadableArgs, Writeable};
use util::test_utils::TestLogger;

View File

@ -21,7 +21,7 @@ use ln::features::ChannelTypeFeatures;
use ln::msgs;
use ln::msgs::DecodeError;
use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
use routing::network_graph::NetworkUpdate;
use routing::gossip::NetworkUpdate;
use util::ser::{BigSize, FixedLengthReader, Writeable, Writer, MaybeReadable, Readable, VecReadWrapper, VecWriteWrapper};
use routing::router::{RouteHop, RouteParameters};
@ -339,8 +339,8 @@ pub enum Event {
/// Should be applied to the [`NetworkGraph`] so that routing decisions can take into
/// account the update. [`P2PGossipSync`] is capable of doing this.
///
/// [`NetworkGraph`]: crate::routing::network_graph::NetworkGraph
/// [`P2PGossipSync`]: crate::routing::network_graph::P2PGossipSync
/// [`NetworkGraph`]: crate::routing::gossip::NetworkGraph
/// [`P2PGossipSync`]: crate::routing::gossip::P2PGossipSync
network_update: Option<NetworkUpdate>,
/// For both single-path and multi-path payments, this is set if all paths of the payment have
/// failed. This will be set to false if (1) this is an MPP payment and (2) other parts of the

View File

@ -13,7 +13,7 @@ use bitcoin::hashes::hex::ToHex;
use io::{self};
use routing::scoring::WriteableScore;
use crate::{chain::{keysinterface::{Sign, KeysInterface}, self, transaction::{OutPoint}, chaininterface::{BroadcasterInterface, FeeEstimator}, chainmonitor::{Persist, MonitorUpdateId}, channelmonitor::{ChannelMonitor, ChannelMonitorUpdate}}, ln::channelmanager::ChannelManager, routing::network_graph::NetworkGraph};
use crate::{chain::{keysinterface::{Sign, KeysInterface}, self, transaction::{OutPoint}, chaininterface::{BroadcasterInterface, FeeEstimator}, chainmonitor::{Persist, MonitorUpdateId}, channelmonitor::{ChannelMonitor, ChannelMonitorUpdate}}, ln::channelmanager::ChannelManager, routing::gossip::NetworkGraph};
use super::{logger::Logger, ser::Writeable};
/// Trait for a key-value store for persisting some writeable object at some key