gossip

package
v0.0.0-...-3423c7d Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const CrdsBloomP = 0.1

CrdsBloomP is bloom filter 'p' parameter (probability)

View Source
const MaxBloomSize = 928
View Source
const PacketSize = 1232
View Source
const PingSize = 128

PingSize is the size of a serialized ping message.

Variables

This section is empty.

Functions

func BloomMaskBits

func BloomMaskBits(numItems, maxItems float64) uint32

func BloomMaxItems

func BloomMaxItems(m, p, k float64) float64

func BloomNumBits

func BloomNumBits(n, p float64) float64

func BloomNumKeys

func BloomNumKeys(m, n float64) float64

func DeserializeInstruction

func DeserializeInstruction(deserializer serde.Deserializer) (solana.CompiledInstruction, error)

func DeserializeTxMessage

func DeserializeTxMessage(deserializer serde.Deserializer) (solana.Message, error)

func FNV1a

func FNV1a(slice []byte, hash uint64) uint64

func HashPingToken

func HashPingToken(token [32]byte) [32]byte

HashPingToken returns the pong token given a ping token.

Types

type Addr

type Addr struct {
	netip.Addr
}

func DeserializeAddr

func DeserializeAddr(deserializer serde.Deserializer) (sa Addr, err error)

func (Addr) Serialize

func (a Addr) Serialize(serializer serde.Serializer) error

type BitVecU64

type BitVecU64 struct {
	Bits BitVecU64Inner
	Len  uint64
}

func BincodeDeserializeBitVecU64

func BincodeDeserializeBitVecU64(input []byte) (BitVecU64, error)

func DeserializeBitVecU64

func DeserializeBitVecU64(deserializer serde.Deserializer) (BitVecU64, error)

func MakeBitVecU64

func MakeBitVecU64(bits []uint64, len int) BitVecU64

func (*BitVecU64) BincodeSerialize

func (obj *BitVecU64) BincodeSerialize() ([]byte, error)

func (*BitVecU64) Get

func (bv *BitVecU64) Get(pos uint64) bool

func (*BitVecU64) Serialize

func (obj *BitVecU64) Serialize(serializer serde.Serializer) error

func (*BitVecU64) Set

func (bv *BitVecU64) Set(pos uint64, b bool)

type BitVecU64Inner

type BitVecU64Inner struct {
	Value *[]uint64
}

func BincodeDeserializeBitVecU64Inner

func BincodeDeserializeBitVecU64Inner(input []byte) (BitVecU64Inner, error)

func DeserializeBitVecU64Inner

func DeserializeBitVecU64Inner(deserializer serde.Deserializer) (BitVecU64Inner, error)

func (*BitVecU64Inner) BincodeSerialize

func (obj *BitVecU64Inner) BincodeSerialize() ([]byte, error)

func (*BitVecU64Inner) Serialize

func (obj *BitVecU64Inner) Serialize(serializer serde.Serializer) error

type BitVecU8

type BitVecU8 struct {
	Bits BitVecU8Inner
	Len  uint64
}

func BincodeDeserializeBitVecU8

func BincodeDeserializeBitVecU8(input []byte) (BitVecU8, error)

func DeserializeBitVecU8

func DeserializeBitVecU8(deserializer serde.Deserializer) (BitVecU8, error)

func MakeBitVecU8

func MakeBitVecU8(bits []byte, len int) BitVecU8

func (*BitVecU8) BincodeSerialize

func (obj *BitVecU8) BincodeSerialize() ([]byte, error)

func (*BitVecU8) Get

func (bv *BitVecU8) Get(pos uint64) bool

func (*BitVecU8) Serialize

func (obj *BitVecU8) Serialize(serializer serde.Serializer) error

func (*BitVecU8) Set

func (bv *BitVecU8) Set(pos uint64, b bool)

type BitVecU8Inner

type BitVecU8Inner struct {
	Value *[]uint8
}

func BincodeDeserializeBitVecU8Inner

func BincodeDeserializeBitVecU8Inner(input []byte) (BitVecU8Inner, error)

func DeserializeBitVecU8Inner

func DeserializeBitVecU8Inner(deserializer serde.Deserializer) (BitVecU8Inner, error)

func (*BitVecU8Inner) BincodeSerialize

func (obj *BitVecU8Inner) BincodeSerialize() ([]byte, error)

func (*BitVecU8Inner) Serialize

func (obj *BitVecU8Inner) Serialize(serializer serde.Serializer) error

type Bloom

type Bloom struct {
	Keys       []uint64
	Bits       BitVecU64
	NumBitsSet uint64
}

func BincodeDeserializeBloom

func BincodeDeserializeBloom(input []byte) (Bloom, error)

func DeserializeBloom

func DeserializeBloom(deserializer serde.Deserializer) (Bloom, error)

func NewBloom

func NewBloom(numBits uint64, keys []uint64) *Bloom

func NewBloomRandom

func NewBloomRandom(numItems uint64, falseRate float64, maxBits uint64) *Bloom

func (*Bloom) Add

func (b *Bloom) Add(key *Hash)

func (*Bloom) BincodeSerialize

func (obj *Bloom) BincodeSerialize() ([]byte, error)

func (*Bloom) Clear

func (b *Bloom) Clear()

func (*Bloom) Contains

func (b *Bloom) Contains(key *Hash) bool

func (*Bloom) Pos

func (b *Bloom) Pos(key *Hash, k uint64) uint64

func (*Bloom) Serialize

func (obj *Bloom) Serialize(serializer serde.Serializer) error

type CompressedSlots

type CompressedSlots interface {
	Serialize(serializer serde.Serializer) error
	BincodeSerialize() ([]byte, error)
	// contains filtered or unexported methods
}

func BincodeDeserializeCompressedSlots

func BincodeDeserializeCompressedSlots(input []byte) (CompressedSlots, error)

func DeserializeCompressedSlots

func DeserializeCompressedSlots(deserializer serde.Deserializer) (CompressedSlots, error)

type CompressedSlots__Flate2

type CompressedSlots__Flate2 struct {
	Value SlotsFlate2
}

func (*CompressedSlots__Flate2) BincodeSerialize

func (obj *CompressedSlots__Flate2) BincodeSerialize() ([]byte, error)

func (*CompressedSlots__Flate2) Serialize

func (obj *CompressedSlots__Flate2) Serialize(serializer serde.Serializer) error

type CompressedSlots__Uncompressed

type CompressedSlots__Uncompressed struct {
	Value SlotsUncompressed
}

func (*CompressedSlots__Uncompressed) BincodeSerialize

func (obj *CompressedSlots__Uncompressed) BincodeSerialize() ([]byte, error)

func (*CompressedSlots__Uncompressed) Serialize

func (obj *CompressedSlots__Uncompressed) Serialize(serializer serde.Serializer) error

type ContactInfo

type ContactInfo struct {
	Id           Pubkey
	Gossip       SocketAddr
	Tvu          SocketAddr
	TvuForwards  SocketAddr
	Repair       SocketAddr
	Tpu          SocketAddr
	TpuForwards  SocketAddr
	TpuVote      SocketAddr
	Rpc          SocketAddr
	RpcPubsub    SocketAddr
	ServeRepair  SocketAddr
	Wallclock    uint64
	ShredVersion uint16
}

func BincodeDeserializeContactInfo

func BincodeDeserializeContactInfo(input []byte) (ContactInfo, error)

func DeserializeContactInfo

func DeserializeContactInfo(deserializer serde.Deserializer) (ContactInfo, error)

func (*ContactInfo) BincodeSerialize

func (obj *ContactInfo) BincodeSerialize() ([]byte, error)

func (*ContactInfo) Serialize

func (obj *ContactInfo) Serialize(serializer serde.Serializer) error

type CrdsData

type CrdsData interface {
	Serialize(serializer serde.Serializer) error
	BincodeSerialize() ([]byte, error)
	Pubkey() *Pubkey
	// contains filtered or unexported methods
}

func BincodeDeserializeCrdsData

func BincodeDeserializeCrdsData(input []byte) (CrdsData, error)

func DeserializeCrdsData

func DeserializeCrdsData(deserializer serde.Deserializer) (CrdsData, error)

type CrdsData__AccountsHashes

type CrdsData__AccountsHashes struct {
	Value SnapshotHashes
}

func (*CrdsData__AccountsHashes) BincodeSerialize

func (obj *CrdsData__AccountsHashes) BincodeSerialize() ([]byte, error)

func (*CrdsData__AccountsHashes) Pubkey

func (obj *CrdsData__AccountsHashes) Pubkey() *Pubkey

func (*CrdsData__AccountsHashes) Serialize

func (obj *CrdsData__AccountsHashes) Serialize(serializer serde.Serializer) error

type CrdsData__ContactInfo

type CrdsData__ContactInfo struct {
	Value ContactInfo
}

func (*CrdsData__ContactInfo) BincodeSerialize

func (obj *CrdsData__ContactInfo) BincodeSerialize() ([]byte, error)

func (*CrdsData__ContactInfo) Pubkey

func (obj *CrdsData__ContactInfo) Pubkey() *Pubkey

func (*CrdsData__ContactInfo) Serialize

func (obj *CrdsData__ContactInfo) Serialize(serializer serde.Serializer) error

type CrdsData__DuplicateShred

type CrdsData__DuplicateShred struct {
	Field0 uint16
	Field1 DuplicateShred
}

func (*CrdsData__DuplicateShred) BincodeSerialize

func (obj *CrdsData__DuplicateShred) BincodeSerialize() ([]byte, error)

func (*CrdsData__DuplicateShred) Pubkey

func (obj *CrdsData__DuplicateShred) Pubkey() *Pubkey

func (*CrdsData__DuplicateShred) Serialize

func (obj *CrdsData__DuplicateShred) Serialize(serializer serde.Serializer) error

type CrdsData__EpochSlots

type CrdsData__EpochSlots struct {
	Field0 uint8
	Field1 EpochSlots
}

func (*CrdsData__EpochSlots) BincodeSerialize

func (obj *CrdsData__EpochSlots) BincodeSerialize() ([]byte, error)

func (*CrdsData__EpochSlots) Pubkey

func (obj *CrdsData__EpochSlots) Pubkey() *Pubkey

func (*CrdsData__EpochSlots) Serialize

func (obj *CrdsData__EpochSlots) Serialize(serializer serde.Serializer) error

type CrdsData__IncrementalSnapshotHashes

type CrdsData__IncrementalSnapshotHashes struct {
	Value IncrementalSnapshotHashes
}

func (*CrdsData__IncrementalSnapshotHashes) BincodeSerialize

func (obj *CrdsData__IncrementalSnapshotHashes) BincodeSerialize() ([]byte, error)

func (*CrdsData__IncrementalSnapshotHashes) Pubkey

func (*CrdsData__IncrementalSnapshotHashes) Serialize

func (obj *CrdsData__IncrementalSnapshotHashes) Serialize(serializer serde.Serializer) error

type CrdsData__LegacyVersion

type CrdsData__LegacyVersion struct {
	From      Pubkey
	Wallclock uint64
	Major     uint16
	Minor     uint16
	Patch     uint16
	Commit    *uint32
}

func (*CrdsData__LegacyVersion) BincodeSerialize

func (obj *CrdsData__LegacyVersion) BincodeSerialize() ([]byte, error)

func (*CrdsData__LegacyVersion) Pubkey

func (obj *CrdsData__LegacyVersion) Pubkey() *Pubkey

func (*CrdsData__LegacyVersion) Serialize

func (obj *CrdsData__LegacyVersion) Serialize(serializer serde.Serializer) error

type CrdsData__LowestSlot

type CrdsData__LowestSlot struct {
	Field0 uint8
	Field1 LowestSlot
}

func (*CrdsData__LowestSlot) BincodeSerialize

func (obj *CrdsData__LowestSlot) BincodeSerialize() ([]byte, error)

func (*CrdsData__LowestSlot) Pubkey

func (obj *CrdsData__LowestSlot) Pubkey() *Pubkey

func (*CrdsData__LowestSlot) Serialize

func (obj *CrdsData__LowestSlot) Serialize(serializer serde.Serializer) error

type CrdsData__NodeInstance

type CrdsData__NodeInstance struct {
	From      Pubkey
	Wallclock uint64
	Timestamp uint64
	Token     uint64
}

func (*CrdsData__NodeInstance) BincodeSerialize

func (obj *CrdsData__NodeInstance) BincodeSerialize() ([]byte, error)

func (*CrdsData__NodeInstance) Pubkey

func (obj *CrdsData__NodeInstance) Pubkey() *Pubkey

func (*CrdsData__NodeInstance) Serialize

func (obj *CrdsData__NodeInstance) Serialize(serializer serde.Serializer) error

type CrdsData__SnapshotHashes

type CrdsData__SnapshotHashes struct {
	Value SnapshotHashes
}

func (*CrdsData__SnapshotHashes) BincodeSerialize

func (obj *CrdsData__SnapshotHashes) BincodeSerialize() ([]byte, error)

func (*CrdsData__SnapshotHashes) Pubkey

func (obj *CrdsData__SnapshotHashes) Pubkey() *Pubkey

func (*CrdsData__SnapshotHashes) Serialize

func (obj *CrdsData__SnapshotHashes) Serialize(serializer serde.Serializer) error

type CrdsData__Version

type CrdsData__Version struct {
	From       Pubkey
	Wallclock  uint64
	Major      uint16
	Minor      uint16
	Patch      uint16
	Commit     *uint32
	FeatureSet uint32
}

func (*CrdsData__Version) BincodeSerialize

func (obj *CrdsData__Version) BincodeSerialize() ([]byte, error)

func (*CrdsData__Version) Pubkey

func (obj *CrdsData__Version) Pubkey() *Pubkey

func (*CrdsData__Version) Serialize

func (obj *CrdsData__Version) Serialize(serializer serde.Serializer) error

type CrdsData__Vote

type CrdsData__Vote struct {
	Field0 uint8
	Field1 Vote
}

func (*CrdsData__Vote) BincodeSerialize

func (obj *CrdsData__Vote) BincodeSerialize() ([]byte, error)

func (*CrdsData__Vote) Pubkey

func (obj *CrdsData__Vote) Pubkey() *Pubkey

func (*CrdsData__Vote) Serialize

func (obj *CrdsData__Vote) Serialize(serializer serde.Serializer) error

type CrdsFilter

type CrdsFilter struct {
	Filter   Bloom
	Mask     uint64
	MaskBits uint32
}

func BincodeDeserializeCrdsFilter

func BincodeDeserializeCrdsFilter(input []byte) (CrdsFilter, error)

func DeserializeCrdsFilter

func DeserializeCrdsFilter(deserializer serde.Deserializer) (CrdsFilter, error)

func (*CrdsFilter) BincodeSerialize

func (obj *CrdsFilter) BincodeSerialize() ([]byte, error)

func (*CrdsFilter) Contains

func (f *CrdsFilter) Contains(item *Hash) bool

func (*CrdsFilter) Serialize

func (obj *CrdsFilter) Serialize(serializer serde.Serializer) error

func (*CrdsFilter) TestMask

func (f *CrdsFilter) TestMask(item *Hash) bool

type CrdsFilterSet

type CrdsFilterSet []CrdsFilter

func NewCrdsFilterSet

func NewCrdsFilterSet(numItems, maxBytes uint64) CrdsFilterSet

func (CrdsFilterSet) Add

func (c CrdsFilterSet) Add(h Hash)

type CrdsValue

type CrdsValue struct {
	Signature Signature
	Data      CrdsData
}

func BincodeDeserializeCrdsValue

func BincodeDeserializeCrdsValue(input []byte) (CrdsValue, error)

func DeserializeCrdsValue

func DeserializeCrdsValue(deserializer serde.Deserializer) (CrdsValue, error)

func (*CrdsValue) BincodeSerialize

func (obj *CrdsValue) BincodeSerialize() ([]byte, error)

func (*CrdsValue) Serialize

func (obj *CrdsValue) Serialize(serializer serde.Serializer) error

func (*CrdsValue) Sign

func (c *CrdsValue) Sign(identity ed25519.PrivateKey) error

func (*CrdsValue) VerifySignature

func (c *CrdsValue) VerifySignature() bool

type Driver

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

Driver implements the network main loop.

Note: This uses Go 1.19 standard library networking, which processes packets one-by-one. (slow!) Looks like Go 1.20 will add batch packet receive: https://github.com/golang/go/issues/45886

func NewDriver

func NewDriver(handler *Handler, so *net.UDPConn) *Driver

func (*Driver) Run

func (c *Driver) Run(ctx context.Context) error

Run processes packets until the context is cancelled.

Destroys all handlers and closes the socket after returning. Returns any network error or nil if the context closed.

type DuplicateShred

type DuplicateShred struct {
	From       Pubkey
	Wallclock  uint64
	Slot       uint64
	ShredIndex uint32
	ShredType  uint8
	NumChunks  uint8
	ChunkIndex uint8
	Chunk      []uint8
}

func BincodeDeserializeDuplicateShred

func BincodeDeserializeDuplicateShred(input []byte) (DuplicateShred, error)

func DeserializeDuplicateShred

func DeserializeDuplicateShred(deserializer serde.Deserializer) (DuplicateShred, error)

func (*DuplicateShred) BincodeSerialize

func (obj *DuplicateShred) BincodeSerialize() ([]byte, error)

func (*DuplicateShred) Serialize

func (obj *DuplicateShred) Serialize(serializer serde.Serializer) error

type EpochSlots

type EpochSlots struct {
	From      Pubkey
	Slots     []CompressedSlots
	Wallclock uint64
}

func BincodeDeserializeEpochSlots

func BincodeDeserializeEpochSlots(input []byte) (EpochSlots, error)

func DeserializeEpochSlots

func DeserializeEpochSlots(deserializer serde.Deserializer) (EpochSlots, error)

func (*EpochSlots) BincodeSerialize

func (obj *EpochSlots) BincodeSerialize() ([]byte, error)

func (*EpochSlots) Serialize

func (obj *EpochSlots) Serialize(serializer serde.Serializer) error

type Handler

type Handler struct {
	*PullClient
	*PingClient
	*PingServer
	// contains filtered or unexported fields
}

Handler is a network-agnostic multiplexer for incoming gossip messages.

func (*Handler) Close

func (h *Handler) Close()

Close destroys all handlers.

func (*Handler) HandlePacket

func (h *Handler) HandlePacket(packet []byte, from netip.AddrPort)

HandlePacket is the entrypoint of the RX side.

type Hash

type Hash [32]uint8

func BincodeDeserializeHash

func BincodeDeserializeHash(input []byte) (Hash, error)

func DeserializeHash

func DeserializeHash(deserializer serde.Deserializer) (Hash, error)

func (*Hash) BincodeSerialize

func (obj *Hash) BincodeSerialize() ([]byte, error)

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

func (*Hash) Serialize

func (obj *Hash) Serialize(serializer serde.Serializer) error

type IncrementalSnapshotHashes

type IncrementalSnapshotHashes struct {
	From      Pubkey
	Base      SlotHash
	Hashes    []SlotHash
	Wallclock uint64
}

func BincodeDeserializeIncrementalSnapshotHashes

func BincodeDeserializeIncrementalSnapshotHashes(input []byte) (IncrementalSnapshotHashes, error)

func DeserializeIncrementalSnapshotHashes

func DeserializeIncrementalSnapshotHashes(deserializer serde.Deserializer) (IncrementalSnapshotHashes, error)

func (*IncrementalSnapshotHashes) BincodeSerialize

func (obj *IncrementalSnapshotHashes) BincodeSerialize() ([]byte, error)

func (*IncrementalSnapshotHashes) Serialize

func (obj *IncrementalSnapshotHashes) Serialize(serializer serde.Serializer) error

type LowestSlot

type LowestSlot struct {
	From      Pubkey
	Root      uint64
	Lowest    uint64
	Slots     []uint64
	Stash     []struct{}
	Wallclock uint64
}

func BincodeDeserializeLowestSlot

func BincodeDeserializeLowestSlot(input []byte) (LowestSlot, error)

func DeserializeLowestSlot

func DeserializeLowestSlot(deserializer serde.Deserializer) (LowestSlot, error)

func (*LowestSlot) BincodeSerialize

func (obj *LowestSlot) BincodeSerialize() ([]byte, error)

func (*LowestSlot) Serialize

func (obj *LowestSlot) Serialize(serializer serde.Serializer) error

type Message

type Message interface {
	Serialize(serializer serde.Serializer) error
	BincodeSerialize() ([]byte, error)
	// contains filtered or unexported methods
}

func BincodeDeserializeMessage

func BincodeDeserializeMessage(input []byte) (Message, error)

func DeserializeMessage

func DeserializeMessage(deserializer serde.Deserializer) (Message, error)

type Message__Ping

type Message__Ping struct {
	Value Ping
}

func (*Message__Ping) BincodeSerialize

func (obj *Message__Ping) BincodeSerialize() ([]byte, error)

func (*Message__Ping) Serialize

func (obj *Message__Ping) Serialize(serializer serde.Serializer) error

type Message__Pong

type Message__Pong struct {
	Value Ping
}

func (*Message__Pong) BincodeSerialize

func (obj *Message__Pong) BincodeSerialize() ([]byte, error)

func (*Message__Pong) Serialize

func (obj *Message__Pong) Serialize(serializer serde.Serializer) error

type Message__PruneMessage

type Message__PruneMessage struct {
	Pubkey Pubkey
	Data   PruneData
}

func (*Message__PruneMessage) BincodeSerialize

func (obj *Message__PruneMessage) BincodeSerialize() ([]byte, error)

func (*Message__PruneMessage) Serialize

func (obj *Message__PruneMessage) Serialize(serializer serde.Serializer) error

type Message__PullRequest

type Message__PullRequest struct {
	Filter CrdsFilter
	Value  CrdsValue
}

func (*Message__PullRequest) BincodeSerialize

func (obj *Message__PullRequest) BincodeSerialize() ([]byte, error)

func (*Message__PullRequest) Serialize

func (obj *Message__PullRequest) Serialize(serializer serde.Serializer) error

type Message__PullResponse

type Message__PullResponse struct {
	Pubkey Pubkey
	Values []CrdsValue
}

func (*Message__PullResponse) BincodeSerialize

func (obj *Message__PullResponse) BincodeSerialize() ([]byte, error)

func (*Message__PullResponse) Serialize

func (obj *Message__PullResponse) Serialize(serializer serde.Serializer) error

type Message__PushMessage

type Message__PushMessage struct {
	Pubkey Pubkey
	Values []CrdsValue
}

func (*Message__PushMessage) BincodeSerialize

func (obj *Message__PushMessage) BincodeSerialize() ([]byte, error)

func (*Message__PushMessage) Serialize

func (obj *Message__PushMessage) Serialize(serializer serde.Serializer) error

type Ping

type Ping struct {
	From      Pubkey
	Token     Hash
	Signature Signature
}

func BincodeDeserializePing

func BincodeDeserializePing(input []byte) (Ping, error)

func DeserializePing

func DeserializePing(deserializer serde.Deserializer) (Ping, error)

func NewPing

func NewPing(token [32]byte, key ed25519.PrivateKey) (p Ping)

NewPing creates and signs a new ping message.

Panics if the provided private key is invalid.

func NewPingRandom

func NewPingRandom(key ed25519.PrivateKey) Ping

func (*Ping) BincodeSerialize

func (obj *Ping) BincodeSerialize() ([]byte, error)

func (*Ping) Serialize

func (obj *Ping) Serialize(serializer serde.Serializer) error

func (*Ping) Verify

func (p *Ping) Verify() bool

Verify checks the Ping's signature.

type PingClient

type PingClient struct {
	NumSent     atomic.Uint64 // ping messages sent
	NumOK       atomic.Uint64 // successful ping transaction
	NumInvalid  atomic.Uint64 // invalid sig in pong
	NumTimeout  atomic.Uint64 // context errored before pong arrived
	NumSendFail atomic.Uint64 // socket refused to send (tx buffer full)
	NumMartian  atomic.Uint64 // unsolicited pong
	// contains filtered or unexported fields
}

PingClient implements the stateful client (initiator) side of the gossip ping protocol.

It tracks every pending request to match it with solicited pong frames.

func NewPingClient

func NewPingClient(identity ed25519.PrivateKey, so udpSender) *PingClient

func (*PingClient) Close

func (p *PingClient) Close()

func (*PingClient) HandlePong

func (p *PingClient) HandlePong(msg *Message__Pong, from netip.AddrPort)

HandlePong processes incoming gossip pong messages.

func (*PingClient) Ping

func (p *PingClient) Ping(ctx context.Context, target netip.AddrPort) (pong Ping, responder netip.AddrPort, err error)

Ping sends a gossip ping packet. Blocks until a valid matching pong packet arrives or the context is cancelled.

Note that this mechanism is unrelated to ICMP pings.

type PingServer

type PingServer struct {
	NumOK       atomic.Uint64 // handled pings, though uncertain whether pong arrived
	NumInvalid  atomic.Uint64 // invalid sig in ping
	NumSendFail atomic.Uint64 // socket refused to send (tx buffer full)
	// contains filtered or unexported fields
}

PingServer implements the stateless server (reactor) side of the gossip ping protocol.

It implements no rate-limits and is thus vulnerable to packet floods.

func NewPingServer

func NewPingServer(identity ed25519.PrivateKey, so udpSender) *PingServer

func (*PingServer) HandlePing

func (p *PingServer) HandlePing(ping *Message__Ping, from netip.AddrPort)

HandlePing processes incoming gossip ping messages.

type PruneData

type PruneData struct {
	Pubkey      Pubkey
	Prunes      []Pubkey
	Signature   Signature
	Destination Pubkey
	Wallclock   uint64
}

func BincodeDeserializePruneData

func BincodeDeserializePruneData(input []byte) (PruneData, error)

func DeserializePruneData

func DeserializePruneData(deserializer serde.Deserializer) (PruneData, error)

func (*PruneData) BincodeSerialize

func (obj *PruneData) BincodeSerialize() ([]byte, error)

func (*PruneData) Serialize

func (obj *PruneData) Serialize(serializer serde.Serializer) error

type Pubkey

type Pubkey [32]uint8

func BincodeDeserializePubkey

func BincodeDeserializePubkey(input []byte) (Pubkey, error)

func DeserializePubkey

func DeserializePubkey(deserializer serde.Deserializer) (Pubkey, error)

func (*Pubkey) BincodeSerialize

func (obj *Pubkey) BincodeSerialize() ([]byte, error)

func (Pubkey) MarshalText

func (p Pubkey) MarshalText() ([]byte, error)

func (*Pubkey) Serialize

func (obj *Pubkey) Serialize(serializer serde.Serializer) error

type PullClient

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

PullClient implements the stateful client (initiator) side of the gossip pull protocol.

func NewPullClient

func NewPullClient(identity ed25519.PrivateKey, so udpSender) *PullClient

func (*PullClient) HandlePullResponse

func (p *PullClient) HandlePullResponse(msg *Message__PullResponse, _ netip.AddrPort)

func (*PullClient) Pull

func (p *PullClient) Pull(target netip.AddrPort) error

type RawAddr

type RawAddr interface {
	Serialize(serializer serde.Serializer) error
	BincodeSerialize() ([]byte, error)
	// contains filtered or unexported methods
}

func BincodeDeserializeRawAddr

func BincodeDeserializeRawAddr(input []byte) (RawAddr, error)

func DeserializeRawAddr

func DeserializeRawAddr(deserializer serde.Deserializer) (RawAddr, error)

type RawAddr__V4

type RawAddr__V4 [4]uint8

func (*RawAddr__V4) BincodeSerialize

func (obj *RawAddr__V4) BincodeSerialize() ([]byte, error)

func (*RawAddr__V4) Serialize

func (obj *RawAddr__V4) Serialize(serializer serde.Serializer) error

type RawAddr__V6

type RawAddr__V6 [16]uint8

func (*RawAddr__V6) BincodeSerialize

func (obj *RawAddr__V6) BincodeSerialize() ([]byte, error)

func (*RawAddr__V6) Serialize

func (obj *RawAddr__V6) Serialize(serializer serde.Serializer) error

type RawSocketAddr

type RawSocketAddr struct {
	Addr Addr
	Port uint16
}

func BincodeDeserializeRawSocketAddr

func BincodeDeserializeRawSocketAddr(input []byte) (RawSocketAddr, error)

func DeserializeRawSocketAddr

func DeserializeRawSocketAddr(deserializer serde.Deserializer) (RawSocketAddr, error)

func (*RawSocketAddr) BincodeSerialize

func (obj *RawSocketAddr) BincodeSerialize() ([]byte, error)

func (*RawSocketAddr) Serialize

func (obj *RawSocketAddr) Serialize(serializer serde.Serializer) error

type Signature

type Signature [64]uint8

func BincodeDeserializeSignature

func BincodeDeserializeSignature(input []byte) (Signature, error)

func DeserializeSignature

func DeserializeSignature(deserializer serde.Deserializer) (Signature, error)

func (*Signature) BincodeSerialize

func (obj *Signature) BincodeSerialize() ([]byte, error)

func (Signature) MarshalText

func (s Signature) MarshalText() ([]byte, error)

func (*Signature) Serialize

func (obj *Signature) Serialize(serializer serde.Serializer) error

type SlotHash

type SlotHash struct {
	Slot uint64
	Hash Hash
}

func BincodeDeserializeSlotHash

func BincodeDeserializeSlotHash(input []byte) (SlotHash, error)

func DeserializeSlotHash

func DeserializeSlotHash(deserializer serde.Deserializer) (SlotHash, error)

func (*SlotHash) BincodeSerialize

func (obj *SlotHash) BincodeSerialize() ([]byte, error)

func (*SlotHash) Serialize

func (obj *SlotHash) Serialize(serializer serde.Serializer) error

type SlotsFlate2

type SlotsFlate2 struct {
	FirstSlot  uint64
	Num        uint64
	Compressed []uint8
}

func BincodeDeserializeSlotsFlate2

func BincodeDeserializeSlotsFlate2(input []byte) (SlotsFlate2, error)

func DeserializeSlotsFlate2

func DeserializeSlotsFlate2(deserializer serde.Deserializer) (SlotsFlate2, error)

func (*SlotsFlate2) BincodeSerialize

func (obj *SlotsFlate2) BincodeSerialize() ([]byte, error)

func (*SlotsFlate2) Serialize

func (obj *SlotsFlate2) Serialize(serializer serde.Serializer) error

type SlotsUncompressed

type SlotsUncompressed struct {
	FirstSlot uint64
	Num       uint64
	Slots     BitVecU8
}

func BincodeDeserializeSlotsUncompressed

func BincodeDeserializeSlotsUncompressed(input []byte) (SlotsUncompressed, error)

func DeserializeSlotsUncompressed

func DeserializeSlotsUncompressed(deserializer serde.Deserializer) (SlotsUncompressed, error)

func (*SlotsUncompressed) BincodeSerialize

func (obj *SlotsUncompressed) BincodeSerialize() ([]byte, error)

func (*SlotsUncompressed) Serialize

func (obj *SlotsUncompressed) Serialize(serializer serde.Serializer) error

type SnapshotHashes

type SnapshotHashes struct {
	From      Pubkey
	Hashes    []SlotHash
	Wallclock uint64
}

func BincodeDeserializeSnapshotHashes

func BincodeDeserializeSnapshotHashes(input []byte) (SnapshotHashes, error)

func DeserializeSnapshotHashes

func DeserializeSnapshotHashes(deserializer serde.Deserializer) (SnapshotHashes, error)

func (*SnapshotHashes) BincodeSerialize

func (obj *SnapshotHashes) BincodeSerialize() ([]byte, error)

func (*SnapshotHashes) Serialize

func (obj *SnapshotHashes) Serialize(serializer serde.Serializer) error

type SocketAddr

type SocketAddr struct {
	netip.AddrPort
}

func DeserializeSocketAddr

func DeserializeSocketAddr(deserializer serde.Deserializer) (sa SocketAddr, err error)

func (SocketAddr) Serialize

func (sa SocketAddr) Serialize(serializer serde.Serializer) error

type Transaction

type Transaction solana.Transaction

func DeserializeTransaction

func DeserializeTransaction(deserializer serde.Deserializer) (Transaction, error)

func (*Transaction) Serialize

func (obj *Transaction) Serialize(serializer serde.Serializer) error

type Vote

type Vote struct {
	From        Pubkey
	Transaction Transaction
	Wallclock   uint64
	Slot        *uint64
}

func BincodeDeserializeVote

func BincodeDeserializeVote(input []byte) (Vote, error)

func DeserializeVote

func DeserializeVote(deserializer serde.Deserializer) (Vote, error)

func (*Vote) BincodeSerialize

func (obj *Vote) BincodeSerialize() ([]byte, error)

func (*Vote) Serialize

func (obj *Vote) Serialize(serializer serde.Serializer) error

Jump to

Keyboard shortcuts

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