/** * @param int $blockHeight * @return \React\Promise\Promise|\React\Promise\PromiseInterface */ public function blockGetChunk($blockHeight) { return $this->conn->request(self::BLOCK_GET_CHUNK, [$blockHeight]); }
public function testRequest() { $expected = new Request(null, 'test.method', [123]); $serialized = new Deferred(); $serialized->promise()->then(function (Request $request) use($expected) { $this->assertEquals($expected->getMethod(), $request->getMethod()); $this->assertEquals($expected->getParams(), $request->getParams()); $this->assertEquals($expected->write(), func_get_args()[0]); }, function ($e) { $this->fail($e); }); $stream = $this->getMockStream(); $stream->expects($this->once())->method('write')->willReturnCallback(function () use(&$serialized) { $args = func_get_args(); if (isset($args[0])) { $serialized->resolve($args[0]); } else { $serialized->reject(); } }); $factory = new RequestFactory(); $connection = new Connection($stream, $factory); $connection->request('test.method', [123]); }
/** * @param string $worker_name * @param string $job_id * @param int $extranonce2 * @param int $ntime * @param int $nonce * @return \React\Promise\Promise|\React\Promise\PromiseInterface */ public function submit($worker_name, $job_id, $extranonce2, $ntime, $nonce) { return $this->conn->request(self::SUBMIT, [$worker_name, $job_id, $extranonce2, $ntime, $nonce]); }