本文整理汇总了Java中org.bitcoinj.core.StoredBlock.deserializeCompact方法的典型用法代码示例。如果您正苦于以下问题:Java StoredBlock.deserializeCompact方法的具体用法?Java StoredBlock.deserializeCompact怎么用?Java StoredBlock.deserializeCompact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.core.StoredBlock
的用法示例。
在下文中一共展示了StoredBlock.deserializeCompact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.bitcoinj.core.StoredBlock; //导入方法依赖的package包/类
public StoredBlock get(Sha256Hash hash, boolean wasUndoableOnly) throws BlockStoreException {
// Optimize for chain head
if (chainHeadHash != null && chainHeadHash.equals(hash))
return chainHeadBlock;
if (verifiedChainHeadHash != null && verifiedChainHeadHash.equals(hash))
return verifiedChainHeadBlock;
if (instrument)
beginMethod("get");// ignore optimised case as not interesting for
// tuning.
boolean undoableResult;
byte[] result = batchGet(getKey(KeyType.HEADERS_ALL, hash));
if (result == null) {
if (instrument)
endMethod("get");
return null;
}
undoableResult = (result[96] == 1 ? true : false);
if (wasUndoableOnly && !undoableResult) {
if (instrument)
endMethod("get");
return null;
}
// TODO Should I chop the last byte off? Seems to work with it left
// there...
StoredBlock stored = StoredBlock.deserializeCompact(params, ByteBuffer.wrap(result));
stored.getHeader().verifyHeader();
if (instrument)
endMethod("get");
return stored;
}