CKB Pulse

全部经验 · Rust scripts and ckb-std · 从这里开始 · 术语表

Comparing packed epoch values实践再次出现

再次出现 · 核对结果:正确 · 核对于 2026-11-19

Decode epochs into (number, index, length) before comparing them. Compare the fractional parts by cross-multiplying (index_a*length_b vs index_b*length_a), because epoch length varies and raw packed integers don't order correctly.

为什么重要: Without decoding, a test or script judges epoch maturity wrongly, because the packed layout puts length and index above the epoch number. The daowow test would then expect an Immature refusal after the savings term had already ended.

代码模式

term_over = tip_n > term_n or (tip_n == term_n and tip_i*term_l >= term_i*tip_l); since = hex(0x2000000000000000 | epoch)

同一提交中改动了测试

它与修复在一起,我们没有运行它。

概念
Since and time locks
证据
再次出现: 在两个或以上项目中出现
首次出现
2026-11-18
最近改动
2026-11-18
最近核对
2026-11-19
对照提交的核对结果
正确:这条经验出自该提交,并且在今天的代码中仍然成立

来源(2)

更多关于Rust scripts and ckb-std

查看此主题的全部 35 条

你维护这条经验的来源项目吗?请确认或纠正

引用这条经验
LusoCryptoLabs, "Comparing packed epoch values", CKB lessons, https://pulse.lusocryptolabs.com/learned/scripts/comparing-packed-epoch-values, CC BY 4.0, last changed 2026-11-18.

取自公开提交,并对照每条经验的来源提交和项目当前代码做了核对。使用前请先读来源。 文本采用 CC BY 4.0:请署名 LusoCryptoLabs, CKB lessons,并附上经验的链接。 想修改或撤下某条经验?请提交 issue。