Skip to content

Commit 1b8834b

Browse files
Update lightning-net-tokio library to match ChannelManager's new ChannelMonitor Deref API
1 parent daa9b89 commit 1b8834b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lightning-net-tokio/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use tokio::net::TcpStream;
1919

2020
use lightning::ln::peer_handler;
2121
use lightning::ln::peer_handler::SocketDescriptor as LnSocketTrait;
22+
use lightning::ln::msgs::ChannelMessageHandler;
2223

2324
use std::mem;
2425
use std::net::SocketAddr;
@@ -42,7 +43,7 @@ pub struct Connection {
4243
id: u64,
4344
}
4445
impl Connection {
45-
fn schedule_read(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor>>, us: Arc<Mutex<Self>>, reader: futures::stream::SplitStream<tokio_codec::Framed<TcpStream, tokio_codec::BytesCodec>>) {
46+
fn schedule_read(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<dyn ChannelMessageHandler>>>, us: Arc<Mutex<Self>>, reader: futures::stream::SplitStream<tokio_codec::Framed<TcpStream, tokio_codec::BytesCodec>>) {
4647
let us_ref = us.clone();
4748
let us_close_ref = us.clone();
4849
let peer_manager_ref = peer_manager.clone();
@@ -110,7 +111,7 @@ impl Connection {
110111
///
111112
/// You should poll the Receive end of event_notify and call get_and_clear_pending_events() on
112113
/// ChannelManager and ChannelMonitor objects.
113-
pub fn setup_inbound(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor>>, event_notify: mpsc::Sender<()>, stream: TcpStream) {
114+
pub fn setup_inbound(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<dyn ChannelMessageHandler>>>, event_notify: mpsc::Sender<()>, stream: TcpStream) {
114115
let (reader, us) = Self::new(event_notify, stream);
115116

116117
if let Ok(_) = peer_manager.new_inbound_connection(SocketDescriptor::new(us.clone(), peer_manager.clone())) {
@@ -124,7 +125,7 @@ impl Connection {
124125
///
125126
/// You should poll the Receive end of event_notify and call get_and_clear_pending_events() on
126127
/// ChannelManager and ChannelMonitor objects.
127-
pub fn setup_outbound(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor>>, event_notify: mpsc::Sender<()>, their_node_id: PublicKey, stream: TcpStream) {
128+
pub fn setup_outbound(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<dyn ChannelMessageHandler>>>, event_notify: mpsc::Sender<()>, their_node_id: PublicKey, stream: TcpStream) {
128129
let (reader, us) = Self::new(event_notify, stream);
129130

130131
if let Ok(initial_send) = peer_manager.new_outbound_connection(their_node_id, SocketDescriptor::new(us.clone(), peer_manager.clone())) {
@@ -142,7 +143,7 @@ impl Connection {
142143
///
143144
/// You should poll the Receive end of event_notify and call get_and_clear_pending_events() on
144145
/// ChannelManager and ChannelMonitor objects.
145-
pub fn connect_outbound(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor>>, event_notify: mpsc::Sender<()>, their_node_id: PublicKey, addr: SocketAddr) {
146+
pub fn connect_outbound(peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<dyn ChannelMessageHandler>>>, event_notify: mpsc::Sender<()>, their_node_id: PublicKey, addr: SocketAddr) {
146147
let connect_timeout = Delay::new(Instant::now() + Duration::from_secs(10)).then(|_| {
147148
future::err(std::io::Error::new(std::io::ErrorKind::TimedOut, "timeout reached"))
148149
});
@@ -161,10 +162,10 @@ impl Connection {
161162
pub struct SocketDescriptor {
162163
conn: Arc<Mutex<Connection>>,
163164
id: u64,
164-
peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor>>,
165+
peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<dyn ChannelMessageHandler>>>,
165166
}
166167
impl SocketDescriptor {
167-
fn new(conn: Arc<Mutex<Connection>>, peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor>>) -> Self {
168+
fn new(conn: Arc<Mutex<Connection>>, peer_manager: Arc<peer_handler::PeerManager<SocketDescriptor, Arc<dyn ChannelMessageHandler>>>) -> Self {
168169
let id = conn.lock().unwrap().id;
169170
Self { conn, id, peer_manager }
170171
}

0 commit comments

Comments
 (0)