link_solicit

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const HashSize = 32

HashSize is the size of a BLAKE3 hash in bytes.

Variables

This section is empty.

Functions

func ComputeProtocolHash

func ComputeProtocolHash(sessionID []byte, protocolID protocol.ID, context []byte) []byte

ComputeProtocolHash returns BLAKE3(session_id || protocol_id || context).

func ComputeProtocolHashes

func ComputeProtocolHashes(sessionID []byte, entries []SolicitEntry) [][]byte

ComputeProtocolHashes returns sorted hashes for a set of (protocolID, context) pairs.

func ComputeSessionID

func ComputeSessionID(peerA, peerB peer.ID) []byte

ComputeSessionID returns BLAKE3(lower_peer || higher_peer). Peers are lexicographically sorted to produce a canonical ordering. Both sides of a link compute the same session ID since the peer IDs are the same regardless of which side you're on.

func FindMatchingHashes

func FindMatchingHashes(local, remote [][]byte) [][]byte

FindMatchingHashes returns the hashes present in both sorted sets. Both input slices must be sorted.

func SortHashes

func SortHashes(hashes [][]byte)

SortHashes sorts a slice of hashes lexicographically.

Types

type SolicitEntry

type SolicitEntry struct {
	ProtocolID protocol.ID
	Context    []byte
}

SolicitEntry is a (protocolID, context) pair for hash computation.

type SolicitMountedStream

type SolicitMountedStream interface {
	// AcceptMountedStream claims ownership of the stream.
	// Returns (stream, false, nil) on success.
	// Returns (nil, true, nil) if already accepted by another caller.
	// Returns (nil, false, err) if the stream is closed or errored.
	AcceptMountedStream() (link.MountedStream, bool, error)
}

SolicitMountedStream is the value type for SolicitProtocol. It wraps a solicited stream that was matched via hash exchange.

func ExSolicitProtocol

func ExSolicitProtocol(
	ctx context.Context,
	b bus.Bus,
	protocolID protocol.ID,
	bctx []byte,
	peerID peer.ID,
	transportID uint64,
) (SolicitMountedStream, directive.Instance, directive.Reference, error)

ExSolicitProtocol executes the SolicitProtocol directive, waiting for a single matched stream. Returns the SolicitMountedStream value, the directive instance, a reference to release, and any error.

func NewSolicitMountedStream

func NewSolicitMountedStream(ms link.MountedStream) SolicitMountedStream

NewSolicitMountedStream constructs a new SolicitMountedStream value.

func NewSolicitMountedStreamWithErr

func NewSolicitMountedStreamWithErr(err error) SolicitMountedStream

NewSolicitMountedStreamWithErr constructs an errored SolicitMountedStream.

type SolicitProtocol

type SolicitProtocol interface {
	// Directive indicates SolicitProtocol is a directive.
	directive.Directive

	// SolicitProtocolID returns the protocol ID to solicit.
	SolicitProtocolID() protocol.ID
	// SolicitProtocolContext returns the opaque context for the solicitation.
	// Different contexts produce different hashes (no match).
	SolicitProtocolContext() []byte
	// SolicitProtocolPeerID returns the optional peer ID constraint.
	// If empty, solicits on all active links.
	SolicitProtocolPeerID() peer.ID
	// SolicitProtocolTransportID returns the optional transport constraint.
	// If 0, solicits on all transports.
	SolicitProtocolTransportID() uint64
}

SolicitProtocol is a directive to solicit a protocol with peers.

When both sides emit SolicitProtocol for the same protocol (matching hash), a stream is established and both directives resolve with a SolicitMountedStream value.

Value type: SolicitMountedStream

func NewSolicitProtocol

func NewSolicitProtocol(
	protocolID protocol.ID,
	ctx []byte,
	peerID peer.ID,
	transportID uint64,
) SolicitProtocol

NewSolicitProtocol constructs a new SolicitProtocol directive.

type SolicitProtocolRequest

type SolicitProtocolRequest struct {

	// ProtocolId is the protocol ID to solicit.
	ProtocolId string `protobuf:"bytes,1,opt,name=protocol_id,json=protocolId,proto3" json:"protocolId,omitempty"`
	// Context is opaque context bytes for the solicitation.
	// Different contexts produce different hashes (no match).
	Context []byte `protobuf:"bytes,2,opt,name=context,proto3" json:"context,omitempty"`
	// PeerId constrains solicitation to a specific peer.
	// If empty, solicits on all active links.
	PeerId string `protobuf:"bytes,3,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
	// TransportId constrains solicitation to a specific transport.
	// If 0, solicits on all transports.
	TransportId uint64 `protobuf:"varint,4,opt,name=transport_id,json=transportId,proto3" json:"transportId,omitempty"`
	// contains filtered or unexported fields
}

SolicitProtocolRequest is the directive request for protocol solicitation.

func (*SolicitProtocolRequest) CloneMessageVT

func (*SolicitProtocolRequest) CloneVT

func (*SolicitProtocolRequest) EqualMessageVT

func (this *SolicitProtocolRequest) EqualMessageVT(thatMsg any) bool

func (*SolicitProtocolRequest) EqualVT

func (this *SolicitProtocolRequest) EqualVT(that *SolicitProtocolRequest) bool

func (*SolicitProtocolRequest) GetContext

func (x *SolicitProtocolRequest) GetContext() []byte

func (*SolicitProtocolRequest) GetPeerId

func (x *SolicitProtocolRequest) GetPeerId() string

func (*SolicitProtocolRequest) GetProtocolId

func (x *SolicitProtocolRequest) GetProtocolId() string

func (*SolicitProtocolRequest) GetTransportId

func (x *SolicitProtocolRequest) GetTransportId() uint64

func (*SolicitProtocolRequest) MarshalJSON

func (x *SolicitProtocolRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SolicitProtocolRequest to JSON.

func (*SolicitProtocolRequest) MarshalProtoJSON

func (x *SolicitProtocolRequest) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SolicitProtocolRequest message to JSON.

func (*SolicitProtocolRequest) MarshalProtoText

func (x *SolicitProtocolRequest) MarshalProtoText() string

func (*SolicitProtocolRequest) MarshalToSizedBufferVT

func (m *SolicitProtocolRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SolicitProtocolRequest) MarshalToVT

func (m *SolicitProtocolRequest) MarshalToVT(dAtA []byte) (int, error)

func (*SolicitProtocolRequest) MarshalVT

func (m *SolicitProtocolRequest) MarshalVT() (dAtA []byte, err error)

func (*SolicitProtocolRequest) ProtoMessage

func (*SolicitProtocolRequest) ProtoMessage()

func (*SolicitProtocolRequest) Reset

func (x *SolicitProtocolRequest) Reset()

func (*SolicitProtocolRequest) SizeVT

func (m *SolicitProtocolRequest) SizeVT() (n int)

func (*SolicitProtocolRequest) String

func (x *SolicitProtocolRequest) String() string

func (*SolicitProtocolRequest) UnmarshalJSON

func (x *SolicitProtocolRequest) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SolicitProtocolRequest from JSON.

func (*SolicitProtocolRequest) UnmarshalProtoJSON

func (x *SolicitProtocolRequest) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SolicitProtocolRequest message from JSON.

func (*SolicitProtocolRequest) UnmarshalVT

func (m *SolicitProtocolRequest) UnmarshalVT(dAtA []byte) error

type SolicitProtocolValue

type SolicitProtocolValue = SolicitMountedStream

SolicitProtocolValue is the type emitted when resolving SolicitProtocol.

type SolicitationExchange

type SolicitationExchange struct {

	// ProtocolHashes contains sorted BLAKE3 hashes.
	// Each hash is 32 bytes.
	// Max 256 entries.
	ProtocolHashes [][]byte `protobuf:"bytes,1,rep,name=protocol_hashes,json=protocolHashes,proto3" json:"protocolHashes,omitempty"`
	// contains filtered or unexported fields
}

SolicitationExchange is sent on the control stream. Full hash set, re-sent each time the local set changes.

func (*SolicitationExchange) CloneMessageVT

func (*SolicitationExchange) CloneVT

func (*SolicitationExchange) EqualMessageVT

func (this *SolicitationExchange) EqualMessageVT(thatMsg any) bool

func (*SolicitationExchange) EqualVT

func (this *SolicitationExchange) EqualVT(that *SolicitationExchange) bool

func (*SolicitationExchange) GetProtocolHashes

func (x *SolicitationExchange) GetProtocolHashes() [][]byte

func (*SolicitationExchange) MarshalJSON

func (x *SolicitationExchange) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SolicitationExchange to JSON.

func (*SolicitationExchange) MarshalProtoJSON

func (x *SolicitationExchange) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SolicitationExchange message to JSON.

func (*SolicitationExchange) MarshalProtoText

func (x *SolicitationExchange) MarshalProtoText() string

func (*SolicitationExchange) MarshalToSizedBufferVT

func (m *SolicitationExchange) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SolicitationExchange) MarshalToVT

func (m *SolicitationExchange) MarshalToVT(dAtA []byte) (int, error)

func (*SolicitationExchange) MarshalVT

func (m *SolicitationExchange) MarshalVT() (dAtA []byte, err error)

func (*SolicitationExchange) ProtoMessage

func (*SolicitationExchange) ProtoMessage()

func (*SolicitationExchange) Reset

func (x *SolicitationExchange) Reset()

func (*SolicitationExchange) SizeVT

func (m *SolicitationExchange) SizeVT() (n int)

func (*SolicitationExchange) String

func (x *SolicitationExchange) String() string

func (*SolicitationExchange) UnmarshalJSON

func (x *SolicitationExchange) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SolicitationExchange from JSON.

func (*SolicitationExchange) UnmarshalProtoJSON

func (x *SolicitationExchange) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SolicitationExchange message from JSON.

func (*SolicitationExchange) UnmarshalVT

func (m *SolicitationExchange) UnmarshalVT(dAtA []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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