Skip to content

Commit 0017bc8

Browse files
authored
Merge pull request #1159 from jkczyz/2021-11-network-gossip
Rename network-related types
2 parents ab20284 + 574870e commit 0017bc8

27 files changed

+438
-432
lines changed

ARCH.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ receive `ChannelMonitorUpdate`s from `ChannelManager` and persist them to disk b
1111
channel steps forward.
1212

1313
There are two additional important structures that you may use either on the same device
14-
as the `ChannelManager` or on a separate one. `NetGraphMsgHandler` handles receiving channel
15-
and node announcements, which are then used to calculate routes by `get_route` for sending payments.
16-
`PeerManager` handles the authenticated and encrypted communication protocol,
17-
monitoring for liveness of peers, routing messages to `ChannelManager` and `NetGraphMsgHandler`
14+
as the `ChannelManager` or on a separate one. `P2PGossipSync` handles receiving channel
15+
and node announcements, which are then used to calculate routes by `find_route` for sending
16+
payments. `PeerManager` handles the authenticated and encrypted communication protocol,
17+
monitoring for liveness of peers, routing messages to `ChannelManager` and `P2PGossipSync`
1818
instances directly, and receiving messages from them via the `EventsProvider` interface.
1919

2020
These structs communicate with each other using a public API, so that you can easily add
@@ -56,7 +56,7 @@ At a high level, some of the common interfaces fit together as follows:
5656
| ----------------- \ / ----------------
5757
| ^ \ / |
5858
(as RoutingMessageHandler) | v v
59-
\ ---------------------- --------- -----------------
60-
-----------------> | NetGraphMsgHandler | | Event | | chain::Filter |
61-
---------------------- --------- -----------------
59+
\ ----------------- --------- -----------------
60+
-----------------> | P2PGossipSync | | Event | | chain::Filter |
61+
----------------- --------- -----------------
6262
```

fuzz/src/full_stack.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use lightning::ln::channelmanager::{ChainParameters, ChannelManager};
3737
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
3838
use lightning::ln::msgs::DecodeError;
3939
use lightning::ln::script::ShutdownScript;
40-
use lightning::routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
40+
use lightning::routing::gossip::{P2PGossipSync, NetworkGraph};
4141
use lightning::routing::router::{find_route, PaymentParameters, RouteParameters};
4242
use lightning::routing::scoring::FixedPenaltyScorer;
4343
use lightning::util::config::UserConfig;
@@ -163,7 +163,7 @@ type ChannelMan = ChannelManager<
163163
EnforcingSigner,
164164
Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
165165
Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>, Arc<dyn Logger>>;
166-
type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<NetGraphMsgHandler<Arc<NetworkGraph>, Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>, IgnoringMessageHandler>;
166+
type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<P2PGossipSync<Arc<NetworkGraph>, Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>, IgnoringMessageHandler>;
167167

168168
struct MoneyLossDetector<'a> {
169169
manager: Arc<ChannelMan>,
@@ -396,13 +396,13 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
396396
keys_manager.counter.fetch_sub(1, Ordering::AcqRel);
397397
let our_id = PublicKey::from_secret_key(&Secp256k1::signing_only(), &keys_manager.get_node_secret(Recipient::Node).unwrap());
398398
let network_graph = Arc::new(NetworkGraph::new(genesis_block(network).block_hash()));
399-
let net_graph_msg_handler = Arc::new(NetGraphMsgHandler::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
399+
let gossip_sync = Arc::new(P2PGossipSync::new(Arc::clone(&network_graph), None, Arc::clone(&logger)));
400400
let scorer = FixedPenaltyScorer::with_penalty(0);
401401

402402
let peers = RefCell::new([false; 256]);
403403
let mut loss_detector = MoneyLossDetector::new(&peers, channelmanager.clone(), monitor.clone(), PeerManager::new(MessageHandler {
404404
chan_handler: channelmanager.clone(),
405-
route_handler: net_graph_msg_handler.clone(),
405+
route_handler: gossip_sync.clone(),
406406
}, our_network_key, &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0], Arc::clone(&logger), IgnoringMessageHandler{}));
407407

408408
let mut should_forward = false;

fuzz/src/process_network_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use utils::test_logger;
55
/// Actual fuzz test, method signature and name are fixed
66
fn do_test(data: &[u8]) {
77
let block_hash = bitcoin::BlockHash::default();
8-
let network_graph = lightning::routing::network_graph::NetworkGraph::new(block_hash);
8+
let network_graph = lightning::routing::gossip::NetworkGraph::new(block_hash);
99
let rapid_sync = RapidGossipSync::new(&network_graph);
1010
let _ = rapid_sync.update_network_graph(data);
1111
}

fuzz/src/router.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use lightning::chain::transaction::OutPoint;
1616
use lightning::ln::channelmanager::{ChannelDetails, ChannelCounterparty};
1717
use lightning::ln::features::InitFeatures;
1818
use lightning::ln::msgs;
19+
use lightning::routing::gossip::{NetworkGraph, RoutingFees};
1920
use lightning::routing::router::{find_route, PaymentParameters, RouteHint, RouteHintHop, RouteParameters};
2021
use lightning::routing::scoring::FixedPenaltyScorer;
2122
use lightning::util::logger::Logger;
2223
use lightning::util::ser::Readable;
23-
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
2424

2525
use bitcoin::hashes::Hash;
2626
use bitcoin::secp256k1::PublicKey;
@@ -196,7 +196,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
196196
},
197197
4 => {
198198
let short_channel_id = slice_to_be64(get_slice!(8));
199-
net_graph.close_channel_from_update(short_channel_id, false);
199+
net_graph.channel_failed(short_channel_id, false);
200200
},
201201
_ if node_pks.is_empty() => {},
202202
_ => {

0 commit comments

Comments
 (0)