}
pub trait RoutingMessageHandler : Send + Sync {
- fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<(), HandleError>;
+ fn handle_node_announcement(&self, msg: &NodeAnnouncement) -> Result<bool, HandleError>;
/// Handle a channel_announcement message, returning true if it should be forwarded on, false
/// or returning an Err otherwise.
fn handle_channel_announcement(&self, msg: &ChannelAnnouncement) -> Result<bool, HandleError>;
- fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result<(), HandleError>;
+ fn handle_channel_update(&self, msg: &ChannelUpdate) -> Result<bool, HandleError>;
fn handle_htlc_fail_channel_update(&self, update: &HTLCFailChannelUpdate);
}
},
257 => {
let msg = try_potential_decodeerror!(msgs::NodeAnnouncement::decode(&msg_data[2..]));
- try_potential_handleerror!(self.message_handler.route_handler.handle_node_announcement(&msg));
+ let should_forward = try_potential_handleerror!(self.message_handler.route_handler.handle_node_announcement(&msg));
+
+ if should_forward {
+ // TODO: forward msg along to all our other peers!
+ }
},
258 => {
let msg = try_potential_decodeerror!(msgs::ChannelUpdate::decode(&msg_data[2..]));
- try_potential_handleerror!(self.message_handler.route_handler.handle_channel_update(&msg));
+ let should_forward = try_potential_handleerror!(self.message_handler.route_handler.handle_channel_update(&msg));
+
+ if should_forward {
+ // TODO: forward msg along to all our other peers!
+ }
},
_ => {
if (msg_type & 1) == 0 {
}
impl RoutingMessageHandler for Router {
- fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<(), HandleError> {
+ fn handle_node_announcement(&self, msg: &msgs::NodeAnnouncement) -> Result<bool, HandleError> {
let msg_hash = Message::from_slice(&Sha256dHash::from_data(&msg.contents.encode()[..])[..]).unwrap();
secp_verify_sig!(self.secp_ctx, &msg_hash, &msg.signature, &msg.contents.node_id);
node.rgb = msg.contents.rgb;
node.alias = msg.contents.alias;
node.addresses = msg.contents.addresses.clone();
- Ok(())
+ Ok(msg.contents.excess_data.is_empty() && msg.contents.excess_address_data.is_empty() && !msg.contents.features.supports_unknown_bits())
}
}
}
}
}
- fn handle_channel_update(&self, msg: &msgs::ChannelUpdate) -> Result<(), HandleError> {
+ fn handle_channel_update(&self, msg: &msgs::ChannelUpdate) -> Result<bool, HandleError> {
let mut network = self.network_map.write().unwrap();
let dest_node_id;
let chan_enabled = msg.contents.flags & (1 << 1) != (1 << 1);
mut_node.lowest_inbound_channel_fee_proportional_millionths = lowest_inbound_channel_fee_proportional_millionths;
}
- Ok(())
+ Ok(msg.contents.excess_data.is_empty())
}
}
}
impl msgs::RoutingMessageHandler for TestRoutingMessageHandler {
- fn handle_node_announcement(&self, _msg: &msgs::NodeAnnouncement) -> Result<(), HandleError> {
+ fn handle_node_announcement(&self, _msg: &msgs::NodeAnnouncement) -> Result<bool, HandleError> {
Err(HandleError { err: "", action: None })
}
fn handle_channel_announcement(&self, _msg: &msgs::ChannelAnnouncement) -> Result<bool, HandleError> {
Err(HandleError { err: "", action: None })
}
- fn handle_channel_update(&self, _msg: &msgs::ChannelUpdate) -> Result<(), HandleError> {
+ fn handle_channel_update(&self, _msg: &msgs::ChannelUpdate) -> Result<bool, HandleError> {
Err(HandleError { err: "", action: None })
}
fn handle_htlc_fail_channel_update(&self, _update: &msgs::HTLCFailChannelUpdate) {}