Exemple #1
0
 public function toNodeList()
 {
     $nodes = new NodeList([]);
     foreach ($this->buckets as $id => $bucket) {
         if ($bucket !== NULL) {
             $nodes->addNodeList($bucket->toNodeList());
         }
     }
     return $nodes;
 }
Exemple #2
0
 public function mergeNodeLists($results)
 {
     $node_list = new NodeList([]);
     foreach ($results as $protocol_result) {
         foreach ($protocol_result as $node_result) {
             if (isset($node_result['node_list'])) {
                 $res = $node_result['node_list'];
                 assert(get_class($res) === 'Kademlia\\NodeList');
                 foreach ($res->toArray() as $n) {
                     assert(get_class($n) === 'Kademlia\\Node' or get_class($n) === 'MockNode');
                 }
                 $node_list->addNodeList($res);
             }
         }
     }
     return $node_list;
 }