本文整理汇总了Java中org.ethereum.util.ByteUtil.fastEquals方法的典型用法代码示例。如果您正苦于以下问题:Java ByteUtil.fastEquals方法的具体用法?Java ByteUtil.fastEquals怎么用?Java ByteUtil.fastEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.ethereum.util.ByteUtil
的用法示例。
在下文中一共展示了ByteUtil.fastEquals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: blockHeaderIsValid
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public boolean blockHeaderIsValid(@Nonnull BlockHeader header, @Nonnull BlockHeader parentHeader) {
if (!ByteUtil.fastEquals(parentHeader.getHash(), header.getParentHash())) {
return false;
}
if (header.getNumber() != parentHeader.getNumber() + 1) {
return false;
}
if (!blockHeaderIsValid(header)) {
return false;
}
return blockParentValidationRule.validate(header, parentHeader);
}
示例2: isValid
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block) {
byte[] unclesHeader = block.getHeader().getUnclesHash();
byte[] unclesBlock = HashUtil.sha3(BlockHeader.getUnclesEncoded(block.getUncleList()));
if (!ByteUtil.fastEquals(unclesHeader, unclesBlock)) {
String message = String.format("Block's given Uncle Hash doesn't match: %s != %s",
Hex.toHexString(unclesHeader), Hex.toHexString(unclesBlock));
logger.warn(message);
panicProcessor.panic("invaliduncle", message);
return false;
}
return true;
}
示例3: newBlockHeaders
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void newBlockHeaders(List<BlockHeader> chunk){
BlockHeader header = chunk.get(0);
if (!ByteUtil.fastEquals(header.getHash(), miniChunk.getHash()) ||
!syncInformation.blockHeaderIsValid(header)) {
syncEventsHandler.onErrorSyncing(
"Invalid chunk received from node {}", EventType.INVALID_HEADER, this.getClass(),
syncInformation.getSelectedPeerId());
return;
}
syncEventsHandler.startFindingConnectionPoint();
}
示例4: equals
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public boolean equals(Object other) {
if (!(other instanceof ByteArrayWrapper)) {
return false;
}
byte[] otherData = ((ByteArrayWrapper) other).data;
return ByteUtil.fastEquals(data, otherData);
}
示例5: newBlockHeaders
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
@Override
public void newBlockHeaders(List<BlockHeader> chunk) {
Optional<ChunkDescriptor> currentChunk = chunksDownloadHelper.getCurrentChunk();
if (!currentChunk.isPresent()
|| chunk.size() != currentChunk.get().getCount()
|| !ByteUtil.fastEquals(chunk.get(0).getHash(), currentChunk.get().getHash())) {
syncEventsHandler.onErrorSyncing(
"Invalid chunk received from node {} {}", EventType.INVALID_MESSAGE,
syncInformation.getSelectedPeerId(), currentChunk.get().getHash());
return;
}
Deque<BlockHeader> headers = new ArrayDeque<>();
// the headers come ordered by block number desc
// we start adding the first parent header
headers.add(chunk.get(chunk.size() - 1));
for (int k = 1; k < chunk.size(); ++k) {
BlockHeader parentHeader = chunk.get(chunk.size() - k);
BlockHeader header = chunk.get(chunk.size() - k - 1);
if (!syncInformation.blockHeaderIsValid(header, parentHeader)) {
syncEventsHandler.onErrorSyncing(
"Invalid header received from node {} {} {}", EventType.INVALID_HEADER,
syncInformation.getSelectedPeerId(), header.getNumber(), header.getShortHash());
return;
}
headers.add(header);
}
pendingHeaders.add(headers);
if (!chunksDownloadHelper.hasNextChunk()) {
// Finished verifying headers
syncEventsHandler.startDownloadingBodies(pendingHeaders, skeletons);
return;
}
resetTimeElapsed();
syncEventsHandler.sendBlockHeadersRequest(chunksDownloadHelper.getNextChunk());
}
示例6: equalsToByteArray
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public boolean equalsToByteArray(byte[] otherData) {
return otherData != null && ByteUtil.fastEquals(data, otherData);
}
示例7: fastEquals
import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public boolean fastEquals(Block block) {
return block != null && ByteUtil.fastEquals(this.getHash(), block.getHash());
}