Open r3rcloak opened 5 years ago
Client calls GetBlockTrust()
in AddToBlockIndex()
to calculate bnChainTrust.
bnChainTrust
is calculated as 2**256 / (bnTarget+1)
bnTarget
is a function of nBits
:
bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
GetBlockTrust uses a trick in calculation to still use uint256 instead of uint512. I did some CPU profiling with Valgrind/KCachegrind on this before to see if I can reduce the CPU/mem load - there was an extremely large amount of calls to GetBlockTrust. Think we should stick with the uint256 implementation for that reason.
Cloak and PeerCoin etc use a variable called bnChainTrust (member of block index) to ascertain the current chain trust at the particular block height associated with the block index. Seeing as the code used to calculate bnChainTrust has separate paths for PoW and PoS, it is likely that this will need to be ported in some manner, even if that just involves tweaking the nChainTrust property for a block index in the new codebase.
More information to follow after some investigation...