encode

package
v0.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package encode builds the push frames the bridge sends back up the tunnel.

These are the exact inverse of what the retrieval plane decodes, and the two directions are deliberately kept in one repo so they cannot drift: a subtree that arrives as BRC-143 and one this cluster produced must be byte-identical on the wire.

Every frame is self-verified against the shared codec before it is returned. The lanes carry bare objects (no length prefix, no sync marker), so a frame that sizes wrong would not merely be rejected, it would desynchronise the stream and cost every object behind it.

Index

Constants

This section is empty.

Variables

View Source
var CoinbasePlaceholder = [32]byte{
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
}

CoinbasePlaceholder is node 0 of a block's first subtree: 32 bytes of 0xFF standing in for the coinbase, which is carried in-band in the block frame instead. Detected by value, so it must be exact.

Functions

func Subtree

func Subtree(root [32]byte, nodes [][32]byte) ([]byte, error)

Subtree builds a BRC-143 subtree push frame.

root[32] | NodeCount u64 BE | NodeCount × hash[32]

root and nodes are in internal (wire) byte order. The root must be the merkle root the node list reproduces, the receiving cluster rebuilds the tree and rejects a mismatch.

Types

type Block

type Block struct {
	Header       []byte     // 80 bytes, consensus layout
	TxCount      uint64     // transactions in the block, including the coinbase
	SizeInBytes  uint64     // serialized block size
	SubtreeRoots [][32]byte // ordered, internal byte order
	Coinbase     []byte     // full coinbase transaction, carried in-band
	Height       uint64
	CoinbaseBUMP []byte // BRC-74 merkle path for the coinbase; may be empty
}

Block describes a BRC-144 block push frame.

func (Block) Encode

func (b Block) Encode() ([]byte, error)

Encode builds the BRC-144 frame.

header[80] | TxCount u64 BE | SizeInBytes u64 BE | SubtreeCount u64 BE |
roots[32×M] | coinbase (self-delimiting) | Height u64 BE |
BUMPLen u64 BE | BUMP

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL