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

116 lines
3.2 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"errors"
"time"
"github.com/luxfi/ids"
"github.com/luxfi/node/proto/p2p"
)
var (
errMissingField = errors.New("message missing field")
_ chainIDGetter = (*p2p.GetStateSummaryFrontier)(nil)
_ chainIDGetter = (*p2p.StateSummaryFrontier)(nil)
_ chainIDGetter = (*p2p.GetAcceptedStateSummary)(nil)
_ chainIDGetter = (*p2p.AcceptedStateSummary)(nil)
_ chainIDGetter = (*p2p.GetAcceptedFrontier)(nil)
_ chainIDGetter = (*p2p.AcceptedFrontier)(nil)
_ chainIDGetter = (*p2p.GetAccepted)(nil)
_ chainIDGetter = (*p2p.Accepted)(nil)
_ chainIDGetter = (*p2p.GetAncestors)(nil)
_ chainIDGetter = (*p2p.Ancestors)(nil)
_ chainIDGetter = (*p2p.Get)(nil)
_ chainIDGetter = (*p2p.Put)(nil)
_ chainIDGetter = (*p2p.PushQuery)(nil)
_ chainIDGetter = (*p2p.PullQuery)(nil)
_ chainIDGetter = (*p2p.Chits)(nil)
_ chainIDGetter = (*p2p.Request)(nil)
_ chainIDGetter = (*p2p.Response)(nil)
_ chainIDGetter = (*p2p.Gossip)(nil)
_ chainIDGetter = (*p2p.BFT)(nil)
_ requestIDGetter = (*p2p.GetStateSummaryFrontier)(nil)
_ requestIDGetter = (*p2p.StateSummaryFrontier)(nil)
_ requestIDGetter = (*p2p.GetAcceptedStateSummary)(nil)
_ requestIDGetter = (*p2p.AcceptedStateSummary)(nil)
_ requestIDGetter = (*p2p.GetAcceptedFrontier)(nil)
_ requestIDGetter = (*p2p.AcceptedFrontier)(nil)
_ requestIDGetter = (*p2p.GetAccepted)(nil)
_ requestIDGetter = (*p2p.Accepted)(nil)
_ requestIDGetter = (*p2p.GetAncestors)(nil)
_ requestIDGetter = (*p2p.Ancestors)(nil)
_ requestIDGetter = (*p2p.Get)(nil)
_ requestIDGetter = (*p2p.Put)(nil)
_ requestIDGetter = (*p2p.PushQuery)(nil)
_ requestIDGetter = (*p2p.PullQuery)(nil)
_ requestIDGetter = (*p2p.Chits)(nil)
_ requestIDGetter = (*p2p.Request)(nil)
_ requestIDGetter = (*p2p.Response)(nil)
_ engineTypeGetter = (*p2p.GetAncestors)(nil)
_ deadlineGetter = (*p2p.GetStateSummaryFrontier)(nil)
_ deadlineGetter = (*p2p.GetAcceptedStateSummary)(nil)
_ deadlineGetter = (*p2p.GetAcceptedFrontier)(nil)
_ deadlineGetter = (*p2p.GetAccepted)(nil)
_ deadlineGetter = (*p2p.GetAncestors)(nil)
_ deadlineGetter = (*p2p.Get)(nil)
_ deadlineGetter = (*p2p.PushQuery)(nil)
_ deadlineGetter = (*p2p.PullQuery)(nil)
_ deadlineGetter = (*p2p.Request)(nil)
)
type chainIDGetter interface {
GetChainId() []byte
}
func GetChainID(m any) (ids.ID, error) {
msg, ok := m.(chainIDGetter)
if !ok {
return ids.Empty, errMissingField
}
chainIDBytes := msg.GetChainId()
return ids.ToID(chainIDBytes)
}
type requestIDGetter interface {
GetRequestId() uint32
}
func GetRequestID(m any) (uint32, bool) {
if msg, ok := m.(requestIDGetter); ok {
return msg.GetRequestId(), true
}
return 0, false
}
type engineTypeGetter interface {
GetEngineType() p2p.EngineType
}
func GetEngineType(m any) (p2p.EngineType, bool) {
msg, ok := m.(engineTypeGetter)
if !ok {
return p2p.EngineType_ENGINE_TYPE_UNSPECIFIED, false
}
return msg.GetEngineType(), true
}
type deadlineGetter interface {
GetDeadline() uint64
}
func GetDeadline(m any) (time.Duration, bool) {
msg, ok := m.(deadlineGetter)
if !ok {
return 0, false
}
deadline := msg.GetDeadline()
return time.Duration(deadline), true
}