Hi, I’ve been reviewing the Scala code related to solution verification and particularly how the diffculty is calculated.
I found that for a recent block:
https://explorer.ergoplatform.com/en/blocks/5571af507c19d938e53bb8520df26fc314dd61f5395011a842f7b7aa9ab3c28d
The “nBits” are: 117968545 which is hex: 0x7080ea1
This value is passed to the method RequiredDifficulty.decodeCompactBits which look like it returns the “difficulty” which for this block is: 2267884466208768 which is hex: 0x80EA100000000.
Then in AutolykosPowScheme.scala this code divides “q” by the difficulty but “q” is not defined anywhere I can find:
204 /**
205 * Get target `b` from encoded difficulty `nBits`
206 */
207 private[mining] def getB(nBits: Long): BigInt = {
208 q / RequiredDifficulty.decodeCompactBits(nBits)
209 }
Can anyone tell me what “q” is?
I’m looking for an example of the 32 byte value “b” from AutolykosPowScheme.validate(). Thanks!