本文整理汇总了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);
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}