"epoch": "0x70806450000aa"
求问解析格式是不是:
[0x708] - epoch length
[0x0645] - current progress
[0x000aa] - epoch number
前 3 位、4 - 7 位、8 - 12 位分别表示三个字段,是这样吗?
我追这个格式的时候要么扎进 ruby,要么扎进 rust,都是看不太懂的语言,太南了
CKB·DEV 问题镜像: https://ckb.dev/topic/22
"epoch": "0x70806450000aa"
求问解析格式是不是:
[0x708] - epoch length
[0x0645] - current progress
[0x000aa] - epoch number
前 3 位、4 - 7 位、8 - 12 位分别表示三个字段,是这样吗?
我追这个格式的时候要么扎进 ruby,要么扎进 rust,都是看不太懂的语言,太南了
CKB·DEV 问题镜像: https://ckb.dev/topic/22
Go 版本的
所以是按位算的,epoch 字段是个 uint64,其中:
Current epoch information. Assume
number
represents the current epoch number,index
represents the index of the block in the current epoch(start at 0),length
represents the length of current epoch. The value store here will then be(number & 0xFFFFFF) | ((index & 0xFFFF) << 24) | ((length & 0xFFFF) << 40)
impl EpochNumberWithFraction {
pub const NUMBER_OFFSET: usize = 0;
pub const NUMBER_BITS: usize = 24;
pub const INDEX_OFFSET: usize = Self::NUMBER_BITS;
pub const INDEX_BITS: usize = 16;
pub const LENGTH_OFFSET: usize = Self::NUMBER_BITS + Self::INDEX_BITS;
pub const LENGTH_BITS: usize = 16;
pub const fn new_unchecked(number: u64, index: u64, length: u64) -> Self {
EpochNumberWithFraction(
(length << Self::LENGTH_OFFSET)
| (index << Self::INDEX_OFFSET)
| (number << Self::NUMBER_OFFSET),
)
}
多谢,RFC 看来经常更新,不能只 watch release 了