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 | 12 | 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 | 9 | public function querySeeds(array $seeds) |
|
75 | |||
76 | /** |
||
77 | * @param int $numSeeds |
||
78 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
79 | */ |
||
80 | 6 | private function getPeerList($numSeeds = 1) |
|
89 | |||
90 | /** |
||
91 | * Connect to $numSeeds DNS seeds |
||
92 | * |
||
93 | * @param int $numSeeds |
||
94 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
95 | */ |
||
96 | 6 | public function queryDnsSeeds($numSeeds = 1) |
|
130 | |||
131 | /** |
||
132 | * @return NetworkAddressInterface[] |
||
133 | */ |
||
134 | 3 | public function getKnownAddresses() |
|
138 | |||
139 | /** |
||
140 | * Pop an address from the discovered peers |
||
141 | * |
||
142 | * @return NetworkAddressInterface |
||
143 | * @throws \Exception |
||
144 | */ |
||
145 | 6 | public function popAddress() |
|
153 | } |
||
154 |
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: