gen

command
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package main is the cbor-gen driver for pkg/core.

It emits pkg/core/cbor_gen.go with struct-as-array (tuple) CBOR codecs for every exported wire type in the package, per ADR-009 §2 (struct-as-array + append-only evolution). Ported from clearnet/clearing/core/gen, trimmed to the types that moved into the SDK.

Invocation

go generate ./pkg/core/...

The wrapper //go:generate directive lives in pkg/core/generate.go so the generator picks it up through the package root. Never call this main directly from tests or application code; it is a build-time tool.

Evolution rules (ADR-009 §2):

  • Field order in a target struct IS the wire encoding. Append only; never insert, reorder, rename, or remove.
  • When adding a new target type, add it at the end of the tuple list below. The order here is not wire-significant (each struct is independent), but stable ordering keeps generated-file diffs minimal.
  • Types with non-empty embedded or nested struct fields (e.g. BurnReceipt embeds BlockEntryRef) serialize the nested struct in its declared position; the nested type itself must also be a codec target so cbor-gen can emit the nested MarshalCBOR call.

Jump to

Keyboard shortcuts

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