Help us shape the future of Go! Take the 2026 Go Developer Survey

wire

package
v1.28.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package wire defines P2P message types for network communication. This package is wire-format agnostic - encoding is handled by the parent message package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMessage = errors.New("invalid wire message")
	ErrUnknownTag     = errors.New("unknown message tag")
)

Functions

func Marshal

func Marshal(m *Message) ([]byte, error)

Marshal encodes a Message to ZAP wire format

Types

type Accepted

type Accepted struct {
	ChainId      []byte
	RequestId    uint32
	ContainerIds [][]byte
}

Accepted message

func (*Accepted) GetChainId

func (m *Accepted) GetChainId() []byte

func (*Accepted) GetRequestId

func (m *Accepted) GetRequestId() uint32

type AcceptedFrontier

type AcceptedFrontier struct {
	ChainId     []byte
	RequestId   uint32
	ContainerId []byte
}

AcceptedFrontier message

func (*AcceptedFrontier) GetChainId

func (m *AcceptedFrontier) GetChainId() []byte

func (*AcceptedFrontier) GetRequestId

func (m *AcceptedFrontier) GetRequestId() uint32

type AcceptedStateSummary

type AcceptedStateSummary struct {
	ChainId    []byte
	RequestId  uint32
	SummaryIds [][]byte
}

AcceptedStateSummary message

func (*AcceptedStateSummary) GetChainId

func (m *AcceptedStateSummary) GetChainId() []byte

func (*AcceptedStateSummary) GetRequestId

func (m *AcceptedStateSummary) GetRequestId() uint32

type Ancestors

type Ancestors struct {
	ChainId    []byte
	RequestId  uint32
	Containers [][]byte
}

Ancestors message

func (*Ancestors) GetChainId

func (m *Ancestors) GetChainId() []byte

func (*Ancestors) GetRequestId

func (m *Ancestors) GetRequestId() uint32

type BFT

type BFT struct {
	ChainId []byte
	Message []byte
}

BFT message

func (*BFT) GetChainId

func (m *BFT) GetChainId() []byte

type BloomFilter

type BloomFilter struct {
	Filter []byte
	Salt   []byte
}

BloomFilter for peer discovery

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer for zero-copy encoding

func NewBuffer

func NewBuffer(size int) *Buffer

func (*Buffer) Bytes

func (b *Buffer) Bytes() []byte

func (*Buffer) Reset

func (b *Buffer) Reset()

func (*Buffer) WriteBytes

func (b *Buffer) WriteBytes(data []byte)

func (*Buffer) WriteBytesSlice

func (b *Buffer) WriteBytesSlice(slices [][]byte)

func (*Buffer) WriteString

func (b *Buffer) WriteString(s string)

func (*Buffer) WriteUint8

func (b *Buffer) WriteUint8(v uint8)

func (*Buffer) WriteUint16

func (b *Buffer) WriteUint16(v uint16)

func (*Buffer) WriteUint32

func (b *Buffer) WriteUint32(v uint32)

func (*Buffer) WriteUint32Slice

func (b *Buffer) WriteUint32Slice(vals []uint32)

func (*Buffer) WriteUint64

func (b *Buffer) WriteUint64(v uint64)

func (*Buffer) WriteUint64Slice

func (b *Buffer) WriteUint64Slice(vals []uint64)

type ChainPingEntry added in v1.25.0

type ChainPingEntry struct {
	ChainId []byte
}

ChainPingEntry is the per-chain payload in Ping/Pong. In Lux's chain model each chain is its own validator set, so the legacy (chain, network) pair collapses to a single chain identifier.

type Chits

type Chits struct {
	ChainId             []byte
	RequestId           uint32
	PreferredId         []byte
	PreferredIdAtHeight []byte
	AcceptedId          []byte
}

Chits message

func (*Chits) GetChainId

func (m *Chits) GetChainId() []byte

func (*Chits) GetRequestId

func (m *Chits) GetRequestId() uint32

type ClaimedIpPort

type ClaimedIpPort struct {
	X509Certificate []byte
	IpAddr          []byte
	IpPort          uint32
	Timestamp       uint64
	Signature       []byte
	TxId            []byte
}

ClaimedIpPort in peer list

type Client

type Client struct {
	Name  string
	Major uint32
	Minor uint32
	Patch uint32
}

Client info in handshake

type EngineType

type EngineType int32

EngineType represents the consensus engine type

const (
	EngineType_UNSPECIFIED EngineType = 0
	EngineType_CHAIN       EngineType = 1
	EngineType_DAG         EngineType = 2
)

type Get

type Get struct {
	ChainId     []byte
	RequestId   uint32
	Deadline    uint64
	ContainerId []byte
	EngineType  EngineType
}

Get message

func (*Get) GetChainId

func (m *Get) GetChainId() []byte

func (*Get) GetDeadline

func (m *Get) GetDeadline() uint64

func (*Get) GetRequestId

func (m *Get) GetRequestId() uint32

type GetAccepted

type GetAccepted struct {
	ChainId      []byte
	RequestId    uint32
	Deadline     uint64
	ContainerIds [][]byte
	EngineType   EngineType
}

GetAccepted message

func (*GetAccepted) GetChainId

func (m *GetAccepted) GetChainId() []byte

func (*GetAccepted) GetDeadline

func (m *GetAccepted) GetDeadline() uint64

func (*GetAccepted) GetRequestId

func (m *GetAccepted) GetRequestId() uint32

type GetAcceptedFrontier

type GetAcceptedFrontier struct {
	ChainId    []byte
	RequestId  uint32
	Deadline   uint64
	EngineType EngineType
}

GetAcceptedFrontier message

func (*GetAcceptedFrontier) GetChainId

func (m *GetAcceptedFrontier) GetChainId() []byte

func (*GetAcceptedFrontier) GetDeadline

func (m *GetAcceptedFrontier) GetDeadline() uint64

func (*GetAcceptedFrontier) GetRequestId

func (m *GetAcceptedFrontier) GetRequestId() uint32

type GetAcceptedStateSummary

type GetAcceptedStateSummary struct {
	ChainId   []byte
	RequestId uint32
	Deadline  uint64
	Heights   []uint64
}

GetAcceptedStateSummary message

func (*GetAcceptedStateSummary) GetChainId

func (m *GetAcceptedStateSummary) GetChainId() []byte

func (*GetAcceptedStateSummary) GetDeadline

func (m *GetAcceptedStateSummary) GetDeadline() uint64

func (*GetAcceptedStateSummary) GetRequestId

func (m *GetAcceptedStateSummary) GetRequestId() uint32

type GetAncestors

type GetAncestors struct {
	ChainId     []byte
	RequestId   uint32
	Deadline    uint64
	ContainerId []byte
	EngineType  EngineType
}

GetAncestors message

func (*GetAncestors) GetChainId

func (m *GetAncestors) GetChainId() []byte

func (*GetAncestors) GetDeadline

func (m *GetAncestors) GetDeadline() uint64

func (*GetAncestors) GetEngineType

func (m *GetAncestors) GetEngineType() EngineType

func (*GetAncestors) GetRequestId

func (m *GetAncestors) GetRequestId() uint32

type GetPeerList

type GetPeerList struct {
	KnownPeers *BloomFilter
}

GetPeerList message

type GetStateSummaryFrontier

type GetStateSummaryFrontier struct {
	ChainId   []byte
	RequestId uint32
	Deadline  uint64
}

GetStateSummaryFrontier message

func (*GetStateSummaryFrontier) GetChainId

func (m *GetStateSummaryFrontier) GetChainId() []byte

func (*GetStateSummaryFrontier) GetDeadline

func (m *GetStateSummaryFrontier) GetDeadline() uint64

func (*GetStateSummaryFrontier) GetRequestId

func (m *GetStateSummaryFrontier) GetRequestId() uint32

type Gossip

type Gossip struct {
	ChainId []byte
	Gossip  []byte
}

Gossip message (app-level)

func (*Gossip) GetChainId

func (m *Gossip) GetChainId() []byte

type Handshake

type Handshake struct {
	NetworkId     uint32
	MyTime        uint64
	IpAddr        []byte
	IpPort        uint32
	IpSigningTime uint64
	IpNodeIdSig   []byte
	TrackedChains [][]byte
	Client        *Client
	SupportedAcps []uint32
	ObjectedAcps  []uint32
	KnownPeers    *BloomFilter
	IpBlsSig      []byte
}

Handshake message

type Message

type Message struct {
	// Only one of these should be set
	CompressedZstd          []byte
	Ping                    *Ping
	Pong                    *Pong
	Handshake               *Handshake
	GetPeerList             *GetPeerList
	PeerList                *PeerList
	GetStateSummaryFrontier *GetStateSummaryFrontier
	StateSummaryFrontier    *StateSummaryFrontier
	GetAcceptedStateSummary *GetAcceptedStateSummary
	AcceptedStateSummary    *AcceptedStateSummary
	GetAcceptedFrontier     *GetAcceptedFrontier
	AcceptedFrontier        *AcceptedFrontier
	GetAccepted             *GetAccepted
	Accepted                *Accepted
	GetAncestors            *GetAncestors
	Ancestors               *Ancestors
	Get                     *Get
	Put                     *Put
	PushQuery               *PushQuery
	PullQuery               *PullQuery
	Chits                   *Chits
	Request                 *Request
	Response                *Response
	Gossip                  *Gossip
	BFT                     *BFT
}

Message is the top-level P2P message container

func Unmarshal

func Unmarshal(data []byte) (*Message, error)

Unmarshal decodes a Message from ZAP wire format

type PeerList

type PeerList struct {
	ClaimedIpPorts []*ClaimedIpPort
}

PeerList message

type Ping

type Ping struct {
	Uptime   uint32
	ChainIds []*ChainPingEntry
}

Ping message

type Pong

type Pong struct {
	Uptime   uint32
	ChainIds []*ChainPingEntry
}

Pong message

type PullQuery

type PullQuery struct {
	ChainId         []byte
	RequestId       uint32
	Deadline        uint64
	ContainerId     []byte
	EngineType      EngineType
	RequestedHeight uint64
}

PullQuery message

func (*PullQuery) GetChainId

func (m *PullQuery) GetChainId() []byte

func (*PullQuery) GetDeadline

func (m *PullQuery) GetDeadline() uint64

func (*PullQuery) GetRequestId

func (m *PullQuery) GetRequestId() uint32

type PushQuery

type PushQuery struct {
	ChainId         []byte
	RequestId       uint32
	Deadline        uint64
	Container       []byte
	EngineType      EngineType
	RequestedHeight uint64
}

PushQuery message

func (*PushQuery) GetChainId

func (m *PushQuery) GetChainId() []byte

func (*PushQuery) GetDeadline

func (m *PushQuery) GetDeadline() uint64

func (*PushQuery) GetRequestId

func (m *PushQuery) GetRequestId() uint32

type Put

type Put struct {
	ChainId    []byte
	RequestId  uint32
	Container  []byte
	EngineType EngineType
}

Put message

func (*Put) GetChainId

func (m *Put) GetChainId() []byte

func (*Put) GetRequestId

func (m *Put) GetRequestId() uint32

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader for zero-copy decoding

func NewReader

func NewReader(data []byte) *Reader

func (*Reader) ReadBytes

func (r *Reader) ReadBytes() ([]byte, error)

func (*Reader) ReadBytesSlice

func (r *Reader) ReadBytesSlice() ([][]byte, error)

func (*Reader) ReadString

func (r *Reader) ReadString() (string, error)

func (*Reader) ReadUint8

func (r *Reader) ReadUint8() (uint8, error)

func (*Reader) ReadUint16

func (r *Reader) ReadUint16() (uint16, error)

func (*Reader) ReadUint32

func (r *Reader) ReadUint32() (uint32, error)

func (*Reader) ReadUint32Slice

func (r *Reader) ReadUint32Slice() ([]uint32, error)

func (*Reader) ReadUint64

func (r *Reader) ReadUint64() (uint64, error)

func (*Reader) ReadUint64Slice

func (r *Reader) ReadUint64Slice() ([]uint64, error)

type Request

type Request struct {
	ChainId   []byte
	RequestId uint32
	Deadline  uint64
	Request   []byte
}

Request message (app-level)

func (*Request) GetChainId

func (m *Request) GetChainId() []byte

func (*Request) GetDeadline

func (m *Request) GetDeadline() uint64

func (*Request) GetRequestId

func (m *Request) GetRequestId() uint32

type Response

type Response struct {
	ChainId   []byte
	RequestId uint32
	Response  []byte
}

Response message (app-level)

func (*Response) GetChainId

func (m *Response) GetChainId() []byte

func (*Response) GetRequestId

func (m *Response) GetRequestId() uint32

type StateSummaryFrontier

type StateSummaryFrontier struct {
	ChainId   []byte
	RequestId uint32
	Summary   []byte
}

StateSummaryFrontier message

func (*StateSummaryFrontier) GetChainId

func (m *StateSummaryFrontier) GetChainId() []byte

func (*StateSummaryFrontier) GetRequestId

func (m *StateSummaryFrontier) GetRequestId() uint32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL