1 | <?php |
||
14 | class Locator |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var Resolver |
||
19 | */ |
||
20 | private $dns; |
||
21 | |||
22 | /** |
||
23 | * @var DnsSeedList |
||
24 | */ |
||
25 | private $seeds; |
||
26 | |||
27 | /** |
||
28 | * @var NetworkAddressInterface[] |
||
29 | */ |
||
30 | private $knownAddresses = []; |
||
31 | |||
32 | /** |
||
33 | * Locator constructor. |
||
34 | * @param Resolver $dns |
||
35 | * @param NetworkSettings $settings |
||
36 | 9 | */ |
|
37 | public function __construct(Resolver $dns, NetworkSettings $settings) |
||
43 | |||
44 | /** |
||
45 | * Takes an arbitrary list of dns seed hostnames, and attempts |
||
46 | * to return a list from each. Request fails if any hosts are |
||
47 | * offline or cause an error. |
||
48 | * |
||
49 | * @param array $seeds |
||
50 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
51 | */ |
||
52 | public function querySeeds(array $seeds) |
||
74 | 6 | ||
75 | 6 | /** |
|
76 | 6 | * Given a number of DNS seeds to query, select a random few and |
|
77 | * return their peers. |
||
78 | * |
||
79 | * @param int $numSeeds |
||
80 | 6 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
|
81 | 6 | */ |
|
82 | 6 | private function getPeerList($numSeeds = 1) |
|
91 | 1 | ||
92 | 6 | /** |
|
93 | * Query $numSeeds DNS seeds, returning the NetworkAddress[] result. |
||
94 | 4 | * Is rejected if any of the seeds fail. |
|
95 | * |
||
96 | * @param int $numSeeds |
||
97 | 6 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
|
98 | */ |
||
99 | public function queryDnsSeeds($numSeeds = 1) |
||
133 | 1 | ||
134 | 3 | /** |
|
135 | 4 | * @return NetworkAddressInterface[] |
|
136 | */ |
||
137 | public function getKnownAddresses() |
||
141 | |||
142 | /** |
||
143 | * Pop an address from the discovered peers |
||
144 | 2 | * |
|
145 | * @return NetworkAddressInterface |
||
146 | 2 | * @throws \Exception |
|
147 | */ |
||
148 | public function popAddress() |
||
156 | } |
||
157 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: