public function testBlockIndex() { $headerHex = '0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c'; $header = BlockHeaderFactory::fromHex($headerHex); $hash = $header->getHash(); $height = 0; $work = 0; $index = new BlockIndex($hash, $height, $work, $header); $this->assertEquals($hash, $index->getHash()); $this->assertEquals($height, $index->getHeight()); $this->assertEquals($work, $index->getWork()); $this->assertSame($header, $index->getHeader()); }
/** * @param BlockIndex $prevIndex * @param BlockHeaderInterface $header * @return BlockIndex */ public function makeIndex(BlockIndex $prevIndex, BlockHeaderInterface $header) { return new BlockIndex($header->getHash()->getHex(), $this->math->add($prevIndex->getHeight(), 1), $this->math->add($this->pow->getWork($header->getBits()), $prevIndex->getWork()), $header); }