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, $defaultNetPort = 8333) |
|
42 | |||
43 | /** |
||
44 | * Sets the default port for network addresses returned by this instance. |
||
45 | * |
||
46 | * @param int $defaultNetPort |
||
47 | */ |
||
48 | public function setDefaultPort($defaultNetPort) |
||
52 | |||
53 | /** |
||
54 | * @param int $numSeeds |
||
55 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
56 | */ |
||
57 | 6 | private function getPeerList($numSeeds = 1) |
|
87 | |||
88 | /** |
||
89 | * Connect to $numSeeds DNS seeds |
||
90 | * |
||
91 | * @param int $numSeeds |
||
92 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
93 | */ |
||
94 | 6 | public function queryDnsSeeds($numSeeds = 1) |
|
128 | |||
129 | /** |
||
130 | * @return NetworkAddressInterface[] |
||
131 | */ |
||
132 | 3 | public function getKnownAddresses() |
|
136 | |||
137 | /** |
||
138 | * Pop an address from the discovered peers |
||
139 | * |
||
140 | * @return NetworkAddressInterface |
||
141 | * @throws \Exception |
||
142 | */ |
||
143 | 6 | public function popAddress() |
|
151 | } |
||
152 |
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: