本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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()));
}
示例5: processBlock
import org.ethereum.core.Block; //导入方法依赖的package包/类
@Override
public BlockProcessResult processBlock(Block block) {
return new BlockProcessResult(false, null, block.getShortHash(), Duration.ZERO);
}