Ejemplo n.º 1
0
 /**
  * @param BufferInterface $hash
  * @param BlockIndexInterface $prevIndex
  * @param BlockHeaderInterface $header
  * @return BlockIndex
  */
 public function getNextIndex(BufferInterface $hash, BlockIndexInterface $prevIndex, BlockHeaderInterface $header)
 {
     return new BlockIndex($hash, $prevIndex->getHeight() + 1, $this->math->toString($this->math->add($this->proofOfWork->getWork($header->getBits()), gmp_init($prevIndex->getWork()))), $header);
 }
Ejemplo n.º 2
0
 /**
  * @param BlockIndexInterface $index
  * @return array
  */
 public function convertIndexToArray(BlockIndexInterface $index)
 {
     $header = $index->getHeader();
     return ['height' => $index->getHeight(), 'hash' => $index->getHash()->getHex(), 'work' => $index->getWork(), 'version' => $header->getVersion(), 'prevBlock' => $header->getPrevBlock()->getHex(), 'merkleRoot' => $header->getMerkleRoot()->getHex(), 'nBits' => $header->getBits(), 'nTimestamp' => $header->getTimestamp(), 'nNonce' => $header->getNonce()];
 }