Skip to content

Export ordinals

Every method in a block's interface has a number, its export ordinal. Callers and the kernel address a method by that number, and the number stays with the method for the life of the interface. A rename changes what people call the method; the number keeps identifying it.

The ledger block's two methods, as generation records them in the interface seed:

"export_ordinals": {"charge": 7, "charge_status": 9}

How the number is used

Bake builds the capsule's executable surface index from these numbers. Each entry maps a method to its number and to the dispatch module that routes calls:

"entries": {
  "charge": {"export_ordinal": 7, "adapter_entrypoint": "capsule.acme.billing.ledger_adapter_dispatch:dispatch"},
  "charge_status": {"export_ordinal": 9, "adapter_entrypoint": "capsule.acme.billing.ledger_adapter_dispatch:dispatch"}
}

A call names method 7. The kernel finds it in the surface index, and the dispatch module inside the capsule calls charge. See Capsule-local adapter dispatch.

Numbers are kept, gaps are normal

The numbers come from the interface definition, and every stage carries them through unchanged: generation copies them into the seed, and bake builds the surface index from them. Numbers need not be consecutive. charge at 7 and charge_status at 9 with 8 retired is an ordinary interface.

Retiring a number

A removed method's number is retired in the interface definition, with the name it used to have:

"reserved_methods": [{"ordinal": 8, "former_name": "legacy_charge"}]

A retired number is refused if any method uses it again. A caller built against an older version therefore gets a refusal when it calls method 8, rather than a different method that took over the number. See Interface evolution and compatibility.