/**
  * @param Parser $parser
  * @return Block
  * @throws ParserOutOfRange
  */
 public function fromParser(Parser &$parser)
 {
     try {
         $block = new Block($this->math, $this->headerSerializer->fromParser($parser));
         $block->getTransactions()->addTransactions($this->getTxsTemplate()->parse($parser)[0]);
     } catch (ParserOutOfRange $e) {
         throw new ParserOutOfRange('Failed to extract full block header from parser');
     }
     return $block;
 }
 /**
  * {@inheritdoc}
  * @see \BitWasp\Buffertools\SerializableInterface::getBuffer()
  */
 public function getBuffer()
 {
     $serializer = new HexBlockHeaderSerializer();
     $hex = $serializer->serialize($this);
     return $hex;
 }
 /**
  * @param $string
  * @return BlockHeader
  */
 public static function fromHex($string)
 {
     $serializer = new HexBlockHeaderSerializer();
     $block = $serializer->parse($string);
     return $block;
 }