1 | <?php |
||
13 | class Locator |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var Resolver |
||
18 | */ |
||
19 | private $dns; |
||
20 | |||
21 | /** |
||
22 | * @var DnsSeedList |
||
23 | */ |
||
24 | private $seeds; |
||
25 | |||
26 | /** |
||
27 | * @var NetworkAddressInterface[] |
||
28 | */ |
||
29 | private $knownAddresses = []; |
||
30 | |||
31 | /** |
||
32 | * Locator constructor. |
||
33 | * @param DnsSeedList $list |
||
34 | * @param Resolver $dns |
||
35 | */ |
||
36 | 9 | public function __construct(DnsSeedList $list, Resolver $dns) |
|
41 | |||
42 | /** |
||
43 | * @param int $numSeeds |
||
44 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
45 | */ |
||
46 | private function getPeerList($numSeeds = 1) |
||
76 | 6 | ||
77 | /** |
||
78 | * Connect to $numSeeds DNS seeds |
||
79 | * |
||
80 | 6 | * @param int $numSeeds |
|
81 | 6 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
|
82 | 6 | */ |
|
83 | 6 | public function queryDnsSeeds($numSeeds = 1) |
|
117 | 5 | ||
118 | 5 | /** |
|
119 | 5 | * @return NetworkAddressInterface[] |
|
120 | 5 | */ |
|
121 | 2 | public function getKnownAddresses() |
|
125 | 5 | ||
126 | 5 | /** |
|
127 | * Pop an address from the discovered peers |
||
128 | 3 | * |
|
129 | * @return NetworkAddressInterface |
||
130 | 5 | * @throws \Exception |
|
131 | 6 | */ |
|
132 | 3 | public function popAddress() |
|
140 | } |
||
141 |