1 | <?php |
||
23 | class Factory |
||
24 | { |
||
25 | /** |
||
26 | * @var NetworkInterface |
||
27 | */ |
||
28 | private $network; |
||
29 | |||
30 | /** |
||
31 | * @var Random |
||
32 | */ |
||
33 | private $random; |
||
34 | |||
35 | /** |
||
36 | * @param NetworkInterface $network |
||
37 | * @param Random $random |
||
38 | */ |
||
39 | 126 | public function __construct(NetworkInterface $network, Random $random) |
|
40 | { |
||
41 | 126 | $this->network = $network; |
|
42 | 126 | $this->random = $random; |
|
43 | 126 | $this->serializer = new NetworkMessageSerializer($this->network); |
|
|
|||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param int $version |
||
48 | * @param int $services |
||
49 | * @param int $timestamp |
||
50 | * @param NetworkAddressInterface $addrRecv |
||
51 | * @param NetworkAddressInterface $addrFrom |
||
52 | * @param BufferInterface $userAgent |
||
53 | * @param int $startHeight |
||
54 | * @param bool $relay |
||
55 | * @return Version |
||
56 | 51 | */ |
|
57 | public function version( |
||
79 | |||
80 | /** |
||
81 | * @return VerAck |
||
82 | 15 | */ |
|
83 | public function verack() |
||
87 | |||
88 | /** |
||
89 | * @return SendHeaders |
||
90 | 3 | */ |
|
91 | public function sendheaders() |
||
95 | |||
96 | /** |
||
97 | * @param NetworkAddressTimestamp[] $addrs |
||
98 | * @return Addr |
||
99 | 3 | */ |
|
100 | public function addr(array $addrs) |
||
104 | |||
105 | /** |
||
106 | * @param Inventory[] $vectors |
||
107 | * @return Inv |
||
108 | 3 | */ |
|
109 | public function inv(array $vectors) |
||
113 | |||
114 | /** |
||
115 | * @param Inventory[] $vectors |
||
116 | * @return GetData |
||
117 | 3 | */ |
|
118 | public function getdata(array $vectors) |
||
122 | |||
123 | /** |
||
124 | * @param Inventory[] $vectors |
||
125 | * @return NotFound |
||
126 | 3 | */ |
|
127 | public function notfound(array $vectors) |
||
131 | |||
132 | /** |
||
133 | * @param $version |
||
134 | * @param BlockLocator $blockLocator |
||
135 | * @return GetBlocks |
||
136 | 3 | */ |
|
137 | public function getblocks($version, BlockLocator $blockLocator) |
||
141 | |||
142 | /** |
||
143 | * @param $version |
||
144 | * @param BlockLocator $blockLocator |
||
145 | * @return GetHeaders |
||
146 | 3 | */ |
|
147 | public function getheaders($version, BlockLocator $blockLocator) |
||
151 | |||
152 | /** |
||
153 | * @param TransactionInterface $tx |
||
154 | * @return Tx |
||
155 | 3 | */ |
|
156 | public function tx(TransactionInterface $tx) |
||
160 | |||
161 | /** |
||
162 | * @param BlockInterface $block |
||
163 | * @return Block |
||
164 | 3 | */ |
|
165 | public function block(BlockInterface $block) |
||
169 | |||
170 | /** |
||
171 | * @param \BitWasp\Bitcoin\Block\BlockHeaderInterface[] $headers |
||
172 | * @return Headers |
||
173 | 3 | */ |
|
174 | public function headers(array $headers) |
||
178 | |||
179 | /** |
||
180 | * @return GetAddr |
||
181 | 3 | */ |
|
182 | public function getaddr() |
||
186 | |||
187 | /** |
||
188 | * @return MemPool |
||
189 | 3 | */ |
|
190 | public function mempool() |
||
194 | |||
195 | /** |
||
196 | * @param int $feeRate |
||
197 | * @return FeeFilter |
||
198 | 3 | */ |
|
199 | public function feefilter($feeRate) |
||
203 | |||
204 | /** |
||
205 | * @param BufferInterface $data |
||
206 | * @return FilterAdd |
||
207 | 3 | */ |
|
208 | public function filteradd(BufferInterface $data) |
||
212 | |||
213 | /** |
||
214 | * @param BloomFilter $filter |
||
215 | * @return FilterLoad |
||
216 | 3 | */ |
|
217 | public function filterload(BloomFilter $filter) |
||
221 | |||
222 | /** |
||
223 | * @return FilterClear |
||
224 | 3 | */ |
|
225 | public function filterclear() |
||
229 | |||
230 | /** |
||
231 | * @param FilteredBlock $filtered |
||
232 | * @return MerkleBlock |
||
233 | 3 | */ |
|
234 | public function merkleblock(FilteredBlock $filtered) |
||
238 | /** |
||
239 | * @return Ping |
||
240 | * @throws \BitWasp\Bitcoin\Exceptions\RandomBytesFailure |
||
241 | 6 | */ |
|
242 | public function ping() |
||
246 | |||
247 | /** |
||
248 | * @param Ping $ping |
||
249 | * @return Pong |
||
250 | 3 | */ |
|
251 | public function pong(Ping $ping) |
||
255 | |||
256 | /** |
||
257 | * @param BufferInterface $message |
||
258 | * @param int $code |
||
259 | * @param BufferInterface $reason |
||
260 | * @param BufferInterface|null $data |
||
261 | * @return Reject |
||
262 | 9 | */ |
|
263 | public function reject( |
||
280 | |||
281 | /** |
||
282 | * @param AlertDetail $detail |
||
283 | * @param SignatureInterface $sig |
||
284 | * @return Alert |
||
285 | 3 | */ |
|
286 | public function alert(AlertDetail $detail, SignatureInterface $sig) |
||
293 | |||
294 | /** |
||
295 | * @param Parser $parser |
||
296 | * @return NetworkMessage |
||
297 | 36 | */ |
|
298 | public function parse(Parser $parser) |
||
302 | |||
303 | /** |
||
304 | * @return NetworkMessageSerializer |
||
305 | 12 | */ |
|
306 | public function getSerializer() |
||
310 | |||
311 | /** |
||
312 | * @return NetworkInterface |
||
313 | */ |
||
314 | public function getNetwork() |
||
318 | } |
||
319 |
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: