Browse Source

add a isBestLink to the pathfinder tree

Caleb James DeLisle 9 years ago
parent
commit
e49eb95368
2 changed files with 7 additions and 1 deletions
  1. 5 0
      dht/dhtcore/NodeStore_admin.c
  2. 2 1
      tools/pathfinderTree

+ 5 - 0
dht/dhtcore/NodeStore_admin.c

@@ -157,6 +157,7 @@ static void getLink(Dict* args, void* vcontext, String* txid, struct Allocator*
 
     Admin_sendMessage(ret, txid, ctx->admin);
 }
+
 static void nodeForAddr(Dict* args, void* vcontext, String* txid, struct Allocator* alloc)
 {
     struct Context* ctx = Identity_check((struct Context*) vcontext);
@@ -211,6 +212,10 @@ static void nodeForAddr(Dict* args, void* vcontext, String* txid, struct Allocat
     AddrTools_printPath(parentChildLabel->bytes, Node_getBestParent(node)->cannonicalLabel);
     Dict_putString(bestParent, String_CONST("parentChildLabel"), parentChildLabel, alloc);
 
+    int isOneHop = EncodingScheme_isOneHop(Node_getBestParent(node)->parent->encodingScheme,
+                                           Node_getBestParent(node)->cannonicalLabel);
+    Dict_putInt(bestParent, String_CONST("isOneHop"), isOneHop, alloc);
+
     Dict_putDict(result, String_CONST("bestParent"), bestParent, alloc);
 
     String* bestLabel = String_newBinary(NULL, 19, alloc);

+ 2 - 1
tools/pathfinderTree

@@ -67,7 +67,8 @@ var buildTree = function (origNodes) {
 };
 
 var printTree = function (tree, spaces) {
-    console.log(spaces + tree.ip + ' ' + tree.bestParent.parentChildLabel + '  ' + tree.routeLabel + '  ' + tree.reach);
+    console.log(spaces + tree.ip + ' ' + tree.bestParent.parentChildLabel + '  ' +
+        tree.routeLabel + '  ' + tree.reach + '  ' + tree.bestParent.isOneHop);
     for (var i = 0; i < tree.peers.length; i++) {
         printTree(tree.peers[i], spaces + '  ');
     }