本文整理了Java中org.bitcoinj.core.Utils.encodeCompactBits()
方法的一些代码示例,展示了Utils.encodeCompactBits()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.encodeCompactBits()
方法的具体详情如下:
包路径:org.bitcoinj.core.Utils
类名称:Utils
方法名:encodeCompactBits
暂无
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
void verifyDifficulty(BigInteger newTarget, Block nextBlock)
{
if (newTarget.compareTo(this.getMaxTarget()) > 0) {
log.info("Difficulty hit proof of work limit: {}", newTarget.toString(16));
newTarget = this.getMaxTarget();
}
int accuracyBytes = (int) (nextBlock.getDifficultyTarget() >>> 24) - 3;
long receivedTargetCompact = nextBlock.getDifficultyTarget();
// The calculated difficulty is to a higher precision than received, so reduce here.
BigInteger mask = BigInteger.valueOf(0xFFFFFFL).shiftLeft(accuracyBytes * 8);
newTarget = newTarget.and(mask);
long newTargetCompact = Utils.encodeCompactBits(newTarget);
if (newTargetCompact != receivedTargetCompact)
throw new VerificationException("Network provided difficulty bits do not match what was calculated: " +
Long.toHexString(newTargetCompact) + " vs " + Long.toHexString(receivedTargetCompact));
}
代码示例来源:origin: dogecoin/libdohj
return Utils.encodeCompactBits(newTarget);
代码示例来源:origin: dogecoin/libdohj
return Utils.encodeCompactBits(newTarget);
代码示例来源:origin: HashEngineering/dashj
long n2 = Utils.encodeCompactBits(n.toBigInteger(), false);
代码示例来源:origin: greenaddress/GreenBits
@Test
public void compactEncoding() throws Exception {
assertEquals(new BigInteger("1234560000", 16), Utils.decodeCompactBits(0x05123456L));
assertEquals(new BigInteger("c0de000000", 16), Utils.decodeCompactBits(0x0600c0de));
assertEquals(0x05123456L, Utils.encodeCompactBits(new BigInteger("1234560000", 16)));
assertEquals(0x0600c0deL, Utils.encodeCompactBits(new BigInteger("c0de000000", 16)));
}
代码示例来源:origin: fr.acinq/bitcoinj-core
long newTargetCompact = Utils.encodeCompactBits(newTarget);
代码示例来源:origin: HashEngineering/dashj
long newTargetCompact = Utils.encodeCompactBits(newTarget);
代码示例来源:origin: greenaddress/GreenBits
long newTargetCompact = Utils.encodeCompactBits(newTarget);
代码示例来源:origin: dogecoin/libdohj
long newTargetCompact = Utils.encodeCompactBits(newTarget);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
if (!maxTarget.equals(nextBlock.getDifficultyTargetAsInteger()))
throw new VerificationException("Testnet block transition that is not allowed: " +
Long.toHexString(Utils.encodeCompactBits(maxTarget)) + " (required min difficulty) vs " +
Long.toHexString(nextBlock.getDifficultyTarget()));
return;
代码示例来源:origin: HashEngineering/dashj
long newTargetCompact = Utils.encodeCompactBits(newTarget);
代码示例来源:origin: HashEngineering/dashj
long n2 = Utils.encodeCompactBits(n.toBigInteger(), false);
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
nPow = getMaxTarget();
if (nextBlock.getDifficultyTarget() != Utils.encodeCompactBits(nPow))
throw new VerificationException("Unexpected change in difficulty [6 blocks >12 hours] at height " + storedPrev.getHeight() +
": " + Long.toHexString(nextBlock.getDifficultyTarget()) + " vs " +
Utils.encodeCompactBits(nPow));
return;
代码示例来源:origin: dogecoin/libdohj
return Utils.encodeCompactBits(this.getMaxTarget());
return Utils.encodeCompactBits(maxTarget);
} else {
&& cursor.getHeader().getDifficultyTarget() == Utils.encodeCompactBits(this.getMaxTarget())) {
StoredBlock prevCursor = cursor.getPrev(blockStore);
if (prevCursor == null) {
代码示例来源:origin: dogecoin/libdohj
return Utils.encodeCompactBits(maxTarget);
} else {
&& cursor.getHeader().getDifficultyTarget() == Utils.encodeCompactBits(this.getMaxTarget())) {
StoredBlock prevCursor = cursor.getPrev(blockStore);
if (prevCursor == null) {
内容来源于网络,如有侵权,请联系作者删除!