private static BlockInfo getBlockInfoForHash(List<BlockInfo> blocks, byte[] hash){ for (BlockInfo blockInfo : blocks) if (areEqual(hash, blockInfo.getHash())) return blockInfo; return null; }
/** * check if param block is son of this block * * @param block - possible a son of this * @return - true if this block is parent of param block */ public boolean isParentOf(Block block) { return Arrays.areEqual(this.getHash(), block.getParentHash()); }
public boolean isEqual(Block block) { return Arrays.areEqual(this.getHash(), block.getHash()); }
@Override public synchronized BigInteger getTotalDifficultyForHash(byte[] hash){ Block block = this.getBlockByHash(hash); if (block == null) return ZERO; Long level = block.getNumber(); List<BlockInfo> blockInfos = index.get(level.intValue()); for (BlockInfo blockInfo : blockInfos) if (areEqual(blockInfo.getHash(), hash)) { return blockInfo.totalDifficulty; } return ZERO; }
@Test public void testAddressStringToBytes() { // valid address String HexStr = "6c386a4b26f73c802f34673f7248bb118f97424a"; byte[] expected = Hex.decode(HexStr); byte[] result = Utils.addressStringToBytes(HexStr); assertEquals(Arrays.areEqual(expected, result), true); // invalid address, we removed the last char so it cannot decode HexStr = "6c386a4b26f73c802f34673f7248bb118f97424"; expected = null; result = Utils.addressStringToBytes(HexStr); assertEquals(expected, result); // invalid address, longer than 20 bytes HexStr = new String(Hex.encode("I am longer than 20 bytes, i promise".getBytes())); expected = null; result = Utils.addressStringToBytes(HexStr); assertEquals(expected, result); // invalid address, shorter than 20 bytes HexStr = new String(Hex.encode("I am short".getBytes())); expected = null; result = Utils.addressStringToBytes(HexStr); assertEquals(expected, result); }
boolean asn1Equals(ASN1Primitive o) { if (!(o instanceof DERUTF8String)) { return false; } DERUTF8String s = (DERUTF8String)o; return Arrays.areEqual(string, s.string); }
boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof ASN1GeneralizedTime)) { return false; } return Arrays.areEqual(time, ((ASN1GeneralizedTime)o).time); }
boolean asn1Equals(ASN1Primitive o) { if (!(o instanceof DERUTF8String)) { return false; } DERUTF8String s = (DERUTF8String)o; return Arrays.areEqual(string, s.string); }
boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof DERApplicationSpecific)) { return false; } DERApplicationSpecific other = (DERApplicationSpecific)o; return isConstructed == other.isConstructed && tag == other.tag && Arrays.areEqual(octets, other.octets); }
public boolean equals(Object obj) { if (!(obj instanceof SessionID)) { return false; } SessionID other = (SessionID)obj; return Arrays.areEqual(id, other.id); }
boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof DERNumericString)) { return false; } DERNumericString s = (DERNumericString)o; return Arrays.areEqual(string, s.string); }
boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof DERVisibleString)) { return false; } return Arrays.areEqual(string, ((DERVisibleString)o).string); }
boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof DERVideotexString)) { return false; } DERVideotexString s = (DERVideotexString)o; return Arrays.areEqual(string, s.string); }
public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Fingerprint) { return Arrays.areEqual(((Fingerprint)o).fingerprint, fingerprint); } return false; }
public boolean equals(Object o) { if (o instanceof OidHandle) { return Arrays.areEqual(enc, ((OidHandle)o).enc); } return false; } }
public boolean equals(Object o) { if (!(o instanceof PackedDate)) { return false; } PackedDate other = (PackedDate)o; return Arrays.areEqual(time, other.time); }
boolean asn1Equals( ASN1Primitive o) { if (!(o instanceof ASN1Integer)) { return false; } ASN1Integer other = (ASN1Integer)o; return Arrays.areEqual(bytes, other.bytes); }
public boolean equals(Object obj) { if (obj instanceof LongPolynomial2) { return Arrays.areEqual(coeffs, ((LongPolynomial2)obj).coeffs); } else { return false; } } }
private void compareDigest(TimeStampToken timeStampToken, byte[] digest) throws ImprintDigestInvalidException { TimeStampTokenInfo info = timeStampToken.getTimeStampInfo(); byte[] tsrMessageDigest = info.getMessageImprintDigest(); if (!Arrays.areEqual(digest, tsrMessageDigest)) { throw new ImprintDigestInvalidException("hash calculated is different from MessageImprintDigest found in TimeStampToken", timeStampToken); } }
private void compareDigest(TimeStampToken timeStampToken, byte[] digest) throws ImprintDigestInvalidException { TimeStampTokenInfo info = timeStampToken.getTimeStampInfo(); byte[] tsrMessageDigest = info.getMessageImprintDigest(); if (!Arrays.areEqual(digest, tsrMessageDigest)) { throw new ImprintDigestInvalidException("hash calculated is different from MessageImprintDigest found in TimeStampToken", timeStampToken); } }