use of com.hedera.services.utils.BytesKey in project hedera-services by hashgraph.
the class CodeCache method getIfPresent.
public Code getIfPresent(final Address address) {
final var cacheKey = new BytesKey(address.toArray());
var code = cache.getIfPresent(cacheKey);
if (code == null) {
final var bytecode = entityAccess.fetchCodeIfPresent(accountIdFromEvmAddress(address));
if (bytecode != null) {
code = new Code(bytecode, Hash.hash(bytecode));
cache.put(cacheKey, code);
}
}
return code;
}
use of com.hedera.services.utils.BytesKey in project hedera-services by hashgraph.
the class CodeCacheTest method bytesKeyEquals.
@Test
void bytesKeyEquals() {
BytesKey key1 = new BytesKey("abc".getBytes());
BytesKey key2 = new BytesKey("abc".getBytes());
assertEquals(key1, key2);
assertEquals(key1, key1);
// Workaround to sonar code-smells. It should NOT be an error to use assertTrue/assertFalse.
boolean eq1 = key1.equals(null);
boolean eq2 = key1.equals("abc");
assertEquals(eq1, eq2);
}