@@ -42,11 +42,11 @@ use bitcoin::hashes::{HashEngine, Hash};
42
42
43
43
/// A dummy struct which implements `RoutingMessageHandler` without storing any routing information
44
44
/// or doing any processing. You can provide one of these as the route_handler in a MessageHandler.
45
- pub struct DummyRouteHandler { }
46
- impl MessageSendEventsProvider for DummyRouteHandler {
45
+ struct IgnoringMessageHandler { }
46
+ impl MessageSendEventsProvider for IgnoringMessageHandler {
47
47
fn get_and_clear_pending_msg_events ( & self ) -> Vec < MessageSendEvent > { Vec :: new ( ) }
48
48
}
49
- impl RoutingMessageHandler for DummyRouteHandler {
49
+ impl RoutingMessageHandler for IgnoringMessageHandler {
50
50
fn handle_node_announcement ( & self , _msg : & msgs:: NodeAnnouncement ) -> Result < bool , LightningError > { Ok ( false ) }
51
51
fn handle_channel_announcement ( & self , _msg : & msgs:: ChannelAnnouncement ) -> Result < bool , LightningError > { Ok ( false ) }
52
52
fn handle_channel_update ( & self , _msg : & msgs:: ChannelUpdate ) -> Result < bool , LightningError > { Ok ( false ) }
@@ -60,18 +60,18 @@ impl RoutingMessageHandler for DummyRouteHandler {
60
60
fn handle_query_channel_range ( & self , _their_node_id : & PublicKey , _msg : msgs:: QueryChannelRange ) -> Result < ( ) , LightningError > { Ok ( ( ) ) }
61
61
fn handle_query_short_channel_ids ( & self , _their_node_id : & PublicKey , _msg : msgs:: QueryShortChannelIds ) -> Result < ( ) , LightningError > { Ok ( ( ) ) }
62
62
}
63
- impl Deref for DummyRouteHandler {
64
- type Target = DummyRouteHandler ;
63
+ impl Deref for IgnoringMessageHandler {
64
+ type Target = IgnoringMessageHandler ;
65
65
fn deref ( & self ) -> & Self { self }
66
66
}
67
67
68
68
/// A dummy struct which implements `ChannelMessageHandler` without having any channels.
69
69
/// You can provide one of these as the route_handler in a MessageHandler.
70
- pub struct DummyChannelHandler {
70
+ struct ErroringMessageHandler {
71
71
message_queue : Mutex < Vec < MessageSendEvent > >
72
72
}
73
- impl DummyChannelHandler {
74
- /// Constructs a new DummyChannelHandler
73
+ impl ErroringMessageHandler {
74
+ /// Constructs a new ErroringMessageHandler
75
75
pub fn new ( ) -> Self {
76
76
Self { message_queue : Mutex :: new ( Vec :: new ( ) ) }
77
77
}
@@ -84,70 +84,70 @@ impl DummyChannelHandler {
84
84
} ) ;
85
85
}
86
86
}
87
- impl MessageSendEventsProvider for DummyChannelHandler {
87
+ impl MessageSendEventsProvider for ErroringMessageHandler {
88
88
fn get_and_clear_pending_msg_events ( & self ) -> Vec < MessageSendEvent > {
89
89
let mut res = Vec :: new ( ) ;
90
90
mem:: swap ( & mut res, & mut self . message_queue . lock ( ) . unwrap ( ) ) ;
91
91
res
92
92
}
93
93
}
94
- impl ChannelMessageHandler for DummyChannelHandler {
94
+ impl ChannelMessageHandler for ErroringMessageHandler {
95
95
// Any messages which are related to a specific channel generate an error message to let the
96
96
// peer know we don't care about channels.
97
97
fn handle_open_channel ( & self , their_node_id : & PublicKey , _their_features : InitFeatures , msg : & msgs:: OpenChannel ) {
98
- DummyChannelHandler :: push_error ( self , their_node_id, msg. temporary_channel_id ) ;
98
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. temporary_channel_id ) ;
99
99
}
100
100
fn handle_accept_channel ( & self , their_node_id : & PublicKey , _their_features : InitFeatures , msg : & msgs:: AcceptChannel ) {
101
- DummyChannelHandler :: push_error ( self , their_node_id, msg. temporary_channel_id ) ;
101
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. temporary_channel_id ) ;
102
102
}
103
103
fn handle_funding_created ( & self , their_node_id : & PublicKey , msg : & msgs:: FundingCreated ) {
104
- DummyChannelHandler :: push_error ( self , their_node_id, msg. temporary_channel_id ) ;
104
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. temporary_channel_id ) ;
105
105
}
106
106
fn handle_funding_signed ( & self , their_node_id : & PublicKey , msg : & msgs:: FundingSigned ) {
107
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
107
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
108
108
}
109
109
fn handle_funding_locked ( & self , their_node_id : & PublicKey , msg : & msgs:: FundingLocked ) {
110
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
110
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
111
111
}
112
112
fn handle_shutdown ( & self , their_node_id : & PublicKey , _their_features : & InitFeatures , msg : & msgs:: Shutdown ) {
113
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
113
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
114
114
}
115
115
fn handle_closing_signed ( & self , their_node_id : & PublicKey , msg : & msgs:: ClosingSigned ) {
116
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
116
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
117
117
}
118
118
fn handle_update_add_htlc ( & self , their_node_id : & PublicKey , msg : & msgs:: UpdateAddHTLC ) {
119
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
119
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
120
120
}
121
121
fn handle_update_fulfill_htlc ( & self , their_node_id : & PublicKey , msg : & msgs:: UpdateFulfillHTLC ) {
122
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
122
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
123
123
}
124
124
fn handle_update_fail_htlc ( & self , their_node_id : & PublicKey , msg : & msgs:: UpdateFailHTLC ) {
125
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
125
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
126
126
}
127
127
fn handle_update_fail_malformed_htlc ( & self , their_node_id : & PublicKey , msg : & msgs:: UpdateFailMalformedHTLC ) {
128
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
128
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
129
129
}
130
130
fn handle_commitment_signed ( & self , their_node_id : & PublicKey , msg : & msgs:: CommitmentSigned ) {
131
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
131
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
132
132
}
133
133
fn handle_revoke_and_ack ( & self , their_node_id : & PublicKey , msg : & msgs:: RevokeAndACK ) {
134
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
134
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
135
135
}
136
136
fn handle_update_fee ( & self , their_node_id : & PublicKey , msg : & msgs:: UpdateFee ) {
137
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
137
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
138
138
}
139
139
fn handle_announcement_signatures ( & self , their_node_id : & PublicKey , msg : & msgs:: AnnouncementSignatures ) {
140
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
140
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
141
141
}
142
142
fn handle_channel_reestablish ( & self , their_node_id : & PublicKey , msg : & msgs:: ChannelReestablish ) {
143
- DummyChannelHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
143
+ ErroringMessageHandler :: push_error ( self , their_node_id, msg. channel_id ) ;
144
144
}
145
145
fn peer_disconnected ( & self , _their_node_id : & PublicKey , _no_connection_possible : bool ) { }
146
146
fn peer_connected ( & self , _their_node_id : & PublicKey , _msg : & msgs:: Init ) { }
147
147
fn handle_error ( & self , _their_node_id : & PublicKey , _msg : & msgs:: ErrorMessage ) { }
148
148
}
149
- impl Deref for DummyChannelHandler {
150
- type Target = DummyChannelHandler ;
149
+ impl Deref for ErroringMessageHandler {
150
+ type Target = ErroringMessageHandler ;
151
151
fn deref ( & self ) -> & Self { self }
152
152
}
153
153
@@ -156,10 +156,10 @@ pub struct MessageHandler<CM: Deref, RM: Deref> where
156
156
CM :: Target : ChannelMessageHandler ,
157
157
RM :: Target : RoutingMessageHandler {
158
158
/// A message handler which handles messages specific to channels. Usually this is just a
159
- /// ChannelManager object or a DummyChannelHandler .
159
+ /// ChannelManager object or a ErroringMessageHandler .
160
160
pub chan_handler : CM ,
161
161
/// A message handler which handles messages updating our knowledge of the network channel
162
- /// graph. Usually this is just a NetGraphMsgHandlerMonitor object or a DummyRouteHandler .
162
+ /// graph. Usually this is just a NetGraphMsgHandlerMonitor object or an IgnoringMessageHandler .
163
163
pub route_handler : RM ,
164
164
}
165
165
0 commit comments