Example #1
0
 /**
  * Checks the block data to ensure it follows the rules laid out in the network parameters.
  * Specifically, throws an exception if the proof of work is invalid, or if the timestamp is too
  * far from what it should be. This is <b>not</b> everything that is required for a block to be
  * valid, only what is checkable independent of the chain and without a transaction index.
  *
  * @throws VerificationException
  */
 public void verifyHeader() throws VerificationException {
   // Prove that this block is OK. It might seem that we can just ignore most of these checks given
   // that the
   // network is also verifying the blocks, but we cannot as it'd open us to a variety of obscure
   // attacks.
   //
   // Firstly we need to ensure this block does in fact represent real work done. If the difficulty
   // is high
   // enough, it's probably been done by the network.
   maybeParseHeader();
   checkProofOfWork(true);
   checkTimestamp();
 }