Documentation ¶
Overview ¶
Package dht is a generated protocol buffer package.
It is generated from these files:
proto.proto
It has these top-level messages:
PacketContact PacketHeader Packet PartHeader Found FoundNodes Store Broadcast Custom CustomAnswer RepeatPlease
Index ¶
- Constants
- Variables
- type Broadcast
- type Callback
- type CallbackChan
- type Command
- type Custom
- type CustomAnswer
- type Dht
- func (this *Dht) Broadcast(data interface{})
- func (this *Dht) Cli()
- func (this *Dht) CustomCmd(data interface{})
- func (this *Dht) Fetch(hash Hash) ([]byte, error)
- func (this *Dht) GetConnectedNumber() int
- func (this *Dht) Logger() *logging.Logger
- func (this *Dht) PrintLocalStore()
- func (this *Dht) PrintRoutingTable()
- func (this *Dht) Running() bool
- func (this *Dht) Start() error
- func (this *Dht) Stop()
- func (this *Dht) StorageSize() int
- func (this *Dht) Store(value []byte) (Hash, int, error)
- func (this *Dht) StoreAt(hash Hash, value []byte) (Hash, int, error)
- func (this *Dht) StoredKeys() int
- func (this *Dht) Wait()
- type DhtOptions
- type Found
- type FoundNodes
- type Hash
- type Node
- func (this *Node) Broadcast(packet Packet) chan interface{}
- func (this *Node) Custom(value interface{}) chan interface{}
- func (this *Node) Fetch(hash []byte) chan interface{}
- func (this *Node) FetchNodes(hash []byte) chan interface{}
- func (this *Node) Found(packet Packet, hash Hash, value []byte)
- func (this *Node) FoundNodes(packet Packet, nodesContact []*PacketContact)
- func (this *Node) HandleInPacket(packet Packet)
- func (this *Node) OnBroadcast(packet Packet)
- func (this *Node) OnCustom(packet Packet)
- func (this *Node) OnCustomAnswer(packet Packet, done CallbackChan)
- func (this *Node) OnFetch(packet Packet)
- func (this *Node) OnFetchNodes(packet Packet)
- func (this *Node) OnFound(packet Packet, done CallbackChan)
- func (this *Node) OnFoundNodes(packet Packet, done CallbackChan)
- func (this *Node) OnPing(packet Packet)
- func (this *Node) OnPong(packet Packet, cb CallbackChan)
- func (this *Node) OnRepeatPlease(packet Packet)
- func (this *Node) OnStore(packet Packet)
- func (this *Node) OnStored(packet Packet, done CallbackChan)
- func (this *Node) Ping() chan interface{}
- func (this *Node) Pong(responseTo []byte) chan interface{}
- func (this *Node) Redacted() interface{}
- func (this *Node) RepeatPlease(hash []byte, value []int32) chan interface{}
- func (this *Node) Store(hash Hash, value []byte) chan interface{}
- func (this *Node) Stored(packet Packet, hasStored bool)
- type Packet
- func (*Packet) Descriptor() ([]byte, []int)
- func (m *Packet) GetBroadcast() *Broadcast
- func (m *Packet) GetCustom() *Custom
- func (m *Packet) GetCustomAnswer() *CustomAnswer
- func (m *Packet) GetData() isPacket_Data
- func (m *Packet) GetFound() *Found
- func (m *Packet) GetFoundNodes() *FoundNodes
- func (m *Packet) GetHash() []byte
- func (m *Packet) GetHeader() *PacketHeader
- func (m *Packet) GetOk() bool
- func (m *Packet) GetRepeatPlease() *RepeatPlease
- func (m *Packet) GetStore() *Store
- func (*Packet) ProtoMessage()
- func (m *Packet) Reset()
- func (m *Packet) String() string
- func (*Packet) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type PacketContact
- type PacketHeader
- func (*PacketHeader) Descriptor() ([]byte, []int)
- func (m *PacketHeader) GetCommand() Command
- func (m *PacketHeader) GetDateSent() int64
- func (m *PacketHeader) GetMessageHash() []byte
- func (m *PacketHeader) GetNonce() int64
- func (m *PacketHeader) GetResponseTo() []byte
- func (m *PacketHeader) GetSender() *PacketContact
- func (*PacketHeader) ProtoMessage()
- func (m *PacketHeader) Reset()
- func (m *PacketHeader) String() string
- type Packet_Broadcast
- type Packet_Custom
- type Packet_CustomAnswer
- type Packet_Found
- type Packet_FoundNodes
- type Packet_Hash
- type Packet_Ok
- type Packet_RepeatPlease
- type Packet_Store
- type PartHeader
- type Query
- type QueryJob
- type RepeatCmd
- type RepeatPlease
- type Routing
- func (this *Routing) AddNode(contact PacketContact)
- func (this *Routing) FindNode(hash []byte) []PacketContact
- func (this *Routing) GetAllNodes() []PacketContact
- func (this *Routing) GetByAddr(addr string) (PacketContact, error)
- func (this *Routing) GetNode(hash []byte) (PacketContact, error)
- func (this *Routing) IsBestStorage(hash []byte) (bool, []PacketContact)
- func (this *Routing) Print()
- func (this *Routing) RemoveNode(contact PacketContact)
- func (this *Routing) Size() int
- type Store
- type StoreInst
- type WaitingPartMsg
- type WorkerJob
- type WorkerQueue
- type WorkerResult
Constants ¶
View Source
const ( HASH_SIZE = 128 BUCKET_SIZE = HASH_SIZE / 8 )
View Source
const BUFFER_SIZE = 1024 * 4
Variables ¶
View Source
var Command_name = map[int32]string{
0: "NOOP",
1: "PING",
2: "PONG",
3: "STORE",
4: "STORED",
5: "FETCH",
6: "FETCH_NODES",
7: "FOUND",
8: "FOUND_NODES",
9: "BROADCAST",
10: "CUSTOM",
11: "CUSTOM_ANSWER",
12: "REPEAT_PLEASE",
}
View Source
var Command_value = map[string]int32{
"NOOP": 0,
"PING": 1,
"PONG": 2,
"STORE": 3,
"STORED": 4,
"FETCH": 5,
"FETCH_NODES": 6,
"FOUND": 7,
"FOUND_NODES": 8,
"BROADCAST": 9,
"CUSTOM": 10,
"CUSTOM_ANSWER": 11,
"REPEAT_PLEASE": 12,
}
Functions ¶
This section is empty.
Types ¶
type Broadcast ¶
type Broadcast struct {
Data []byte `protobuf:"bytes,2,opt,name=Data,json=data,proto3" json:"Data,omitempty"`
}
func (*Broadcast) Descriptor ¶
func (*Broadcast) ProtoMessage ¶
func (*Broadcast) ProtoMessage()
type CallbackChan ¶
type CallbackChan struct {
// contains filtered or unexported fields
}
type Command ¶
type Command int32
const ( Command_NOOP Command = 0 Command_PING Command = 1 Command_PONG Command = 2 Command_STORE Command = 3 Command_STORED Command = 4 Command_FETCH Command = 5 Command_FETCH_NODES Command = 6 Command_FOUND Command = 7 Command_FOUND_NODES Command = 8 Command_BROADCAST Command = 9 Command_CUSTOM Command = 10 Command_CUSTOM_ANSWER Command = 11 Command_REPEAT_PLEASE Command = 12 )
func (Command) EnumDescriptor ¶
type Custom ¶
type Custom struct { Command Command `protobuf:"varint,1,opt,name=Command,json=command,enum=dht.Command" json:"Command,omitempty"` Data []byte `protobuf:"bytes,2,opt,name=Data,json=data,proto3" json:"Data,omitempty"` }
func (*Custom) Descriptor ¶
func (*Custom) GetCommand ¶
func (*Custom) ProtoMessage ¶
func (*Custom) ProtoMessage()
type CustomAnswer ¶
type CustomAnswer struct {
Data []byte `protobuf:"bytes,2,opt,name=Data,json=data,proto3" json:"Data,omitempty"`
}
func (*CustomAnswer) Descriptor ¶
func (*CustomAnswer) Descriptor() ([]byte, []int)
func (*CustomAnswer) GetData ¶
func (m *CustomAnswer) GetData() []byte
func (*CustomAnswer) ProtoMessage ¶
func (*CustomAnswer) ProtoMessage()
func (*CustomAnswer) Reset ¶
func (m *CustomAnswer) Reset()
func (*CustomAnswer) String ¶
func (m *CustomAnswer) String() string
type Dht ¶
func New ¶
func New(options DhtOptions) *Dht
func (*Dht) GetConnectedNumber ¶
func (*Dht) PrintLocalStore ¶
func (this *Dht) PrintLocalStore()
func (*Dht) PrintRoutingTable ¶
func (this *Dht) PrintRoutingTable()
func (*Dht) StorageSize ¶
func (*Dht) StoredKeys ¶
type DhtOptions ¶
type Found ¶
type Found struct {
Header *PartHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
}
func (*Found) Descriptor ¶
func (*Found) GetHeader ¶
func (m *Found) GetHeader() *PartHeader
func (*Found) ProtoMessage ¶
func (*Found) ProtoMessage()
type FoundNodes ¶
type FoundNodes struct {
Nodes []*PacketContact `protobuf:"bytes,1,rep,name=Nodes,json=nodes" json:"Nodes,omitempty"`
}
func (*FoundNodes) Descriptor ¶
func (*FoundNodes) Descriptor() ([]byte, []int)
func (*FoundNodes) GetNodes ¶
func (m *FoundNodes) GetNodes() []*PacketContact
func (*FoundNodes) ProtoMessage ¶
func (*FoundNodes) ProtoMessage()
func (*FoundNodes) Reset ¶
func (m *FoundNodes) Reset()
func (*FoundNodes) String ¶
func (m *FoundNodes) String() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func NewNodeContact ¶
func NewNodeContact(dht *Dht, addr net.Addr, contact PacketContact) *Node
func (*Node) FetchNodes ¶
func (*Node) FoundNodes ¶
func (this *Node) FoundNodes(packet Packet, nodesContact []*PacketContact)
func (*Node) HandleInPacket ¶
func (*Node) OnBroadcast ¶
func (*Node) OnCustomAnswer ¶
func (this *Node) OnCustomAnswer(packet Packet, done CallbackChan)
func (*Node) OnFetchNodes ¶
func (*Node) OnFound ¶
func (this *Node) OnFound(packet Packet, done CallbackChan)
func (*Node) OnFoundNodes ¶
func (this *Node) OnFoundNodes(packet Packet, done CallbackChan)
func (*Node) OnPong ¶
func (this *Node) OnPong(packet Packet, cb CallbackChan)
func (*Node) OnRepeatPlease ¶
func (*Node) OnStored ¶
func (this *Node) OnStored(packet Packet, done CallbackChan)
func (*Node) RepeatPlease ¶
type Packet ¶
type Packet struct { Header *PacketHeader `protobuf:"bytes,1,opt,name=Header,json=header" json:"Header,omitempty"` // Types that are valid to be assigned to Data: // *Packet_Hash // *Packet_Ok // *Packet_FoundNodes // *Packet_Found // *Packet_Store // *Packet_Custom // *Packet_CustomAnswer // *Packet_RepeatPlease // *Packet_Broadcast Data isPacket_Data `protobuf_oneof:"Data"` }
func (*Packet) Descriptor ¶
func (*Packet) GetBroadcast ¶
func (*Packet) GetCustomAnswer ¶
func (m *Packet) GetCustomAnswer() *CustomAnswer
func (*Packet) GetFoundNodes ¶
func (m *Packet) GetFoundNodes() *FoundNodes
func (*Packet) GetHeader ¶
func (m *Packet) GetHeader() *PacketHeader
func (*Packet) GetRepeatPlease ¶
func (m *Packet) GetRepeatPlease() *RepeatPlease
func (*Packet) ProtoMessage ¶
func (*Packet) ProtoMessage()
type PacketContact ¶
type PacketContact struct { Hash []byte `protobuf:"bytes,1,opt,name=Hash,json=hash,proto3" json:"Hash,omitempty"` Addr string `protobuf:"bytes,2,opt,name=addr" json:"addr,omitempty"` }
func (*PacketContact) Descriptor ¶
func (*PacketContact) Descriptor() ([]byte, []int)
func (*PacketContact) GetAddr ¶
func (m *PacketContact) GetAddr() string
func (*PacketContact) GetHash ¶
func (m *PacketContact) GetHash() []byte
func (*PacketContact) ProtoMessage ¶
func (*PacketContact) ProtoMessage()
func (*PacketContact) Reset ¶
func (m *PacketContact) Reset()
func (*PacketContact) String ¶
func (m *PacketContact) String() string
type PacketHeader ¶
type PacketHeader struct { DateSent int64 `protobuf:"varint,1,opt,name=DateSent,json=dateSent" json:"DateSent,omitempty"` Command Command `protobuf:"varint,2,opt,name=Command,json=command,enum=dht.Command" json:"Command,omitempty"` Sender *PacketContact `protobuf:"bytes,3,opt,name=Sender,json=sender" json:"Sender,omitempty"` MessageHash []byte `protobuf:"bytes,4,opt,name=MessageHash,json=messageHash,proto3" json:"MessageHash,omitempty"` ResponseTo []byte `protobuf:"bytes,5,opt,name=ResponseTo,json=responseTo,proto3" json:"ResponseTo,omitempty"` Nonce int64 `protobuf:"varint,6,opt,name=Nonce,json=nonce" json:"Nonce,omitempty"` }
func (*PacketHeader) Descriptor ¶
func (*PacketHeader) Descriptor() ([]byte, []int)
func (*PacketHeader) GetCommand ¶
func (m *PacketHeader) GetCommand() Command
func (*PacketHeader) GetDateSent ¶
func (m *PacketHeader) GetDateSent() int64
func (*PacketHeader) GetMessageHash ¶
func (m *PacketHeader) GetMessageHash() []byte
func (*PacketHeader) GetNonce ¶
func (m *PacketHeader) GetNonce() int64
func (*PacketHeader) GetResponseTo ¶
func (m *PacketHeader) GetResponseTo() []byte
func (*PacketHeader) GetSender ¶
func (m *PacketHeader) GetSender() *PacketContact
func (*PacketHeader) ProtoMessage ¶
func (*PacketHeader) ProtoMessage()
func (*PacketHeader) Reset ¶
func (m *PacketHeader) Reset()
func (*PacketHeader) String ¶
func (m *PacketHeader) String() string
type Packet_Broadcast ¶
type Packet_Broadcast struct {
Broadcast *Broadcast `protobuf:"bytes,13,opt,name=broadcast,oneof"`
}
type Packet_Custom ¶
type Packet_Custom struct {
Custom *Custom `protobuf:"bytes,10,opt,name=custom,oneof"`
}
type Packet_CustomAnswer ¶
type Packet_CustomAnswer struct {
CustomAnswer *CustomAnswer `protobuf:"bytes,11,opt,name=customAnswer,oneof"`
}
type Packet_Found ¶
type Packet_Found struct {
Found *Found `protobuf:"bytes,7,opt,name=found,oneof"`
}
type Packet_FoundNodes ¶
type Packet_FoundNodes struct {
FoundNodes *FoundNodes `protobuf:"bytes,6,opt,name=foundNodes,oneof"`
}
type Packet_Hash ¶
type Packet_Hash struct {
Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3,oneof"`
}
type Packet_RepeatPlease ¶
type Packet_RepeatPlease struct {
RepeatPlease *RepeatPlease `protobuf:"bytes,12,opt,name=repeatPlease,oneof"`
}
type Packet_Store ¶
type Packet_Store struct {
Store *Store `protobuf:"bytes,8,opt,name=store,oneof"`
}
type PartHeader ¶
type PartHeader struct { Id int32 `protobuf:"varint,1,opt,name=Id,json=id" json:"Id,omitempty"` Total int32 `protobuf:"varint,2,opt,name=Total,json=total" json:"Total,omitempty"` Hash []byte `protobuf:"bytes,3,opt,name=Hash,json=hash,proto3" json:"Hash,omitempty"` Data []byte `protobuf:"bytes,4,opt,name=Data,json=data,proto3" json:"Data,omitempty"` }
func (*PartHeader) Descriptor ¶
func (*PartHeader) Descriptor() ([]byte, []int)
func (*PartHeader) GetData ¶
func (m *PartHeader) GetData() []byte
func (*PartHeader) GetHash ¶
func (m *PartHeader) GetHash() []byte
func (*PartHeader) GetId ¶
func (m *PartHeader) GetId() int32
func (*PartHeader) GetTotal ¶
func (m *PartHeader) GetTotal() int32
func (*PartHeader) ProtoMessage ¶
func (*PartHeader) ProtoMessage()
func (*PartHeader) Reset ¶
func (m *PartHeader) Reset()
func (*PartHeader) String ¶
func (m *PartHeader) String() string
type Query ¶
func (*Query) WaitResult ¶
func (this *Query) WaitResult() interface{}
type RepeatPlease ¶
type RepeatPlease struct { Hash []byte `protobuf:"bytes,1,opt,name=Hash,json=hash,proto3" json:"Hash,omitempty"` Data []int32 `protobuf:"varint,2,rep,packed,name=Data,json=data" json:"Data,omitempty"` }
func (*RepeatPlease) Descriptor ¶
func (*RepeatPlease) Descriptor() ([]byte, []int)
func (*RepeatPlease) GetData ¶
func (m *RepeatPlease) GetData() []int32
func (*RepeatPlease) GetHash ¶
func (m *RepeatPlease) GetHash() []byte
func (*RepeatPlease) ProtoMessage ¶
func (*RepeatPlease) ProtoMessage()
func (*RepeatPlease) Reset ¶
func (m *RepeatPlease) Reset()
func (*RepeatPlease) String ¶
func (m *RepeatPlease) String() string
type Routing ¶
func NewRouting ¶
func NewRouting() *Routing
func (*Routing) AddNode ¶
func (this *Routing) AddNode(contact PacketContact)
func (*Routing) FindNode ¶
func (this *Routing) FindNode(hash []byte) []PacketContact
func (*Routing) GetAllNodes ¶
func (this *Routing) GetAllNodes() []PacketContact
func (*Routing) IsBestStorage ¶
func (this *Routing) IsBestStorage(hash []byte) (bool, []PacketContact)
func (*Routing) RemoveNode ¶
func (this *Routing) RemoveNode(contact PacketContact)
type Store ¶
type Store struct {
Header *PartHeader `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
}
func (*Store) Descriptor ¶
func (*Store) GetHeader ¶
func (m *Store) GetHeader() *PartHeader
func (*Store) ProtoMessage ¶
func (*Store) ProtoMessage()
type WaitingPartMsg ¶
type WaitingPartMsg struct {
// contains filtered or unexported fields
}
type WorkerQueue ¶
type WorkerQueue struct { sync.RWMutex Results chan WorkerResult // contains filtered or unexported fields }
func NewWorkerQueue ¶
func NewWorkerQueue(size, buffer int) *WorkerQueue
func (*WorkerQueue) Add ¶
func (this *WorkerQueue) Add(job WorkerJob)
func (*WorkerQueue) IsRunning ¶
func (this *WorkerQueue) IsRunning() bool
func (*WorkerQueue) OnDone ¶
func (this *WorkerQueue) OnDone()
func (*WorkerQueue) Start ¶
func (this *WorkerQueue) Start()
func (*WorkerQueue) Stop ¶
func (this *WorkerQueue) Stop()
func (*WorkerQueue) WaitingCount ¶
func (this *WorkerQueue) WaitingCount() int
type WorkerResult ¶
type WorkerResult interface{}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.