1 | <?php |
||
27 | class Peer extends EventEmitter |
||
28 | { |
||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $buffer = ''; |
||
33 | |||
34 | /** |
||
35 | * @var LoopInterface |
||
36 | */ |
||
37 | private $loop; |
||
38 | |||
39 | /** |
||
40 | * @var \BitWasp\Bitcoin\Networking\Messages\Factory |
||
41 | */ |
||
42 | private $msgs; |
||
43 | |||
44 | /** |
||
45 | * @var Stream |
||
46 | */ |
||
47 | private $stream; |
||
48 | |||
49 | /** |
||
50 | * @var Version |
||
51 | */ |
||
52 | private $localVersion; |
||
53 | |||
54 | /** |
||
55 | * @var Version |
||
56 | */ |
||
57 | private $remoteVersion; |
||
58 | |||
59 | /** |
||
60 | * @var ConnectionParams |
||
61 | */ |
||
62 | private $connectionParams; |
||
63 | |||
64 | /** |
||
65 | * @var bool |
||
66 | */ |
||
67 | private $exchangedVersion = false; |
||
68 | |||
69 | /** |
||
70 | * @param \BitWasp\Bitcoin\Networking\Messages\Factory $msgs |
||
71 | * @param LoopInterface $loop |
||
72 | */ |
||
73 | public function __construct(\BitWasp\Bitcoin\Networking\Messages\Factory $msgs, LoopInterface $loop) |
||
78 | |||
79 | /** |
||
80 | * @return Version |
||
81 | */ |
||
82 | public function getLocalVersion() |
||
86 | |||
87 | /** |
||
88 | * @return Version |
||
89 | */ |
||
90 | public function getRemoteVersion() |
||
94 | |||
95 | /** |
||
96 | * @return ConnectionParams |
||
97 | */ |
||
98 | public function getConnectionParams() |
||
102 | |||
103 | 18 | /** |
|
104 | * @param NetworkSerializable $msg |
||
105 | */ |
||
106 | public function send(NetworkSerializable $msg) |
||
112 | 18 | ||
113 | /** |
||
114 | * Handler for incoming data. Buffers possibly fragmented packets since they arrive sequentially. |
||
115 | * Before finishing the version exchange, this will only emit Version and VerAck messages. |
||
116 | */ |
||
117 | private function onData() |
||
134 | |||
135 | /** |
||
136 | * @param Stream $stream |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function setupStream(Stream $stream) |
||
161 | |||
162 | /** |
||
163 | * @param Stream $connection |
||
164 | * @param ConnectionParams $params |
||
165 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
166 | */ |
||
167 | public function inboundHandshake(Stream $connection, ConnectionParams $params) |
||
189 | |||
190 | /** |
||
191 | * @param NetworkAddressInterface $remotePeer |
||
192 | * @param ConnectionParams $params |
||
193 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
194 | */ |
||
195 | public function outboundHandshake(NetworkAddressInterface $remotePeer, ConnectionParams $params) |
||
217 | |||
218 | /** |
||
219 | * |
||
220 | 15 | */ |
|
221 | public function intentionalClose() |
||
226 | 15 | ||
227 | 15 | /** |
|
228 | 15 | * |
|
229 | 15 | */ |
|
230 | 15 | public function close() |
|
236 | |||
237 | 15 | /** |
|
238 | * @param int $protocolVersion |
||
239 | * @param BufferInterface $services |
||
240 | * @param int $timestamp |
||
241 | * @param NetworkAddressInterface $remoteAddr |
||
242 | * @param NetworkAddressInterface $localAddr |
||
243 | * @param string $userAgent |
||
244 | 15 | * @param int $blockHeight |
|
245 | * @param bool $relayToUs |
||
246 | */ |
||
247 | 15 | public function version( |
|
268 | |||
269 | /** |
||
270 | * |
||
271 | */ |
||
272 | public function verack() |
||
276 | |||
277 | /** |
||
278 | * |
||
279 | */ |
||
280 | public function sendheaders() |
||
284 | |||
285 | /** |
||
286 | * @param Inventory[] $vInv |
||
287 | */ |
||
288 | 9 | public function inv(array $vInv) |
|
292 | 9 | ||
293 | 9 | /** |
|
294 | * @param Inventory[] $vInv |
||
295 | */ |
||
296 | 9 | public function getdata(array $vInv) |
|
300 | |||
301 | 9 | /** |
|
302 | 9 | * @param array $vInv |
|
303 | 9 | */ |
|
304 | 9 | public function notfound(array $vInv) |
|
308 | |||
309 | 9 | /** |
|
310 | * @param NetworkAddressTimestamp[] $vNetAddr |
||
311 | */ |
||
312 | public function addr(array $vNetAddr) |
||
316 | |||
317 | 15 | /** |
|
318 | * |
||
319 | 15 | */ |
|
320 | 15 | public function getaddr() |
|
324 | 15 | ||
325 | /** |
||
326 | 15 | * |
|
327 | 15 | */ |
|
328 | public function ping() |
||
332 | |||
333 | /** |
||
334 | 12 | * @param Ping $ping |
|
335 | 12 | */ |
|
336 | 12 | public function pong(Ping $ping) |
|
340 | |||
341 | 15 | /** |
|
342 | * @param TransactionInterface $tx |
||
343 | 15 | */ |
|
344 | 2 | public function tx(TransactionInterface $tx) |
|
348 | 15 | ||
349 | /** |
||
350 | * @param BlockLocator $locator |
||
351 | */ |
||
352 | public function getblocks(BlockLocator $locator) |
||
359 | |||
360 | /** |
||
361 | * @param BlockLocator $locator |
||
362 | */ |
||
363 | 10 | public function getheaders(BlockLocator $locator) |
|
370 | |||
371 | /** |
||
372 | * @param BlockInterface $block |
||
373 | 15 | */ |
|
374 | public function block(BlockInterface $block) |
||
378 | 15 | ||
379 | 15 | /** |
|
380 | 15 | * @param array $vHeaders |
|
381 | 15 | */ |
|
382 | 15 | public function headers(array $vHeaders) |
|
386 | |||
387 | /** |
||
388 | * @param AlertDetail $detail |
||
389 | * @param SignatureInterface $signature |
||
390 | 15 | */ |
|
391 | public function alert(AlertDetail $detail, SignatureInterface $signature) |
||
395 | |||
396 | /** |
||
397 | * @param int $feeRate |
||
398 | */ |
||
399 | public function feefilter($feeRate) |
||
403 | |||
404 | /** |
||
405 | * @param BufferInterface $data |
||
406 | */ |
||
407 | public function filteradd(BufferInterface $data) |
||
411 | |||
412 | /** |
||
413 | * @param BloomFilter $filter |
||
414 | */ |
||
415 | public function filterload(BloomFilter $filter) |
||
419 | |||
420 | /** |
||
421 | * |
||
422 | */ |
||
423 | public function filterclear() |
||
427 | |||
428 | /** |
||
429 | * @param FilteredBlock $filtered |
||
430 | */ |
||
431 | public function merkleblock(FilteredBlock $filtered) |
||
435 | |||
436 | /** |
||
437 | * |
||
438 | */ |
||
439 | public function mempool() |
||
443 | |||
444 | /** |
||
445 | * Issue a Reject message, with a required $msg, $code, and $reason |
||
446 | * |
||
447 | * @param BufferInterface $msg |
||
448 | * @param int $code |
||
449 | * @param BufferInterface $reason |
||
450 | * @param BufferInterface $data |
||
451 | */ |
||
452 | public function reject(BufferInterface $msg, $code, BufferInterface $reason, BufferInterface $data = null) |
||
456 | } |
||
457 |