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


Java Block.getParentHash方法代码示例

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


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

示例1: saveBlock

import org.ethereum.core.Block; //导入方法依赖的package包/类
public synchronized void saveBlock(Block block) {
    ByteArrayWrapper key = new ByteArrayWrapper(block.getHash());
    ByteArrayWrapper pkey = new ByteArrayWrapper(block.getParentHash());
    Long nkey = Long.valueOf(block.getNumber());
    this.blocks.put(key, block);

    Set<Block> bsbynumber = this.blocksbynumber.get(nkey);

    if (bsbynumber == null) {
        bsbynumber = new HashSet<>();
        this.blocksbynumber.put(nkey, bsbynumber);
    }

    bsbynumber.add(block);

    Set<Block> bsbyphash = this.blocksbyparent.get(pkey);

    if (bsbyphash == null) {
        bsbyphash = new HashSet<>();
        this.blocksbyparent.put(pkey, bsbyphash);
    }

    bsbyphash.add(block);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:25,代码来源:BlockStore.java

示例2: createWithCompleteArguments

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void createWithCompleteArguments() {
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block = BlockGenerator.getInstance().createChildBlock(genesis);
    Status status = new Status(block.getNumber(), block.getHash(), block.getParentHash(), BigInteger.TEN);

    StatusMessage message = new StatusMessage(status);

    Assert.assertEquals(MessageType.STATUS_MESSAGE, message.getMessageType());
    Assert.assertSame(status, message.getStatus());
    Assert.assertEquals(1, message.getStatus().getBestBlockNumber());
    Assert.assertArrayEquals(block.getHash(), message.getStatus().getBestBlockHash());
    Assert.assertNotNull(message.getStatus().getBestBlockParentHash());
    Assert.assertArrayEquals(block.getParentHash(), message.getStatus().getBestBlockParentHash());
    Assert.assertNotNull(message.getStatus().getTotalDifficulty());
    Assert.assertEquals(BigInteger.TEN, message.getStatus().getTotalDifficulty());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:18,代码来源:StatusMessageTest.java

示例3: sendStatusToAll

import org.ethereum.core.Block; //导入方法依赖的package包/类
private synchronized void sendStatusToAll() {
    BlockChainStatus blockChainStatus = this.blockProcessor.getBlockchain().getStatus();
    Block block = blockChainStatus.getBestBlock();
    BigInteger totalDifficulty = blockChainStatus.getTotalDifficulty();

    Status status = new Status(block.getNumber(), block.getHash(), block.getParentHash(), totalDifficulty);
    logger.trace("Sending status best block to all {} {}", status.getBestBlockNumber(), Hex.toHexString(status.getBestBlockHash()).substring(0, 8));
    this.channelManager.broadcastStatus(status);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:10,代码来源:NodeMessageHandler.java

示例4: removeBlock

import org.ethereum.core.Block; //导入方法依赖的package包/类
public synchronized void removeBlock(Block block) {
    if (!this.hasBlock(block.getHash())) {
        return;
    }

    ByteArrayWrapper key = new ByteArrayWrapper(block.getHash());
    ByteArrayWrapper pkey = new ByteArrayWrapper(block.getParentHash());
    Long nkey = Long.valueOf(block.getNumber());

    this.blocks.remove(key);

    removeBlockByNumber(key, nkey);
    removeBlockByParent(key, pkey);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:15,代码来源:BlockStore.java

示例5: getFullStatus

import org.ethereum.core.Block; //导入方法依赖的package包/类
public Status getFullStatus() {
    Block block = this.getBestBlock();
    return new Status(block.getNumber(), block.getHash(), block.getParentHash(), this.getTotalDifficulty());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:5,代码来源:SimpleNode.java


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