Files
zeekay 2210675e6e The info, admin and health replies cross the plane carrying their values
A ZAP field is an offset. Eight of these replies held a map, which has no
order to give one, so the reply could not cross between two processes at
all. Two more held values whose fields are every one unexported —
netip.AddrPort, time.Time — and those are worse: they are not refused, they
derive an EMPTY layout, so the reply crossed, reported no error and carried
nothing. GetNodeIPReply has one field, so its whole answer was blank. And a
health check says what it likes, so its details were an `any`, which has no
shape until it holds something.

Each map is now a list of a stated element type, ordered by the key it was
an object of. An address is the text netip already wrote for it, an instant
is three numbers, and a check details are the bytes of their own JSON —
the one shape an object, a string and a list all share.

The JSON does not move. Every list marshals to the object it replaced and
reads one back, and wire_test.go holds that against the old shape spelled
out as a literal rather than against itself. The order is new where there
was none: a map answered the same question two ways.

APIReply also states the status it carries, so the 503 a probe reads and
the healthy a person reads are one fact computed once.
2026-08-29 22:53:03 -07:00

705 lines
18 KiB
Go

// Code generated by zip; DO NOT EDIT.
package types
import (
"encoding/binary"
"encoding/json"
"fmt"
"strings"
formatting "github.com/luxfi/formatting"
zap "github.com/zap-proto/go"
)
// ---- EmptyReply --------------------------------------------------------
const (
emptyReplySize = 0
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*EmptyReply)(nil)
// MarshalZAP writes EmptyReply from constant offsets.
func (x *EmptyReply) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(emptyReplySize + 256)
ob := b.StartObject(emptyReplySize)
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads EmptyReply out of the buffer that arrived.
func (x *EmptyReply) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("EmptyReply: %w", err)
}
_ = m
return nil
}
// ---- FormattedTx -------------------------------------------------------
const (
formattedTxTxAt = 0
formattedTxEncodingAt = 8
formattedTxSize = 16
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*FormattedTx)(nil)
// MarshalZAP writes FormattedTx from constant offsets.
func (x *FormattedTx) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(formattedTxSize + 256)
ob := b.StartObject(formattedTxSize)
ob.SetText(formattedTxTxAt, string(x.Tx))
ob.SetUint8(formattedTxEncodingAt, uint8(x.Encoding))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads FormattedTx out of the buffer that arrived.
func (x *FormattedTx) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("FormattedTx: %w", err)
}
o := m.Root()
x.Tx = string(strings.Clone(o.Text(formattedTxTxAt)))
x.Encoding = formatting.Encoding(o.Uint8(formattedTxEncodingAt))
return nil
}
// ---- GetBlockArgs ------------------------------------------------------
const (
getBlockArgsBlockIDAt = 0
getBlockArgsEncodingAt = 32
getBlockArgsSize = 40
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetBlockArgs)(nil)
// MarshalZAP writes GetBlockArgs from constant offsets.
func (x *GetBlockArgs) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getBlockArgsSize + 256)
ob := b.StartObject(getBlockArgsSize)
ob.SetBytesFixed(getBlockArgsBlockIDAt, x.BlockID[:])
ob.SetUint8(getBlockArgsEncodingAt, uint8(x.Encoding))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetBlockArgs out of the buffer that arrived.
func (x *GetBlockArgs) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetBlockArgs: %w", err)
}
o := m.Root()
copy(x.BlockID[:], o.BytesFixed(getBlockArgsBlockIDAt, 32))
x.Encoding = formatting.Encoding(o.Uint8(getBlockArgsEncodingAt))
return nil
}
// ---- GetBlockByHeightArgs ----------------------------------------------
const (
getBlockByHeightArgsHeightAt = 0
getBlockByHeightArgsEncodingAt = 8
getBlockByHeightArgsSize = 16
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetBlockByHeightArgs)(nil)
// MarshalZAP writes GetBlockByHeightArgs from constant offsets.
func (x *GetBlockByHeightArgs) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getBlockByHeightArgsSize + 256)
ob := b.StartObject(getBlockByHeightArgsSize)
ob.SetUint64(getBlockByHeightArgsHeightAt, uint64(x.Height))
ob.SetUint8(getBlockByHeightArgsEncodingAt, uint8(x.Encoding))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetBlockByHeightArgs out of the buffer that arrived.
func (x *GetBlockByHeightArgs) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetBlockByHeightArgs: %w", err)
}
o := m.Root()
x.Height = Uint64(o.Uint64(getBlockByHeightArgsHeightAt))
x.Encoding = formatting.Encoding(o.Uint8(getBlockByHeightArgsEncodingAt))
return nil
}
// ---- GetBlockResponse --------------------------------------------------
const (
getBlockResponseBlockAt = 0
getBlockResponseEncodingAt = 8
getBlockResponseSize = 16
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetBlockResponse)(nil)
// MarshalZAP writes GetBlockResponse from constant offsets.
func (x *GetBlockResponse) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getBlockResponseSize + 256)
ob := b.StartObject(getBlockResponseSize)
ob.SetBytes(getBlockResponseBlockAt, []byte(x.Block))
ob.SetUint8(getBlockResponseEncodingAt, uint8(x.Encoding))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetBlockResponse out of the buffer that arrived.
func (x *GetBlockResponse) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetBlockResponse: %w", err)
}
o := m.Root()
x.Block = json.RawMessage(append([]byte(nil), o.Bytes(getBlockResponseBlockAt)...))
x.Encoding = formatting.Encoding(o.Uint8(getBlockResponseEncodingAt))
return nil
}
// ---- GetHeightResponse -------------------------------------------------
const (
getHeightResponseHeightAt = 0
getHeightResponseSize = 8
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetHeightResponse)(nil)
// MarshalZAP writes GetHeightResponse from constant offsets.
func (x *GetHeightResponse) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getHeightResponseSize + 256)
ob := b.StartObject(getHeightResponseSize)
ob.SetUint64(getHeightResponseHeightAt, uint64(x.Height))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetHeightResponse out of the buffer that arrived.
func (x *GetHeightResponse) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetHeightResponse: %w", err)
}
o := m.Root()
x.Height = Uint64(o.Uint64(getHeightResponseHeightAt))
return nil
}
// ---- GetTxArgs ---------------------------------------------------------
const (
getTxArgsTxIDAt = 0
getTxArgsEncodingAt = 32
getTxArgsSize = 40
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetTxArgs)(nil)
// MarshalZAP writes GetTxArgs from constant offsets.
func (x *GetTxArgs) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getTxArgsSize + 256)
ob := b.StartObject(getTxArgsSize)
ob.SetBytesFixed(getTxArgsTxIDAt, x.TxID[:])
ob.SetUint8(getTxArgsEncodingAt, uint8(x.Encoding))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetTxArgs out of the buffer that arrived.
func (x *GetTxArgs) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetTxArgs: %w", err)
}
o := m.Root()
copy(x.TxID[:], o.BytesFixed(getTxArgsTxIDAt, 32))
x.Encoding = formatting.Encoding(o.Uint8(getTxArgsEncodingAt))
return nil
}
// ---- GetTxReply --------------------------------------------------------
const (
getTxReplyTxAt = 0
getTxReplyEncodingAt = 8
getTxReplySize = 16
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetTxReply)(nil)
// MarshalZAP writes GetTxReply from constant offsets.
func (x *GetTxReply) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getTxReplySize + 256)
ob := b.StartObject(getTxReplySize)
ob.SetBytes(getTxReplyTxAt, []byte(x.Tx))
ob.SetUint8(getTxReplyEncodingAt, uint8(x.Encoding))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetTxReply out of the buffer that arrived.
func (x *GetTxReply) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetTxReply: %w", err)
}
o := m.Root()
x.Tx = json.RawMessage(append([]byte(nil), o.Bytes(getTxReplyTxAt)...))
x.Encoding = formatting.Encoding(o.Uint8(getTxReplyEncodingAt))
return nil
}
// ---- GetUTXOsArgs ------------------------------------------------------
const (
getUTXOsArgsAddressesAt = 0
getUTXOsArgsSourceChainAt = 8
getUTXOsArgsLimitAt = 16
getUTXOsArgsStartIndexAt = 24
getUTXOsArgsEncodingAt = 32
getUTXOsArgsSize = 40
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetUTXOsArgs)(nil)
// MarshalZAP writes GetUTXOsArgs from constant offsets.
func (x *GetUTXOsArgs) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getUTXOsArgsSize + 256)
addressesAt, addressesN := 0, len(x.Addresses)
if addressesN > 0 {
var blob []byte
for i := range x.Addresses {
enc := []byte(x.Addresses[i])
var n [4]byte
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
blob = append(blob, n[:]...)
blob = append(blob, enc...)
}
addressesAt = b.WriteBytes(blob)
}
ob := b.StartObject(getUTXOsArgsSize)
ob.SetText(getUTXOsArgsSourceChainAt, string(x.SourceChain))
ob.SetUint32(getUTXOsArgsLimitAt, uint32(x.Limit))
innerStartIndex, err := x.StartIndex.MarshalZAP()
if err != nil {
return nil, err
}
ob.SetBytes(getUTXOsArgsStartIndexAt, innerStartIndex)
ob.SetUint8(getUTXOsArgsEncodingAt, uint8(x.Encoding))
if addressesN > 0 {
ob.SetList(getUTXOsArgsAddressesAt, addressesAt, addressesN)
}
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetUTXOsArgs out of the buffer that arrived.
func (x *GetUTXOsArgs) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetUTXOsArgs: %w", err)
}
o := m.Root()
if l := o.List(getUTXOsArgsAddressesAt); l.Len() > 0 {
rows := make([]string, l.Len())
for i := range rows {
rows[i] = string(l.BytesAt(i))
}
x.Addresses = rows
}
x.SourceChain = string(strings.Clone(o.Text(getUTXOsArgsSourceChainAt)))
x.Limit = Uint32(o.Uint32(getUTXOsArgsLimitAt))
if raw := o.Bytes(getUTXOsArgsStartIndexAt); len(raw) > 0 {
if err := x.StartIndex.UnmarshalZAP(raw); err != nil {
return err
}
}
x.Encoding = formatting.Encoding(o.Uint8(getUTXOsArgsEncodingAt))
return nil
}
// ---- GetUTXOsReply -----------------------------------------------------
const (
getUTXOsReplyNumFetchedAt = 0
getUTXOsReplyUTXOsAt = 8
getUTXOsReplyEndIndexAt = 16
getUTXOsReplyEncodingAt = 24
getUTXOsReplySize = 32
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*GetUTXOsReply)(nil)
// MarshalZAP writes GetUTXOsReply from constant offsets.
func (x *GetUTXOsReply) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(getUTXOsReplySize + 256)
uTXOsAt, uTXOsN := 0, len(x.UTXOs)
if uTXOsN > 0 {
var blob []byte
for i := range x.UTXOs {
enc := []byte(x.UTXOs[i])
var n [4]byte
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
blob = append(blob, n[:]...)
blob = append(blob, enc...)
}
uTXOsAt = b.WriteBytes(blob)
}
ob := b.StartObject(getUTXOsReplySize)
ob.SetUint64(getUTXOsReplyNumFetchedAt, uint64(x.NumFetched))
innerEndIndex, err := x.EndIndex.MarshalZAP()
if err != nil {
return nil, err
}
ob.SetBytes(getUTXOsReplyEndIndexAt, innerEndIndex)
ob.SetUint8(getUTXOsReplyEncodingAt, uint8(x.Encoding))
if uTXOsN > 0 {
ob.SetList(getUTXOsReplyUTXOsAt, uTXOsAt, uTXOsN)
}
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads GetUTXOsReply out of the buffer that arrived.
func (x *GetUTXOsReply) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("GetUTXOsReply: %w", err)
}
o := m.Root()
x.NumFetched = Uint64(o.Uint64(getUTXOsReplyNumFetchedAt))
if l := o.List(getUTXOsReplyUTXOsAt); l.Len() > 0 {
rows := make([]string, l.Len())
for i := range rows {
rows[i] = string(l.BytesAt(i))
}
x.UTXOs = rows
}
if raw := o.Bytes(getUTXOsReplyEndIndexAt); len(raw) > 0 {
if err := x.EndIndex.UnmarshalZAP(raw); err != nil {
return err
}
}
x.Encoding = formatting.Encoding(o.Uint8(getUTXOsReplyEncodingAt))
return nil
}
// ---- Index -------------------------------------------------------------
const (
indexAddressAt = 0
indexUTXOAt = 8
indexSize = 16
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*Index)(nil)
// MarshalZAP writes Index from constant offsets.
func (x *Index) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(indexSize + 256)
ob := b.StartObject(indexSize)
ob.SetText(indexAddressAt, string(x.Address))
ob.SetText(indexUTXOAt, string(x.UTXO))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads Index out of the buffer that arrived.
func (x *Index) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("Index: %w", err)
}
o := m.Root()
x.Address = string(strings.Clone(o.Text(indexAddressAt)))
x.UTXO = string(strings.Clone(o.Text(indexUTXOAt)))
return nil
}
// ---- JSONAddress -------------------------------------------------------
const (
jSONAddressAddressAt = 0
jSONAddressSize = 8
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*JSONAddress)(nil)
// MarshalZAP writes JSONAddress from constant offsets.
func (x *JSONAddress) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(jSONAddressSize + 256)
ob := b.StartObject(jSONAddressSize)
ob.SetText(jSONAddressAddressAt, string(x.Address))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads JSONAddress out of the buffer that arrived.
func (x *JSONAddress) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("JSONAddress: %w", err)
}
o := m.Root()
x.Address = string(strings.Clone(o.Text(jSONAddressAddressAt)))
return nil
}
// ---- JSONAddresses -----------------------------------------------------
const (
jSONAddressesAddressesAt = 0
jSONAddressesSize = 8
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*JSONAddresses)(nil)
// MarshalZAP writes JSONAddresses from constant offsets.
func (x *JSONAddresses) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(jSONAddressesSize + 256)
addressesAt, addressesN := 0, len(x.Addresses)
if addressesN > 0 {
var blob []byte
for i := range x.Addresses {
enc := []byte(x.Addresses[i])
var n [4]byte
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
blob = append(blob, n[:]...)
blob = append(blob, enc...)
}
addressesAt = b.WriteBytes(blob)
}
ob := b.StartObject(jSONAddressesSize)
if addressesN > 0 {
ob.SetList(jSONAddressesAddressesAt, addressesAt, addressesN)
}
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads JSONAddresses out of the buffer that arrived.
func (x *JSONAddresses) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("JSONAddresses: %w", err)
}
o := m.Root()
if l := o.List(jSONAddressesAddressesAt); l.Len() > 0 {
rows := make([]string, l.Len())
for i := range rows {
rows[i] = string(l.BytesAt(i))
}
x.Addresses = rows
}
return nil
}
// ---- JSONTxID ----------------------------------------------------------
const (
jSONTxIDTxIDAt = 0
jSONTxIDSize = 32
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*JSONTxID)(nil)
// MarshalZAP writes JSONTxID from constant offsets.
func (x *JSONTxID) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(jSONTxIDSize + 256)
ob := b.StartObject(jSONTxIDSize)
ob.SetBytesFixed(jSONTxIDTxIDAt, x.TxID[:])
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads JSONTxID out of the buffer that arrived.
func (x *JSONTxID) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("JSONTxID: %w", err)
}
o := m.Root()
copy(x.TxID[:], o.BytesFixed(jSONTxIDTxIDAt, 32))
return nil
}
// ---- Time --------------------------------------------------------------
const (
timeSecondsAt = 0
timeNanosAt = 8
timeOffsetAt = 12
timeSize = 16
)
var _ interface {
MarshalZAP() ([]byte, error)
UnmarshalZAP([]byte) error
} = (*Time)(nil)
// MarshalZAP writes Time from constant offsets.
func (x *Time) MarshalZAP() ([]byte, error) {
if x == nil {
return nil, nil
}
b := zap.NewBuilder(timeSize + 256)
ob := b.StartObject(timeSize)
ob.SetInt64(timeSecondsAt, int64(x.Seconds))
ob.SetInt32(timeNanosAt, int32(x.Nanos))
ob.SetInt32(timeOffsetAt, int32(x.Offset))
ob.FinishAsRoot()
return b.Finish(), nil
}
// UnmarshalZAP reads Time out of the buffer that arrived.
func (x *Time) UnmarshalZAP(data []byte) error {
if x == nil || len(data) == 0 {
return nil
}
m, err := zap.Parse(data)
if err != nil {
return fmt.Errorf("Time: %w", err)
}
o := m.Root()
x.Seconds = int64(o.Int64(timeSecondsAt))
x.Nanos = int32(o.Int32(timeNanosAt))
x.Offset = int32(o.Int32(timeOffsetAt))
return nil
}