主要实现功能:

CheckPowHash

// this function check whether the pow hash meets difficulty criteria

计算出来的哈希字符串与当前难度值进行比较。

转换成两个大数,进行比较。
(不涉及业务)

CheckPowHashBig

// this function check whether the pow hash meets difficulty criteria
// however, it take diff in  bigint format

计算出来的哈希字符串与当前难度值进行比较。
(原理和上面的 CheckPowHash 完全一样,只不过输入参数的类型有一点不同)

VerifyPoW

指定“区块”,验证其“哈希运算值”是否满足对其要求的“难度值”?
(和业务有关)

验证工作量证明,即验证难度是否符合预期。

Get_Difficulty_At_Tips

// NOTE: we need to evaluate if the mining adversary gains something, if the they set the time diff to 1
// we need to do more simulations and evaluations


难度调整体现在这里!

依赖方法:

HashToBig

ConvertDifficultyToBig

ConvertIntegerDifficultyToBig

find_best_tip_cumulative_difficulty

validate_tips

手段:

将两个对象转换成可比较的数据,这里是:big.Int

results matching ""

    No results matching ""