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
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.
- toastmanAu/daowow:
apps/web/test/model-time.test.js - toastmanAu/daowow:
apps/web/test/round-rules.test.js
- 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)
- 2026-11-10 · toastmanAu/daowow · mais deste projeto
- 2026-10-24 · toastmanAu/ckb-watch-visualiser · mais deste projeto
- 2026-10-13 · toastmanAu/daowow · mais deste projeto
Mais sobre CKB node, RPC and indexer
- Validate header and epoch lookups before using timestamps
- Nervos DAO compensation from the header's accumulated rate (AR)
- Nervos DAO phase 1 withdrawing cells keep the DAO type; count deposits by 8 zero bytes of data
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.