Esempio n. 1
0
 /*
  * Block uses some special handling for lazy parsing and retention of cached bytes. Parsing and serializing the
  * block header and the transaction list are both non-trivial so there are good efficiency gains to be had by
  * separating them. There are many cases where a user may need access to access or change one or the other but not both.
  *
  * With this in mind we ignore the inherited checkParse() and unCache() methods and implement a separate version
  * of them for both header and transactions.
  *
  * Serializing methods are also handled in their own way. Whilst they deal with separate parts of the block structure
  * there are some interdependencies. For example altering a tx requires invalidating the Merkle root and therefore
  * the cached header bytes.
  */
 private void maybeParseHeader() {
   if (headerParsed || bytes == null) return;
   parseHeader();
   if (!(headerBytesValid || transactionBytesValid)) bytes = null;
 }
Esempio n. 2
0
 void parse() throws ProtocolException {
   parseHeader();
   parseTransactions();
   length = cursor - offset;
 }