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


Java Block.isGenesis方法代码示例

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


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

示例1: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public boolean isValid(Block block, Block parent) {
    if(block.isGenesis()) {
        return true;
    }

    if(block.getMinGasPriceAsInteger() == null || parent == null) {
        logger.warn("PrevMinGasPriceRule - blockmingasprice or parent are null");
        return false;
    }

    BlockGasPriceRange range = new BlockGasPriceRange(parent.getMinGasPriceAsInteger());
    boolean result = range.inRange(block.getMinGasPriceAsInteger());
    if(!result) {
        logger.warn("Error validating Min Gas Price.");
        panicProcessor.panic("invalidmingasprice", "Error validating Min Gas Price.");
    }

    return range.inRange(block.getMinGasPriceAsInteger());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:21,代码来源:PrevMinGasPriceRule.java

示例2: isValid

import org.ethereum.core.Block; //导入方法依赖的package包/类
/**
 * Validate a block.
 * The validation includes
 * - Validate the header data relative to parent block
 * - Validate the transaction root hash to transaction list
 * - Validate uncles
 * - Validate transactions
 *
 * @param block        Block to validate
 * @return true if the block is valid, false if the block is invalid
 */
@Override
public boolean isValid(Block block) {
    if (block.isGenesis()) {
        return true;
    }

    Block parent = getParent(block);

    if(!this.blockParentValidator.isValid(block, parent)) {
        return false;
    }

    if(!this.blockValidator.isValid(block)) {
        return false;
    }

    return true;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:30,代码来源:BlockValidatorImpl.java

示例3: processBlockMessage

import org.ethereum.core.Block; //导入方法依赖的package包/类
/**
 * processBlockMessage processes a BlockMessage message, adding the block to the blockchain if appropriate, or
 * forwarding it to peers that are missing the Block.
 *
 * @param sender  the message sender.
 * @param message the BlockMessage.
 */
private void processBlockMessage(@Nonnull final MessageChannel sender, @Nonnull final BlockMessage message) {
    final Block block = message.getBlock();
    logger.trace("Process block {} {}", block.getNumber(), block.getShortHash());

    if (block.isGenesis()) {
        logger.trace("Skip block processing {} {}", block.getNumber(), block.getShortHash());
        return;
    }

    Metrics.processBlockMessage("start", block, sender.getPeerNodeID());

    if (!isValidBlock(block)) {
        logger.trace("Invalid block {} {}", block.getNumber(), block.getShortHash());
        recordEvent(sender, EventType.INVALID_BLOCK);
        return;
    }

    boolean wasOrphan = !this.blockProcessor.hasBlockInSomeBlockchain(block.getHash());
    BlockProcessResult result = this.blockProcessor.processBlock(sender, block);

    Metrics.processBlockMessage("blockProcessed", block, sender.getPeerNodeID());

    recordEvent(sender, EventType.VALID_BLOCK);
    tryRelayBlock(sender, block, wasOrphan, result);

    Metrics.processBlockMessage("finish", block, sender.getPeerNodeID());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:35,代码来源:NodeMessageHandler.java

示例4: getNextHashes

import org.ethereum.core.Block; //导入方法依赖的package包/类
private static Set<ByteArrayWrapper> getNextHashes(Set<ByteArrayWrapper> previousHashes, Set<ByteArrayWrapper> unknown, Blockchain blockChain, BlockStore store, boolean withUncles) {
    Set<ByteArrayWrapper> nextHashes = new HashSet<>();
    for (ByteArrayWrapper hash : previousHashes) {
        if (unknown.contains(hash)) {
            continue;
        }

        Block block = blockChain.getBlockByHash(hash.getData());
        if (block == null) {
            block = store.getBlockByHash(hash.getData());
        }

        if (block == null) {
            unknown.add(hash);
            continue;
        }

        if (!block.isGenesis() && !blockInSomeBlockChain(block, blockChain)) {
            nextHashes.add(new ByteArrayWrapper(block.getParentHash()));

            if (withUncles) {
                for (BlockHeader uncleHeader : block.getUncleList()) {
                    nextHashes.add(new ByteArrayWrapper(uncleHeader.getHash()));
                }
            }
        }
    }
    return nextHashes;
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:30,代码来源:BlockUtils.java


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