public AuxPoW(NetworkParameters params, @Nullable Message parent) { super(params); transaction = new Transaction(params); hashBlock = Sha256Hash.ZERO_HASH; coinbaseBranch = new MerkleBranch(params, this); chainMerkleBranch = new MerkleBranch(params, this); parentBlockHeader = null; }
@Override protected void parse() throws ProtocolException { cursor = offset; transaction = new Transaction(params, payload, cursor, this, serializer, Message.UNKNOWN_LENGTH); cursor += transaction.getOptimalEncodingMessageSize(); optimalEncodingMessageSize = transaction.getOptimalEncodingMessageSize(); hashBlock = readHash(); optimalEncodingMessageSize += 32; // Add the hash size to the optimal encoding coinbaseBranch = new MerkleBranch(params, this, payload, cursor, serializer); cursor += coinbaseBranch.getOptimalEncodingMessageSize(); optimalEncodingMessageSize += coinbaseBranch.getOptimalEncodingMessageSize(); chainMerkleBranch = new MerkleBranch(params, this, payload, cursor, serializer); cursor += chainMerkleBranch.getOptimalEncodingMessageSize(); optimalEncodingMessageSize += chainMerkleBranch.getOptimalEncodingMessageSize(); // Make a copy of JUST the contained block header, so the block parser doesn't try reading // transactions past the end byte[] blockBytes = Arrays.copyOfRange(payload, cursor, cursor + Block.HEADER_SIZE); cursor += Block.HEADER_SIZE; parentBlockHeader = new AltcoinBlock(params, blockBytes, 0, this, serializer, Block.HEADER_SIZE); length = cursor - offset; }