Files
zeekay 7cf87b230b node-unified is the node
The module already called itself github.com/luxfi/node while containing no node
in Go: cmd/luxd was twenty-one lines that printed the size of a few types, and
the Go column of the matrix measured a VM plugin. A repo that fetches the thing
it claims to be has not replaced it, so the Go sources move in — 1515 files,
the daemon and everything under it — and the build reaches outside this module
for nothing.

Rust and C++ sit beside it unchanged and are still measured against it by the
differential. That is the point of one repo: the reference implementation and
the two ports are the same checkout, so parity is a thing you can run rather
than a thing you assert.

Verified: builds, and the closure carries no lux-private — checked at build time
rather than believed. The daemon starts twelve chains on a local network
(P X C Q Z A B G K M F, plus D through its plugin) and reports healthy.
2026-09-07 16:15:25 -07:00

63 lines
2.0 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package indexer
import (
"encoding/binary"
"errors"
"github.com/luxfi/ids"
)
// On-disk encoding of an indexed Container. Big-endian wire layout:
//
// bytes 0..31 : Container.ID (ids.IDLen)
// bytes 32..35 : len(Container.Bytes) (uint32 BE)
// bytes 36..N : Container.Bytes (variable)
// bytes N..N+8 : Container.Timestamp (int64 BE, two's complement)
//
// No codec version prefix — the indexer DB lives inside the node, so a
// forward-only schema is fine. Older versions stored a 2-byte codec
// version header; that format is no longer accepted (hard cut from
// luxfi/codec rip — Wave 1D).
var (
errContainerTooShort = errors.New("indexer: encoded container shorter than header")
errContainerBytesLen = errors.New("indexer: encoded container length exceeds payload")
)
// marshalContainer encodes c to its on-disk representation.
func marshalContainer(c Container) ([]byte, error) {
out := make([]byte, 0, ids.IDLen+4+len(c.Bytes)+8)
out = append(out, c.ID[:]...)
var lenBuf [4]byte
binary.BigEndian.PutUint32(lenBuf[:], uint32(len(c.Bytes)))
out = append(out, lenBuf[:]...)
out = append(out, c.Bytes...)
var tsBuf [8]byte
binary.BigEndian.PutUint64(tsBuf[:], uint64(c.Timestamp))
out = append(out, tsBuf[:]...)
return out, nil
}
// unmarshalContainer decodes b into a Container.
func unmarshalContainer(b []byte) (Container, error) {
const headerLen = ids.IDLen + 4
if len(b) < headerLen+8 {
return Container{}, errContainerTooShort
}
var c Container
copy(c.ID[:], b[:ids.IDLen])
bytesLen := binary.BigEndian.Uint32(b[ids.IDLen : ids.IDLen+4])
if uint64(len(b)) < uint64(headerLen)+uint64(bytesLen)+8 {
return Container{}, errContainerBytesLen
}
payloadStart := headerLen
payloadEnd := payloadStart + int(bytesLen)
c.Bytes = make([]byte, bytesLen)
copy(c.Bytes, b[payloadStart:payloadEnd])
c.Timestamp = int64(binary.BigEndian.Uint64(b[payloadEnd : payloadEnd+8]))
return c, nil
}