Example #1
0
 public function perform()
 {
     $data = ['type' => 'FIND_VALUE', 'key_id' => \Kademlia\Node::binId2hex($this->needle_id)];
     $results = parent::perform($data);
     $node_list = new \Kademlia\NodeList();
     $values = [];
     foreach ($results as $res) {
         $nodes = $this->parseNodeList($res['data']);
         $values = array_merge($values, $this->parseValues($res['data']));
         $node_list->addNodeList($nodes);
     }
     $emitted_result = ['node_list' => $node_list, 'values' => $values];
     if ($this->settings->verbosity >= 4) {
         print \Kademlia\Node::binId2hex($this->settings->own_node_id) . ": FindValue process found these nodes\n";
         var_dump($emitted_result['node_list']);
         print \Kademlia\Node::binId2hex($this->settings->own_node_id) . ": end of FindNode process found nodes\n";
     }
     $type = 'done';
     if (count($values) > 0) {
         $type = 'success';
     }
     $this->emit($type, $emitted_result);
 }