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.
118 lines
2.7 KiB
Go
118 lines
2.7 KiB
Go
// Code generated by zip; DO NOT EDIT.
|
|
|
|
package genesis
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"fmt"
|
|
|
|
zap "github.com/zap-proto/go"
|
|
)
|
|
|
|
// ---- Allocation --------------------------------------------------------
|
|
|
|
const (
|
|
allocationAddressAt = 0
|
|
allocationBalanceAt = 24
|
|
allocationSize = 32
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Allocation)(nil)
|
|
|
|
// MarshalZAP writes Allocation from constant offsets.
|
|
func (x *Allocation) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(allocationSize + 256)
|
|
ob := b.StartObject(allocationSize)
|
|
ob.SetBytesFixed(allocationAddressAt, x.Address[:])
|
|
ob.SetUint64(allocationBalanceAt, uint64(x.Balance))
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Allocation out of the buffer that arrived.
|
|
func (x *Allocation) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Allocation: %w", err)
|
|
}
|
|
o := m.Root()
|
|
copy(x.Address[:], o.BytesFixed(allocationAddressAt, 20))
|
|
x.Balance = uint64(o.Uint64(allocationBalanceAt))
|
|
return nil
|
|
}
|
|
|
|
// ---- Genesis -----------------------------------------------------------
|
|
|
|
const (
|
|
genesisTimestampAt = 0
|
|
genesisAllocationsAt = 8
|
|
genesisSize = 16
|
|
)
|
|
|
|
var _ interface {
|
|
MarshalZAP() ([]byte, error)
|
|
UnmarshalZAP([]byte) error
|
|
} = (*Genesis)(nil)
|
|
|
|
// MarshalZAP writes Genesis from constant offsets.
|
|
func (x *Genesis) MarshalZAP() ([]byte, error) {
|
|
if x == nil {
|
|
return nil, nil
|
|
}
|
|
b := zap.NewBuilder(genesisSize + 256)
|
|
allocationsAt, allocationsN := 0, len(x.Allocations)
|
|
if allocationsN > 0 {
|
|
var blob []byte
|
|
for i := range x.Allocations {
|
|
enc, err := x.Allocations[i].MarshalZAP()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var n [4]byte
|
|
binary.LittleEndian.PutUint32(n[:], uint32(len(enc)))
|
|
blob = append(blob, n[:]...)
|
|
blob = append(blob, enc...)
|
|
}
|
|
allocationsAt = b.WriteBytes(blob)
|
|
}
|
|
ob := b.StartObject(genesisSize)
|
|
ob.SetInt64(genesisTimestampAt, int64(x.Timestamp))
|
|
if allocationsN > 0 {
|
|
ob.SetList(genesisAllocationsAt, allocationsAt, allocationsN)
|
|
}
|
|
ob.FinishAsRoot()
|
|
return b.Finish(), nil
|
|
}
|
|
|
|
// UnmarshalZAP reads Genesis out of the buffer that arrived.
|
|
func (x *Genesis) UnmarshalZAP(data []byte) error {
|
|
if x == nil || len(data) == 0 {
|
|
return nil
|
|
}
|
|
m, err := zap.Parse(data)
|
|
if err != nil {
|
|
return fmt.Errorf("Genesis: %w", err)
|
|
}
|
|
o := m.Root()
|
|
x.Timestamp = int64(o.Int64(genesisTimestampAt))
|
|
if l := o.List(genesisAllocationsAt); l.Len() > 0 {
|
|
rows := make([]Allocation, l.Len())
|
|
for i := range rows {
|
|
if err := rows[i].UnmarshalZAP(l.BytesAt(i)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
x.Allocations = rows
|
|
}
|
|
return nil
|
|
}
|