/** 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; }
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; }
void setNonce(long nonce) { unCacheHeader(); this.nonce = nonce; this.hash = null; this.scryptHash = null; }
void setDifficultyTarget(long compactForm) { unCacheHeader(); this.difficultyTarget = compactForm; this.hash = null; this.scryptHash = null; }
void setTime(long time) { unCacheHeader(); this.time = time; this.hash = null; this.scryptHash = null; }
void setPrevBlockHash(Sha256Hash prevBlockHash) { unCacheHeader(); this.prevBlockHash = prevBlockHash; this.hash = null; this.scryptHash = null; }
/** Exists only for unit testing. */ void setMerkleRoot(Sha256Hash value) { unCacheHeader(); merkleRoot = value; hash = null; }