Skip to content

Commit ec8984e

Browse files
committed
Remove NetGraphMsgHandler serialization
1 parent abac0b7 commit ec8984e

File tree

2 files changed

+1
-78
lines changed

2 files changed

+1
-78
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use chain::keysinterface::KeysInterface;
77
use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSecret, PaymentSendFailure};
88
use ln::channelmonitor::{ChannelMonitor, ManyChannelMonitor};
99
use routing::router::{Route, get_route};
10-
use routing::network_graph::{NetGraphMsgHandler, NetGraphMsgHandlerReadArgs};
10+
use routing::network_graph::{NetGraphMsgHandler};
1111
use ln::features::InitFeatures;
1212
use ln::msgs;
1313
use ln::msgs::{ChannelMessageHandler,RoutingMessageHandler};
@@ -99,36 +99,6 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
9999
assert!(self.node.get_and_clear_pending_events().is_empty());
100100
assert!(self.chan_monitor.added_monitors.lock().unwrap().is_empty());
101101

102-
// Check that if we serialize the Router, we can deserialize it again.
103-
{
104-
let mut w = test_utils::TestVecWriter(Vec::new());
105-
self.net_graph_msg_handler.write(&mut w).unwrap();
106-
let net_graph_msg_handler = NetGraphMsgHandler::read(&mut ::std::io::Cursor::new(&w.0), NetGraphMsgHandlerReadArgs {
107-
chain_monitor: Arc::clone(&self.chain_monitor) as Arc<chaininterface::ChainWatchInterface>,
108-
logger: Arc::clone(&self.logger) as Arc<Logger>
109-
}).unwrap();
110-
let mut chan_progress = 0;
111-
loop {
112-
let orig_announcements = self.net_graph_msg_handler.get_next_channel_announcements(chan_progress, 255);
113-
let deserialized_announcements = net_graph_msg_handler.get_next_channel_announcements(chan_progress, 255);
114-
assert!(orig_announcements == deserialized_announcements);
115-
chan_progress = match orig_announcements.last() {
116-
Some(announcement) => announcement.0.contents.short_channel_id + 1,
117-
None => break,
118-
};
119-
}
120-
let mut node_progress = None;
121-
loop {
122-
let orig_announcements = self.net_graph_msg_handler.get_next_node_announcements(node_progress.as_ref(), 255);
123-
let deserialized_announcements = net_graph_msg_handler.get_next_node_announcements(node_progress.as_ref(), 255);
124-
assert!(orig_announcements == deserialized_announcements);
125-
node_progress = match orig_announcements.last() {
126-
Some(announcement) => Some(announcement.contents.node_id),
127-
None => break,
128-
};
129-
}
130-
}
131-
132102
// Check that if we serialize and then deserialize all our channel monitors we get the
133103
// same set of outputs to watch for on chain as we have now. Note that if we write
134104
// tests that fully close channels and remove the monitors at some point this may break.

lightning/src/routing/network_graph.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -198,53 +198,6 @@ impl RoutingMessageHandler for NetGraphMsgHandler {
198198
}
199199
}
200200

201-
202-
const SERIALIZATION_VERSION: u8 = 1;
203-
const MIN_SERIALIZATION_VERSION: u8 = 1;
204-
205-
impl Writeable for NetGraphMsgHandler {
206-
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
207-
writer.write_all(&[SERIALIZATION_VERSION; 1])?;
208-
writer.write_all(&[MIN_SERIALIZATION_VERSION; 1])?;
209-
210-
let network = self.network_graph.read().unwrap();
211-
network.write(writer)?;
212-
Ok(())
213-
}
214-
}
215-
216-
/// Arguments for the creation of a NetGraphMsgHandler that are not deserialized.
217-
/// At a high-level, the process for deserializing a NetGraphMsgHandler and resuming normal operation is:
218-
/// 1) Deserialize the NetGraphMsgHandler by filling in this struct and calling <NetGraphMsgHandler>::read(reaser, args).
219-
/// 2) Register the new NetGraphMsgHandler with your ChainWatchInterface
220-
pub struct NetGraphMsgHandlerReadArgs {
221-
/// The ChainWatchInterface for use in the NetGraphMsgHandler in the future.
222-
///
223-
/// No calls to the ChainWatchInterface will be made during deserialization.
224-
pub chain_monitor: Arc<ChainWatchInterface>,
225-
/// The Logger for use in the ChannelManager and which may be used to log information during
226-
/// deserialization.
227-
pub logger: Arc<Logger>,
228-
}
229-
230-
impl ReadableArgs<NetGraphMsgHandlerReadArgs> for NetGraphMsgHandler {
231-
fn read<R: ::std::io::Read>(reader: &mut R, args: NetGraphMsgHandlerReadArgs) -> Result<NetGraphMsgHandler, DecodeError> {
232-
let _ver: u8 = Readable::read(reader)?;
233-
let min_ver: u8 = Readable::read(reader)?;
234-
if min_ver > SERIALIZATION_VERSION {
235-
return Err(DecodeError::UnknownVersion);
236-
}
237-
let network_graph = Readable::read(reader)?;
238-
Ok(NetGraphMsgHandler {
239-
secp_ctx: Secp256k1::verification_only(),
240-
network_graph: RwLock::new(network_graph),
241-
chain_monitor: args.chain_monitor,
242-
full_syncs_requested: AtomicUsize::new(0),
243-
logger: args.logger.clone(),
244-
})
245-
}
246-
}
247-
248201
#[derive(PartialEq, Debug)]
249202
/// Details regarding one direction of a channel
250203
pub struct DirectionalChannelInfo {

0 commit comments

Comments
 (0)