From bcc296f5058bc3219834ef33e42eff49b82aba20 Mon Sep 17 00:00:00 2001
From: nanocryk <nanocryk@ifee.fr>
Date: Mon, 19 Mar 2018 17:00:45 +0100
Subject: [PATCH] [fix] Keep less then k_max distance paths

---
 wotb/rusty.rs | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/wotb/rusty.rs b/wotb/rusty.rs
index d0e605b6..8506ed13 100644
--- a/wotb/rusty.rs
+++ b/wotb/rusty.rs
@@ -260,12 +260,20 @@ impl WebOfTrust for RustyWebOfTrust {
             let mut new_paths = vec![];
 
             for path in &paths {
-                let sources = &graph[path.last().unwrap().0];
-                for source in &sources.1 {
-                    let mut new_path = path.clone();
-                    new_path.push(NodeId(*source));
-                    new_paths.push(new_path);
-                }
+                let node = path.last().unwrap();
+
+                if node == &to {
+                    // If path is complete, we keep it.
+                    new_paths.push(path.clone())
+                } else {
+                    // If not complete we comlete paths
+                    let sources = &graph[node.0];
+                    for source in &sources.1 {
+                        let mut new_path = path.clone();
+                        new_path.push(NodeId(*source));
+                        new_paths.push(new_path);
+                    }
+                }                
             }
 
             paths = new_paths;
-- 
GitLab