Exemplo n.º 1
0
  /** Returns the merkle root in big endian form, calculating it from transactions if necessary. */
  public Sha256Hash getMerkleRoot() {
    maybeParseHeader();
    if (merkleRoot == null) {

      // TODO check if this is really necessary.
      unCacheHeader();

      merkleRoot = calculateMerkleRoot();
    }
    return merkleRoot;
  }
Exemplo n.º 2
0
 private void unCacheTransactions() {
   maybeParseTransactions();
   transactionBytesValid = false;
   if (!headerBytesValid) bytes = null;
   // Current implementation has to uncache headers as well as any change to a tx will alter the
   // merkle root. In
   // future we can go more granular and cache merkle root separately so rest of the header does
   // not need to be
   // rewritten.
   unCacheHeader();
   // Clear merkleRoot last as it may end up being parsed during unCacheHeader().
   merkleRoot = null;
 }
Exemplo n.º 3
0
 void setNonce(long nonce) {
   unCacheHeader();
   this.nonce = nonce;
   this.hash = null;
   this.scryptHash = null;
 }
Exemplo n.º 4
0
 void setDifficultyTarget(long compactForm) {
   unCacheHeader();
   this.difficultyTarget = compactForm;
   this.hash = null;
   this.scryptHash = null;
 }
Exemplo n.º 5
0
 void setTime(long time) {
   unCacheHeader();
   this.time = time;
   this.hash = null;
   this.scryptHash = null;
 }
Exemplo n.º 6
0
 void setPrevBlockHash(Sha256Hash prevBlockHash) {
   unCacheHeader();
   this.prevBlockHash = prevBlockHash;
   this.hash = null;
   this.scryptHash = null;
 }
Exemplo n.º 7
0
 /** Exists only for unit testing. */
 void setMerkleRoot(Sha256Hash value) {
   unCacheHeader();
   merkleRoot = value;
   hash = null;
 }