未来币透明锻造机制原理

锻造机制原理用公式表达就是:
1.hit

static BigInteger getHit(byte[] publicKey, Block block) {

 MessageDigest digest = Crypto.sha256();
 digest.update(block.getGenerationSignature());
 byte[] generationSignatureHash = digest.digest(publicKey);
 BigInteger hit = BigInteger(1, new byte[] {generationSignatureHash[7], generationSignatureHash[6],    generationSignatureHash[5], generationSignatureHash[4], generationSignatureHash[3],  generationSignatureHash[2], generationSignatureHash[1], generationSignatureHash[0]});
 return hit;

}

2.target

static boolean getTarget(BigInteger effectiveBalance, Block previousBlock) {

elapsedTime = getElapsedTime - block.getLastTime()
BigInteger effectiveBaseTarget = BigInteger.valueOf(previousBlock.getBaseTarget()).multiply(effectiveBalance);
BigInteger prevTarget = effectiveBaseTarget.multiply(BigInteger.valueOf(elapsedTime - 1));
BigInteger target = prevTarget.add(effectiveBaseTarget);

}

判断公式

/**
 * 如果当前账户的hit

所以对于下一个区块的打包,一个特定的账户来说,hit是确定的,target的balance是确定的,只有baseTarget和times随着时间不断变大,其中baseTarget的变化和时间是成正比的

target = balance * times * (a*times*baseTarget) = a*balance*baseTarget*times^2 (备注:a是系数)

times = sqrt{hit/(a*balance*baseTarget)};

所以系统可以收集所有账户,然后分别计算它们所需时间,时间最小的即为下一个打包者。
故透明锻造机制可以预测下一个区块由谁、什么时间打包完成。

你可能感兴趣的:(未来币透明锻造机制原理)