当前位置: 首页>>代码示例>>Java>>正文


Java ByteUtil.fastEquals方法代码示例

本文整理汇总了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);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:17,代码来源:SyncProcessor.java

示例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;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:15,代码来源:BlockUnclesHashValidationRule.java

示例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();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:14,代码来源:CheckingBestHeaderSyncState.java

示例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);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:8,代码来源:ByteArrayWrapper.java

示例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());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:43,代码来源:DownloadingHeadersSyncState.java

示例6: equalsToByteArray

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public boolean equalsToByteArray(byte[] otherData) {
    return otherData != null && ByteUtil.fastEquals(data, otherData);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:4,代码来源:ByteArrayWrapper.java

示例7: fastEquals

import org.ethereum.util.ByteUtil; //导入方法依赖的package包/类
public boolean fastEquals(Block block) {
    return block != null && ByteUtil.fastEquals(this.getHash(), block.getHash());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:4,代码来源:Block.java


注:本文中的org.ethereum.util.ByteUtil.fastEquals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。