pb

package
v0.0.0-...-e07b07e Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 0

README

Protocol Buffers

To generate the protobuf definitions run:

make

This command will clone the libp2p/go-libp2p-record repository into this directory (git-ignored) and run the protoc command to generate the dht.pb.go file for the dht.proto protobuf definition. We need go-libp2p-record because dht.proto reference the Record protobuf definition from that repository.

To clean up after you have generated the dht.pb.go file, you can run:

make clean

Documentation

Index

Constants

This section is empty.

Variables

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.

Functions

This section is empty.

Types

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.
	//
	// Deprecated: Marked as deprecated in msg.proto.
	ClusterLevelRaw int32 `protobuf:"varint,10,opt,name=cluster_level_raw,json=clusterLevelRaw,proto3" json:"cluster_level_raw,omitempty"`
	// 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 *pb.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=closer_peers,json=closerPeers,proto3" json:"closer_peers,omitempty"`
	// Used to return Providers
	// GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
	ProviderPeers []*Message_Peer `protobuf:"bytes,9,rep,name=provider_peers,json=providerPeers,proto3" json:"provider_peers,omitempty"`
	// contains filtered or unexported fields
}

Message is the top-level envelope for exchanging information with the DHT protocol.

func (*Message) CloserNodes

func (m *Message) CloserNodes() []kadt.PeerID

func (*Message) CloserPeersAddrInfos

func (m *Message) CloserPeersAddrInfos() []peer.AddrInfo

CloserPeersAddrInfos returns the peer.AddrInfo's of the closer peers in this message.

func (*Message) ContainsCloserPeer

func (m *Message) ContainsCloserPeer(pid peer.ID) bool

ContainsCloserPeer returns true if the provided peer ID is among the list of closer peers contained in this message.

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) ExpectResponse

func (m *Message) ExpectResponse() bool

ExpectResponse returns true if we expect a response from the remote peer if we sent a message with the given type to them. For example, when a peer sends a PUT_VALUE message to another peer, that other peer won't respond with anything.

func (*Message) GetCloserPeers

func (x *Message) GetCloserPeers() []*Message_Peer

func (*Message) GetClusterLevelRaw deprecated

func (x *Message) GetClusterLevelRaw() int32

Deprecated: Marked as deprecated in msg.proto.

func (*Message) GetKey

func (x *Message) GetKey() []byte

func (*Message) GetProviderPeers

func (x *Message) GetProviderPeers() []*Message_Peer

func (*Message) GetRecord

func (x *Message) GetRecord() *pb.Record

func (*Message) GetType

func (x *Message) GetType() Message_MessageType

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) ProviderAddrInfos

func (m *Message) ProviderAddrInfos() []peer.AddrInfo

ProviderAddrInfos returns the peer.AddrInfo's of the provider peers in this message.

func (*Message) Reset

func (x *Message) Reset()

func (*Message) Size

func (m *Message) Size() (n int)

func (*Message) String

func (x *Message) String() string

func (*Message) Target

func (m *Message) Target() kadt.Key

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) Enum

func (Message_ConnectionType) EnumDescriptor deprecated

func (Message_ConnectionType) EnumDescriptor() ([]byte, []int)

Deprecated: Use Message_ConnectionType.Descriptor instead.

func (Message_ConnectionType) Number

func (Message_ConnectionType) String

func (x Message_ConnectionType) String() string

func (Message_ConnectionType) Type

type Message_MessageType

type Message_MessageType int32

MessageType represents the type of RPC being called. Based on the message type different fields of this message will be populated. The response of a message with a certain type will have the same type.

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) Enum

func (Message_MessageType) EnumDescriptor deprecated

func (Message_MessageType) EnumDescriptor() ([]byte, []int)

Deprecated: Use Message_MessageType.Descriptor instead.

func (Message_MessageType) Number

func (Message_MessageType) String

func (x Message_MessageType) String() string

func (Message_MessageType) Type

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 FromAddrInfo

func FromAddrInfo(p peer.AddrInfo) *Message_Peer

FromAddrInfo constructs a Message_Peer from the given peer.AddrInfo.

func (*Message_Peer) Addresses

func (m *Message_Peer) Addresses() []ma.Multiaddr

Addresses returns the Multiaddresses associated with the Message_Peer entry

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) Size

func (m *Message_Peer) Size() (n int)

func (*Message_Peer) String

func (x *Message_Peer) String() string

Jump to

Keyboard shortcuts

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