AuxPoW extends ChildMessage { static boolean arrayMatch(byte[] script, int offset, byte[] subArray) { int matchIdx; for (matchIdx = 0; matchIdx + offset < script.length && matchIdx < subArray.length; matchIdx++) { if (script[offset + matchIdx] != subArray[matchIdx]) { return false; } } return matchIdx == subArray.length; } AuxPoW(NetworkParameters params, @Nullable Message parent);  AuxPoW(NetworkParameters params, byte[] payload, int offset, Message parent, MessageSerializer serializer);  AuxPoW(NetworkParameters params, byte[] payload, @Nullable Message parent, MessageSerializer serializer); int getOptimalEncodingMessageSize(); @Override String toString(); String toString(@Nullable AbstractBlockChain chain); @Override boolean equals(Object o); @Override int hashCode(); AltcoinBlock getParentBlockHeader(); Transaction getCoinbase(); MerkleBranch getChainMerkleBranch(); MerkleBranch getCoinbaseBranch(); Transaction getTransaction(); void setCoinbaseBranch(final MerkleBranch merkleBranch); void setParentBlockHeader(final AltcoinBlock header); static final byte[] MERGED_MINING_HEADER; }
@Test public void testArrayMatch() { byte[] script = Utils.HEX.decode("089b911f5e471c0e1800f3384281ebec5b372fbb6f358790a92747ade271ccdf"); byte[] prefix = Utils.HEX.decode("089b911f"); byte[] suffix = Utils.HEX.decode("e271ccdf"); byte[] anywhere = Utils.HEX.decode("384281eb"); byte[] overTheEnd = Utils.HEX.decode("e271ccdf000000"); assertTrue(AuxPoW.arrayMatch(script, 0, prefix)); assertTrue(AuxPoW.arrayMatch(script, 28, suffix)); assertTrue(AuxPoW.arrayMatch(script, 11, anywhere)); assertFalse(AuxPoW.arrayMatch(script, 28, overTheEnd)); }