Skip to content

Fix XXXs that slipped into router and handle HTLCFailCHannelUpdates #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rust:
- stable
- beta
- 1.22.0
- 1.29.2
cache: cargo

before_install:
Expand All @@ -12,4 +13,4 @@ before_install:
script:
- cargo build --verbose
- cargo test --verbose
- if [ "$(rustup show | grep default | grep stable)" != "" ]; then cd fuzz && cargo test --verbose && ./travis-fuzz.sh; fi
- if [ "$(rustup show | grep default | grep 1.29.2)" != "" ]; then cd fuzz && cargo test --verbose && ./travis-fuzz.sh; fi
25 changes: 16 additions & 9 deletions src/ln/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,25 @@ impl RoutingMessageHandler for Router {
&msgs::HTLCFailChannelUpdate::ChannelUpdateMessage { ref msg } => {
let _ = self.handle_channel_update(msg);
},
&msgs::HTLCFailChannelUpdate::ChannelClosed { ref short_channel_id, is_permanent:_ } => {
//XXX
&msgs::HTLCFailChannelUpdate::ChannelClosed { ref short_channel_id, ref is_permanent } => {
let mut network = self.network_map.write().unwrap();
if let Some(chan) = network.channels.remove(short_channel_id) {
Self::remove_channel_in_nodes(&mut network.nodes, &chan, *short_channel_id);
if *is_permanent {
if let Some(chan) = network.channels.remove(short_channel_id) {
Self::remove_channel_in_nodes(&mut network.nodes, &chan, *short_channel_id);
}
Copy link
Contributor

@yuntai yuntai Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ MAY TODO: if the announced node no longer has any associated open channels:
+ MAY prune nodes added through node_announcement messages from their local view.
?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove_channel_in_nodes removes the node if there are no channels left.

} else {
if let Some(chan) = network.channels.get_mut(short_channel_id) {
chan.one_to_two.enabled = false;
chan.two_to_one.enabled = false;
}
}
},
&msgs::HTLCFailChannelUpdate::NodeFailure { ref node_id, is_permanent:_ } => {
//XXX
//let mut network = self.network_map.write().unwrap();
//TODO: check _blamed_upstream_node
self.mark_node_bad(node_id, false);
&msgs::HTLCFailChannelUpdate::NodeFailure { ref node_id, ref is_permanent } => {
if *is_permanent {
//TODO: Wholly remove the node
} else {
self.mark_node_bad(node_id, false);
}
},
}
}
Expand Down