Merge pull request #220 from TheBlueMatt/2018-10-oops-xxx
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Thu, 25 Oct 2018 19:19:06 +0000 (15:19 -0400)
committerGitHub <noreply@github.com>
Thu, 25 Oct 2018 19:19:06 +0000 (15:19 -0400)
Fix XXXs that slipped into router and handle HTLCFailCHannelUpdates

.travis.yml
src/ln/router.rs

index 6a21dfa0b3a14d19d726756b5f3437b562933495..efdff130b0df85d87b7f7b34e4964aa76a8db100 100644 (file)
@@ -3,6 +3,7 @@ rust:
   - stable
   - beta
   - 1.22.0
+  - 1.29.2
 cache: cargo
 
 before_install:
@@ -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
index 4c3bcb98074fd8301941739c9352ce6bef593e05..0d049f5a78d6bfcb68bd41a49ab06602e98069c3 100644 (file)
@@ -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);
+                                       }
+                               } 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);
+                               }
                        },
                }
        }