CKB Pulse

Todas as lições · CKB node, RPC and indexer · Começa aqui · Glossário

Decoding the packed epoch field (number, index, length)PráticoVista outra vez

Vista outra vez · Verificação: certa · Verificada em 2026-11-19

A CKB header epoch field packs the epoch number in the low 24 bits, the index in the next 16 bits (shift 24) and the epoch length in the next 16 bits (shift 40). When estimating time to a target epoch from the tip, subtract the fraction already spent (index * epoch duration / length) and guard against length 0 to avoid division by zero.

Porque importa: Reading the raw epoch hex as a number, or masking it wrongly, gives nonsense epoch numbers for window checks. Ignoring the index fraction makes time-to-epoch estimates off by up to a whole epoch, about four hours.

Padrão

Preferir
number: v & 0xffffffn, index: (v >> 24n) & 0xffffn, length: (v >> 40n) & 0xffffn,

Tirado do commit, encurtado.

Um teste mudou no mesmo commit

Está ao lado da correcção. Nós não o corremos.

Conceitos
Since and time locks, Data encoding (molecule, hex, bigints)
Evidência
Vista outra vez: vista em dois ou mais projetos
Vista pela primeira vez
2026-11-10
Última mudança
2026-11-10
Última verificação
2026-11-19
Verificação contra o commit
certa: a lição sai do commit e continua a valer no código de hoje

Fontes (3)

Mais sobre CKB node, RPC and indexer

Ver as 45 deste tema

Manténs um projeto de onde esta lição veio? Confirma ou corrige

Citar esta lição
LusoCryptoLabs, "Decoding the packed epoch field (number, index, length)", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/decoding-the-packed-epoch-field-number-index-length, CC BY 4.0, last changed 2026-11-10.

Tiradas de commits públicos e verificadas contra o commit de onde cada uma veio e o código de hoje do projeto. Lê a fonte antes de confiar numa. Texto sob CC BY 4.0: dá crédito à LusoCryptoLabs, CKB lessons, com uma ligação para a lição. Queres que uma lição seja mudada ou retirada? Abre um issue.