Documentation ¶
Index ¶
- Variables
- func ParsePeers(pbps []*Message_Peer) []kad.NodeInfo[key.Key256, multiaddr.Multiaddr]
- func ReadMsg(s network.Stream, msg protoreflect.ProtoMessage) error
- func WriteMsg(s network.Stream, msg protoreflect.ProtoMessage) error
- type AddrInfo
- type DialReportFn
- type Libp2pEndpoint
- func (e *Libp2pEndpoint) AddRequestHandler(protoID address.ProtocolID, req kad.Message, ...) error
- func (e *Libp2pEndpoint) AsyncDialAndReport(ctx context.Context, id kad.NodeID[key.Key256], reportFn DialReportFn) error
- func (e *Libp2pEndpoint) Connectedness(id kad.NodeID[key.Key256]) (endpoint.Connectedness, error)
- func (e *Libp2pEndpoint) DialPeer(ctx context.Context, id kad.NodeID[key.Key256]) error
- func (e *Libp2pEndpoint) Key() key.Key256
- func (e *Libp2pEndpoint) MaybeAddToPeerstore(ctx context.Context, id kad.NodeInfo[key.Key256, multiaddr.Multiaddr], ...) error
- func (e *Libp2pEndpoint) NetworkAddress(n kad.NodeID[key.Key256]) (kad.NodeInfo[key.Key256, multiaddr.Multiaddr], error)
- func (e *Libp2pEndpoint) PeerInfo(id kad.NodeID[key.Key256]) (peer.AddrInfo, error)
- func (e *Libp2pEndpoint) RemoveRequestHandler(protoID address.ProtocolID)
- func (e *Libp2pEndpoint) SendRequestHandleResponse(ctx context.Context, protoID address.ProtocolID, n kad.NodeID[key.Key256], ...) error
- type Message
- func (msg *Message) CloserNodes() []kad.NodeInfo[key.Key256, multiaddr.Multiaddr]
- func (*Message) Descriptor() ([]byte, []int)deprecated
- func (msg *Message) EmptyResponse() kad.Response[key.Key256, multiaddr.Multiaddr]
- func (x *Message) GetCloserPeers() []*Message_Peer
- func (x *Message) GetClusterLevelRaw() int32
- func (x *Message) GetKey() []byte
- func (x *Message) GetProviderPeers() []*Message_Peer
- func (x *Message) GetRecord() *Record
- func (x *Message) GetType() Message_MessageType
- func (*Message) ProtoMessage()
- func (x *Message) ProtoReflect() protoreflect.Message
- func (x *Message) Reset()
- func (x *Message) String() string
- func (msg *Message) Target() key.Key256
- type Message_ConnectionType
- func (Message_ConnectionType) Descriptor() protoreflect.EnumDescriptor
- func (x Message_ConnectionType) Enum() *Message_ConnectionType
- func (Message_ConnectionType) EnumDescriptor() ([]byte, []int)deprecated
- func (x Message_ConnectionType) Number() protoreflect.EnumNumber
- func (x Message_ConnectionType) String() string
- func (Message_ConnectionType) Type() protoreflect.EnumType
- type Message_MessageType
- func (Message_MessageType) Descriptor() protoreflect.EnumDescriptor
- func (x Message_MessageType) Enum() *Message_MessageType
- func (Message_MessageType) EnumDescriptor() ([]byte, []int)deprecated
- func (x Message_MessageType) Number() protoreflect.EnumNumber
- func (x Message_MessageType) String() string
- func (Message_MessageType) Type() protoreflect.EnumType
- type Message_Peer
- func (*Message_Peer) Descriptor() ([]byte, []int)deprecated
- func (x *Message_Peer) GetAddrs() [][]byte
- func (x *Message_Peer) GetConnection() Message_ConnectionType
- func (x *Message_Peer) GetId() []byte
- func (*Message_Peer) ProtoMessage()
- func (x *Message_Peer) ProtoReflect() protoreflect.Message
- func (x *Message_Peer) Reset()
- func (x *Message_Peer) String() string
- type PeerID
- type ProtoKadMessage
- type ProtoKadRequestMessage
- type ProtoKadResponseMessage
- type Record
- func (*Record) Descriptor() ([]byte, []int)deprecated
- func (x *Record) GetKey() []byte
- func (x *Record) GetPublisher() []byte
- func (x *Record) GetTimeReceived() string
- func (x *Record) GetTtl() uint32
- func (x *Record) GetValue() []byte
- func (*Record) ProtoMessage()
- func (x *Record) ProtoReflect() protoreflect.Message
- func (x *Record) Reset()
- func (x *Record) String() string
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotPeerAddrInfo = errors.New("not peer.AddrInfo") ErrRequirePeerID = errors.New("Libp2pEndpoint requires peer.ID") ErrRequireProtoKadMessage = errors.New("Libp2pEndpoint requires ProtoKadMessage") ErrRequireProtoKadResponse = errors.New("Libp2pEndpoint requires ProtoKadResponseMessage") )
View Source
var ( Message_MessageType_name = map[int32]string{ 0: "PUT_VALUE", 1: "GET_VALUE", 2: "ADD_PROVIDER", 3: "GET_PROVIDERS", 4: "FIND_NODE", 5: "PING", } Message_MessageType_value = map[string]int32{ "PUT_VALUE": 0, "GET_VALUE": 1, "ADD_PROVIDER": 2, "GET_PROVIDERS": 3, "FIND_NODE": 4, "PING": 5, } )
Enum value maps for Message_MessageType.
View Source
var ( Message_ConnectionType_name = map[int32]string{ 0: "NOT_CONNECTED", 1: "CONNECTED", 2: "CAN_CONNECT", 3: "CANNOT_CONNECT", } Message_ConnectionType_value = map[string]int32{ "NOT_CONNECTED": 0, "CONNECTED": 1, "CAN_CONNECT": 2, "CANNOT_CONNECT": 3, } )
Enum value maps for Message_ConnectionType.
View Source
var ErrNoValidAddresses = errors.New("no valid addresses")
View Source
var File_message_proto protoreflect.FileDescriptor
Functions ¶
func ParsePeers ¶
func ParsePeers(pbps []*Message_Peer) []kad.NodeInfo[key.Key256, multiaddr.Multiaddr]
func ReadMsg ¶
func ReadMsg(s network.Stream, msg protoreflect.ProtoMessage) error
func WriteMsg ¶
func WriteMsg(s network.Stream, msg protoreflect.ProtoMessage) error
Types ¶
type AddrInfo ¶
func NewAddrInfo ¶
func PBPeerToPeerInfo ¶
func PBPeerToPeerInfo(pbp *Message_Peer) (*AddrInfo, error)
type DialReportFn ¶
type Libp2pEndpoint ¶
type Libp2pEndpoint struct {
// contains filtered or unexported fields
}
func NewLibp2pEndpoint ¶
func (*Libp2pEndpoint) AddRequestHandler ¶
func (e *Libp2pEndpoint) AddRequestHandler(protoID address.ProtocolID, req kad.Message, reqHandler endpoint.RequestHandlerFn[key.Key256], ) error
func (*Libp2pEndpoint) AsyncDialAndReport ¶
func (e *Libp2pEndpoint) AsyncDialAndReport(ctx context.Context, id kad.NodeID[key.Key256], reportFn DialReportFn, ) error
func (*Libp2pEndpoint) Connectedness ¶
func (e *Libp2pEndpoint) Connectedness(id kad.NodeID[key.Key256]) (endpoint.Connectedness, error)
func (*Libp2pEndpoint) Key ¶
func (e *Libp2pEndpoint) Key() key.Key256
func (*Libp2pEndpoint) MaybeAddToPeerstore ¶
func (*Libp2pEndpoint) NetworkAddress ¶
func (*Libp2pEndpoint) RemoveRequestHandler ¶
func (e *Libp2pEndpoint) RemoveRequestHandler(protoID address.ProtocolID)
func (*Libp2pEndpoint) SendRequestHandleResponse ¶
type Message ¶
type Message struct { // defines what type of message it is Type Message_MessageType `protobuf:"varint,1,opt,name=type,proto3,enum=dht.pb.Message_MessageType" json:"type,omitempty"` // defines what coral cluster level this query/response belongs to // in case we want to implement coral's cluster rings in the future ClusterLevelRaw int32 `protobuf:"varint,10,opt,name=clusterLevelRaw,proto3" json:"clusterLevelRaw,omitempty"` // NOT USED // Used to specify the key associated with this message // PUT_VALUE, GET_VALUE, ADD_PROVIDER, GET_PROVIDERS Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` // Used to return a value // PUT_VALUE, GET_VALUE Record *Record `protobuf:"bytes,3,opt,name=record,proto3" json:"record,omitempty"` // Used to return peers closer to a key in a query // GET_VALUE, GET_PROVIDERS, FIND_NODE CloserPeers []*Message_Peer `protobuf:"bytes,8,rep,name=closerPeers,proto3" json:"closerPeers,omitempty"` // Used to return Providers // GET_VALUE, ADD_PROVIDER, GET_PROVIDERS ProviderPeers []*Message_Peer `protobuf:"bytes,9,rep,name=providerPeers,proto3" json:"providerPeers,omitempty"` // contains filtered or unexported fields }
func FindPeerRequest ¶
func FindPeerResponse ¶
func (*Message) CloserNodes ¶
func (*Message) Descriptor
deprecated
func (*Message) EmptyResponse ¶
func (*Message) GetCloserPeers ¶
func (x *Message) GetCloserPeers() []*Message_Peer
func (*Message) GetClusterLevelRaw ¶
func (*Message) GetProviderPeers ¶
func (x *Message) GetProviderPeers() []*Message_Peer
func (*Message) GetType ¶
func (x *Message) GetType() Message_MessageType
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) ProtoReflect ¶
func (x *Message) ProtoReflect() protoreflect.Message
type Message_ConnectionType ¶
type Message_ConnectionType int32
const ( // sender does not have a connection to peer, and no extra information // (default) Message_NOT_CONNECTED Message_ConnectionType = 0 // sender has a live connection to peer Message_CONNECTED Message_ConnectionType = 1 // sender recently connected to peer Message_CAN_CONNECT Message_ConnectionType = 2 // sender recently tried to connect to peer repeatedly but failed to connect // ("try" here is loose, but this should signal "made strong effort, // failed") Message_CANNOT_CONNECT Message_ConnectionType = 3 )
func (Message_ConnectionType) Descriptor ¶
func (Message_ConnectionType) Descriptor() protoreflect.EnumDescriptor
func (Message_ConnectionType) Enum ¶
func (x Message_ConnectionType) Enum() *Message_ConnectionType
func (Message_ConnectionType) EnumDescriptor
deprecated
func (Message_ConnectionType) EnumDescriptor() ([]byte, []int)
Deprecated: Use Message_ConnectionType.Descriptor instead.
func (Message_ConnectionType) Number ¶
func (x Message_ConnectionType) Number() protoreflect.EnumNumber
func (Message_ConnectionType) String ¶
func (x Message_ConnectionType) String() string
func (Message_ConnectionType) Type ¶
func (Message_ConnectionType) Type() protoreflect.EnumType
type Message_MessageType ¶
type Message_MessageType int32
const ( Message_PUT_VALUE Message_MessageType = 0 Message_GET_VALUE Message_MessageType = 1 Message_ADD_PROVIDER Message_MessageType = 2 Message_GET_PROVIDERS Message_MessageType = 3 Message_FIND_NODE Message_MessageType = 4 Message_PING Message_MessageType = 5 )
func (Message_MessageType) Descriptor ¶
func (Message_MessageType) Descriptor() protoreflect.EnumDescriptor
func (Message_MessageType) Enum ¶
func (x Message_MessageType) Enum() *Message_MessageType
func (Message_MessageType) EnumDescriptor
deprecated
func (Message_MessageType) EnumDescriptor() ([]byte, []int)
Deprecated: Use Message_MessageType.Descriptor instead.
func (Message_MessageType) Number ¶
func (x Message_MessageType) Number() protoreflect.EnumNumber
func (Message_MessageType) String ¶
func (x Message_MessageType) String() string
func (Message_MessageType) Type ¶
func (Message_MessageType) Type() protoreflect.EnumType
type Message_Peer ¶
type Message_Peer struct { // ID of a given peer. Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // multiaddrs for a given peer Addrs [][]byte `protobuf:"bytes,2,rep,name=addrs,proto3" json:"addrs,omitempty"` // used to signal the sender's connection capabilities to the peer Connection Message_ConnectionType `protobuf:"varint,3,opt,name=connection,proto3,enum=dht.pb.Message_ConnectionType" json:"connection,omitempty"` // contains filtered or unexported fields }
func NodeIDsToPbPeers ¶
func NodeIDsToPbPeers(peers []kad.NodeID[key.Key256], e endpoint.NetworkedEndpoint[key.Key256, multiaddr.Multiaddr]) []*Message_Peer
func (*Message_Peer) Descriptor
deprecated
func (*Message_Peer) Descriptor() ([]byte, []int)
Deprecated: Use Message_Peer.ProtoReflect.Descriptor instead.
func (*Message_Peer) GetAddrs ¶
func (x *Message_Peer) GetAddrs() [][]byte
func (*Message_Peer) GetConnection ¶
func (x *Message_Peer) GetConnection() Message_ConnectionType
func (*Message_Peer) GetId ¶
func (x *Message_Peer) GetId() []byte
func (*Message_Peer) ProtoMessage ¶
func (*Message_Peer) ProtoMessage()
func (*Message_Peer) ProtoReflect ¶
func (x *Message_Peer) ProtoReflect() protoreflect.Message
func (*Message_Peer) Reset ¶
func (x *Message_Peer) Reset()
func (*Message_Peer) String ¶
func (x *Message_Peer) String() string
type ProtoKadMessage ¶
type ProtoKadRequestMessage ¶
type ProtoKadResponseMessage ¶
type Record ¶
type Record struct { // The key that references this record Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // The actual value this record is storing Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // Time the record was received, set by receiver TimeReceived string `protobuf:"bytes,5,opt,name=timeReceived,proto3" json:"timeReceived,omitempty"` // The original publisher of the record // Not used at the moment, but may be useful for future developments Publisher []byte `protobuf:"bytes,666,opt,name=publisher,proto3" json:"publisher,omitempty"` // The remaining TTL of the record, in seconds // Not used at the moment, but may be useful for future developments Ttl uint32 `protobuf:"varint,777,opt,name=ttl,proto3" json:"ttl,omitempty"` // contains filtered or unexported fields }
Record represents a dht record that contains a value for a key value pair
func (*Record) Descriptor
deprecated
func (*Record) GetPublisher ¶
func (*Record) GetTimeReceived ¶
func (*Record) ProtoMessage ¶
func (*Record) ProtoMessage()
func (*Record) ProtoReflect ¶
func (x *Record) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.