dht_pb

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dht_pb is a generated protocol buffer package.

It is generated from these files:

dht.proto

It has these top-level messages:

Message
Record

Index

Constants

This section is empty.

Variables

View Source
var Message_ConnectionType_name = map[int32]string{
	0: "NOT_CONNECTED",
	1: "CONNECTED",
	2: "CAN_CONNECT",
	3: "CANNOT_CONNECT",
}
View Source
var Message_ConnectionType_value = map[string]int32{
	"NOT_CONNECTED":  0,
	"CONNECTED":      1,
	"CAN_CONNECT":    2,
	"CANNOT_CONNECT": 3,
}
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",
}
View Source
var Message_MessageType_value = map[string]int32{
	"PUT_VALUE":     0,
	"GET_VALUE":     1,
	"ADD_PROVIDER":  2,
	"GET_PROVIDERS": 3,
	"FIND_NODE":     4,
	"PING":          5,
}

Functions

func Connectedness

func Connectedness(c Message_ConnectionType) inet.Connectedness

Connectedness returns an inet.Connectedness associated with the Message_ConnectionType.

func PBPeerToPeerInfo

func PBPeerToPeerInfo(pbp *Message_Peer) peer.PeerInfo

PBPeerToPeer turns a *Message_Peer into its peer.PeerInfo counterpart

func PBPeersToPeerInfos

func PBPeersToPeerInfos(pbps []*Message_Peer) []peer.PeerInfo

PBPeersToPeerInfos converts given []*Message_Peer into []peer.PeerInfo Invalid addresses will be silently omitted.

Types

type Message

type Message struct {
	// defines what type of message it is.
	Type *Message_MessageType `protobuf:"varint,1,opt,name=type,enum=dht.pb.Message_MessageType" json:"type,omitempty"`
	// defines what coral cluster level this query/response belongs to.
	ClusterLevelRaw *int32 `protobuf:"varint,10,opt,name=clusterLevelRaw" json:"clusterLevelRaw,omitempty"`
	// Used to specify the key associated with this message.
	// PUT_VALUE, GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
	Key *string `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"`
	// Used to return a value
	// PUT_VALUE, GET_VALUE
	Record *Record `protobuf:"bytes,3,opt,name=record" 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" json:"closerPeers,omitempty"`
	// Used to return Providers
	// GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
	ProviderPeers    []*Message_Peer `protobuf:"bytes,9,rep,name=providerPeers" json:"providerPeers,omitempty"`
	XXX_unrecognized []byte          `json:"-"`
}

func NewMessage

func NewMessage(typ Message_MessageType, key string, level int) *Message

NewMessage constructs a new dht message with given type, key, and level

func (*Message) GetCloserPeers

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

func (*Message) GetClusterLevel

func (m *Message) GetClusterLevel() int

GetClusterLevel gets and adjusts the cluster level on the message. a +/- 1 adjustment is needed to distinguish a valid first level (1) and default "no value" protobuf behavior (0)

func (*Message) GetClusterLevelRaw

func (m *Message) GetClusterLevelRaw() int32

func (*Message) GetKey

func (m *Message) GetKey() string

func (*Message) GetProviderPeers

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

func (*Message) GetRecord

func (m *Message) GetRecord() *Record

func (*Message) GetType

func (m *Message) GetType() Message_MessageType

func (*Message) Loggable

func (m *Message) Loggable() map[string]interface{}

Loggable turns a Message into machine-readable log output

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) SetClusterLevel

func (m *Message) SetClusterLevel(level int)

SetClusterLevel adjusts and sets the cluster level on the message. a +/- 1 adjustment is needed to distinguish a valid first level (1) and default "no value" protobuf behavior (0)

func (*Message) String

func (m *Message) String() string

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 ConnectionType

func ConnectionType(c inet.Connectedness) Message_ConnectionType

ConnectionType returns a Message_ConnectionType associated with the inet.Connectedness.

func (Message_ConnectionType) Enum

func (Message_ConnectionType) String

func (x Message_ConnectionType) String() string

func (*Message_ConnectionType) UnmarshalJSON

func (x *Message_ConnectionType) UnmarshalJSON(data []byte) error

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

func (Message_MessageType) String

func (x Message_MessageType) String() string

func (*Message_MessageType) UnmarshalJSON

func (x *Message_MessageType) UnmarshalJSON(data []byte) error

type Message_Peer

type Message_Peer struct {
	// ID of a given peer.
	Id *string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
	// multiaddrs for a given peer
	Addrs [][]byte `protobuf:"bytes,2,rep,name=addrs" json:"addrs,omitempty"`
	// used to signal the sender's connection capabilities to the peer
	Connection       *Message_ConnectionType `protobuf:"varint,3,opt,name=connection,enum=dht.pb.Message_ConnectionType" json:"connection,omitempty"`
	XXX_unrecognized []byte                  `json:"-"`
}

func PeerInfosToPBPeers

func PeerInfosToPBPeers(n inet.Network, peers []peer.PeerInfo) []*Message_Peer

PeersToPBPeers converts given []peer.Peer into a set of []*Message_Peer, which can be written to a message and sent out. the key thing this function does (in addition to PeersToPBPeers) is set the ConnectionType with information from the given inet.Network.

func PeerRoutingInfosToPBPeers

func PeerRoutingInfosToPBPeers(peers []PeerRoutingInfo) []*Message_Peer

func RawPeerInfosToPBPeers

func RawPeerInfosToPBPeers(peers []peer.PeerInfo) []*Message_Peer

RawPeerInfosToPBPeers converts a slice of Peers into a slice of *Message_Peers, ready to go out on the wire.

func (*Message_Peer) Addresses

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

Addresses returns a multiaddr associated with the Message_Peer entry

func (*Message_Peer) GetAddrs

func (m *Message_Peer) GetAddrs() [][]byte

func (*Message_Peer) GetConnection

func (m *Message_Peer) GetConnection() Message_ConnectionType

func (*Message_Peer) GetId

func (m *Message_Peer) GetId() string

func (*Message_Peer) ProtoMessage

func (*Message_Peer) ProtoMessage()

func (*Message_Peer) Reset

func (m *Message_Peer) Reset()

func (*Message_Peer) String

func (m *Message_Peer) String() string

type PeerRoutingInfo

type PeerRoutingInfo struct {
	peer.PeerInfo
	inet.Connectedness
}

type Record

type Record struct {
	// The key that references this record
	Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
	// The actual value this record is storing
	Value []byte `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"`
	// hash of the authors public key
	Author *string `protobuf:"bytes,3,opt,name=author" json:"author,omitempty"`
	// A PKI signature for the key+value+author
	Signature []byte `protobuf:"bytes,4,opt,name=signature" json:"signature,omitempty"`
	// Time the record was received, set by receiver
	TimeReceived     *string `protobuf:"bytes,5,opt,name=timeReceived" json:"timeReceived,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

Record represents a dht record that contains a value for a key value pair

func (*Record) GetAuthor

func (m *Record) GetAuthor() string

func (*Record) GetKey

func (m *Record) GetKey() string

func (*Record) GetSignature

func (m *Record) GetSignature() []byte

func (*Record) GetTimeReceived added in v0.3.8

func (m *Record) GetTimeReceived() string

func (*Record) GetValue

func (m *Record) GetValue() []byte

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) Reset

func (m *Record) Reset()

func (*Record) String

func (m *Record) String() string

Jump to

Keyboard shortcuts

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