mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
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.
78 lines
2.1 KiB
Go
78 lines
2.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package message
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/zap"
|
|
)
|
|
|
|
// L1ValidatorRegistration reports if a validator is registered on the P-chain.
|
|
//
|
|
// Wire: mkind u8 @0, ValidationID 32B @1, Registered u8 @33 = 34 bytes.
|
|
type L1ValidatorRegistration struct {
|
|
payload
|
|
|
|
ValidationID ids.ID `json:"validationID"`
|
|
// Registered being true means that validationID is currently a validator on
|
|
// the P-chain.
|
|
//
|
|
// Registered being false means that validationID is not and can never
|
|
// become a validator on the P-chain. It is possible that validationID was
|
|
// previously a validator on the P-chain.
|
|
Registered bool `json:"registered"`
|
|
}
|
|
|
|
const (
|
|
regOffValidationID = 1
|
|
regOffRegistered = 33
|
|
regSize = 34
|
|
)
|
|
|
|
// NewL1ValidatorRegistration creates a new initialized L1ValidatorRegistration.
|
|
func NewL1ValidatorRegistration(
|
|
validationID ids.ID,
|
|
registered bool,
|
|
) (*L1ValidatorRegistration, error) {
|
|
msg := &L1ValidatorRegistration{
|
|
ValidationID: validationID,
|
|
Registered: registered,
|
|
}
|
|
b := zap.NewBuilder(zap.HeaderSize + regSize)
|
|
ob := b.StartObject(regSize)
|
|
ob.SetUint8(offMKind, uint8(mkindL1ValidatorRegistration))
|
|
ob.SetBytesFixed(regOffValidationID, validationID[:])
|
|
var reg uint8
|
|
if registered {
|
|
reg = 1
|
|
}
|
|
ob.SetUint8(regOffRegistered, reg)
|
|
ob.FinishAsRoot()
|
|
msg.initialize(b.Finish())
|
|
return msg, nil
|
|
}
|
|
|
|
func parseL1ValidatorRegistration(root zap.Object) *L1ValidatorRegistration {
|
|
return &L1ValidatorRegistration{
|
|
ValidationID: readID(root, regOffValidationID),
|
|
Registered: root.Uint8(regOffRegistered) != 0,
|
|
}
|
|
}
|
|
|
|
// ParseL1ValidatorRegistration parses bytes into an initialized
|
|
// L1ValidatorRegistration.
|
|
func ParseL1ValidatorRegistration(b []byte) (*L1ValidatorRegistration, error) {
|
|
payloadIntf, err := Parse(b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
payload, ok := payloadIntf.(*L1ValidatorRegistration)
|
|
if !ok {
|
|
return nil, fmt.Errorf("%w: %T", ErrWrongType, payloadIntf)
|
|
}
|
|
return payload, nil
|
|
}
|