Documentation ¶
Index ¶
- Constants
- type DataExchange
- type Datagram
- type HaveMsg
- type Msg
- func (m *Msg) HandleDataExchange(pStorage storage.LocalStorage) error
- func (m *Msg) HandleHave(pid PeerID, lStorage storage.LocalStorage, pStorage storage.PeerStorage) (*Datagram, error)
- func (m *Msg) HandleRequest(pStorage storage.LocalStorage) (*Datagram, error)
- func (m *Msg) MarshalJSON() ([]byte, error)
- func (m *Msg) UnmarshalJSON(b []byte) error
- type MsgData
- type MsgError
- type Opcode
- type PeerID
- type Protocol
- type RequestChunks
Constants ¶
View Source
const ( HaveRequest = iota HaveResponse )
View Source
const ( FileTransferProtocol = "/p2p/files/0.0.0" HandshakeProtocol = "/p2p/handshake/0.0.0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Datagram ¶
type Datagram struct {
Msgs []Msg
}
Datagram holds a protocol datagram
func NewDataGram ¶
type Msg ¶
Msg holds a protocol message
func (*Msg) HandleDataExchange ¶
func (m *Msg) HandleDataExchange(pStorage storage.LocalStorage) error
func (*Msg) HandleHave ¶
func (m *Msg) HandleHave(pid PeerID, lStorage storage.LocalStorage, pStorage storage.PeerStorage) (*Datagram, error)
func (*Msg) HandleRequest ¶
func (m *Msg) HandleRequest(pStorage storage.LocalStorage) (*Datagram, error)
func (*Msg) MarshalJSON ¶
Encode handles the serializing of a message.
See note above Decode for the reason for the custom Encode
func (*Msg) UnmarshalJSON ¶
Decode handles the deserializing of a message.
We can't get away with off-the-shelf JSON, because we're using an interface type for MsgData, which causes problems on the decode side.
type MsgError ¶
type MsgError struct {
// contains filtered or unexported fields
}
MsgError is an error that happens while handling an incoming message
type PeerID ¶
type PeerID interface {
String() string
}
PeerID identifies a peer To avoid cycle Import
type RequestChunks ¶
RequestChunks holds a have message storage payload
func (RequestChunks) String ¶
func (c RequestChunks) String() string
Click to show internal directories.
Click to hide internal directories.