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


Java Block.getShortHash方法代码示例

本文整理汇总了Java中org.ethereum.core.Block.getShortHash方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getShortHash方法的具体用法?Java Block.getShortHash怎么用?Java Block.getShortHash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ethereum.core.Block的用法示例。


在下文中一共展示了Block.getShortHash方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block, Block parent) {
    final String shortHash = block.getShortHash();
    logger.debug("Validating block {}", shortHash);
    for(BlockParentDependantValidationRule rule : this.rules) {
        if(!rule.isValid(block, parent)) {
            logger.warn("Error Validating block {}", shortHash);
            return false;
        }
    }
    return true;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:13,代码来源:BlockParentCompositeRule.java

示例2: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block) {
    String shortHash = block.getShortHash();
    logger.debug("Validating block {}", shortHash);
    for(BlockValidationRule rule : this.rules) {
        if(!rule.isValid(block)) {
            logger.warn("Error Validating block {}", shortHash);
            return false;
        }
    }
    return true;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:13,代码来源:BlockCompositeRule.java

示例3: processBlock

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public BlockProcessResult processBlock(MessageChannel sender, Block block) {
    Map<ByteArrayWrapper, ImportResult> connectionsResult = new HashMap<>();
    this.blocks.add(block);
    connectionsResult.put(new ByteArrayWrapper(block.getHash()), ImportResult.IMPORTED_BEST);
    return new BlockProcessResult(false, connectionsResult, block.getShortHash(), Duration.ZERO);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:8,代码来源:SimpleBlockProcessor.java

示例4: processBlock

import org.ethereum.core.Block; //导入方法依赖的package包/类
public BlockProcessResult processBlock(MessageChannel sender, @Nonnull Block block, boolean ignoreMissingHashes) {
    Instant start = Instant.now();
    long bestBlockNumber = this.getBestBlockNumber();
    long blockNumber = block.getNumber();
    final ByteArrayWrapper blockHash = new ByteArrayWrapper(block.getHash());
    int syncMaxDistance = syncConfiguration.getChunkSize() * syncConfiguration.getMaxSkeletonChunks();

    tryReleaseStore(bestBlockNumber);
    store.removeHeader(block.getHeader());
    unknownBlockHashes.remove(blockHash);

    if (blockNumber > bestBlockNumber + syncMaxDistance) {
        logger.trace("Block too advanced {} {} from {} ", blockNumber, block.getShortHash(),
                sender != null ? sender.getPeerNodeID().toString() : "N/A");
        return new BlockProcessResult(false, null, block.getShortHash(),
                Duration.between(start, Instant.now()));
    }

    if (sender != null) {
        nodeInformation.addBlockToNode(blockHash, sender.getPeerNodeID());
    }

    // already in a blockchain
    if (BlockUtils.blockInSomeBlockChain(block, blockchain)) {
        logger.trace("Block already in a chain {} {}", blockNumber, block.getShortHash());
        return new BlockProcessResult(false, null, block.getShortHash(),
                Duration.between(start, Instant.now()));
    }
    trySaveStore(block);

    Set<ByteArrayWrapper> unknownHashes = BlockUtils.unknownDirectAncestorsHashes(block, blockchain, store);
    // We can't add the block if there are missing ancestors or uncles. Request the missing blocks to the sender.
    if (!unknownHashes.isEmpty()) {
        if (!ignoreMissingHashes){
            logger.trace("Missing hashes for block in process {} {}", blockNumber, block.getShortHash());
            requestMissingHashes(sender, unknownHashes);
        }
        return new BlockProcessResult(false, null, block.getShortHash(),
                Duration.between(start, Instant.now()));
    }

    logger.trace("Trying to add to blockchain");

    Map<ByteArrayWrapper, ImportResult> connectResult = connectBlocksAndDescendants(sender,
            BlockUtils.sortBlocksByNumber(this.getParentsNotInBlockchain(block)), ignoreMissingHashes);

    return new BlockProcessResult(true, connectResult, block.getShortHash(),
            Duration.between(start, Instant.now()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:50,代码来源:BlockSyncService.java

示例5: processBlock

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public BlockProcessResult processBlock(Block block) {
    return new BlockProcessResult(false, null, block.getShortHash(), Duration.ZERO);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:5,代码来源:SimpleSyncInformation.java


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