CKB Pulse

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

Filter prefix get_cells results by data length before decodingPráticoDe uma correção

De uma correção · Verificação: certa · Verificada em 2026-11-19

A get_cells query with script_search_mode "prefix" and args "0x" returns every live cell whose script has that code hash and hash_type, whatever its args, so it can include cells of the same script with a different data layout (for example a script that owns both a state cell and a ledger cell). Check output_data length, or catch the decode error, and skip the cell before calling a strict decoder. Otherwise one unexpected cell throws and the whole result list is lost.

Porque importa: Without the length check one cell with a different data length makes the strict decoder throw, and the page shows no rounds at all instead of the rounds that exist.

Padrão

Preferir
if (data.length !== ROUND_CONFIG_SIZE) continue; // not a round config cell

Tirado do commit, encurtado.

Um teste mudou no mesmo commit

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

Conceitos
Indexer queries and cell collection, Data encoding (molecule, hex, bigints)
Evidência
De uma correção: de um projeto, verificada contra o commit
Vista pela primeira vez
2026-09-18
Última mudança
2026-09-18
Ú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 (1)

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, "Filter prefix get_cells results by data length before decoding", CKB lessons, https://pulse.lusocryptolabs.com/learned/node/filter-prefix-get-cells-results-by-data-length-before-decodi, CC BY 4.0, last changed 2026-09-18.

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.