Documentation
¶
Index ¶
- Constants
- type AddressExchangeRequest
- type AddressExchangeResponse
- type FileRequest
- type FileResponse
- type Message
- type Node
- func (n *Node) Connect(addr multiaddr.Multiaddr) error
- func (n *Node) DHT() *dht.IpfsDHT
- func (n *Node) FindFileProviders(ctx context.Context, hash string) ([]peer.ID, error)
- func (n *Node) Host() host.Host
- func (n *Node) PublishFileInfo(ctx context.Context, hash string) error
- func (n *Node) RequestFile(ctx context.Context, p peer.ID, hash string) (io.ReadCloser, error)
- func (n *Node) SetupAddressExchangeProtocol()
- func (n *Node) SetupProtocol()
- func (n *Node) Start() error
- func (n *Node) Stop() error
Constants ¶
View Source
const ( ProtocolID = "/p2p-file-sharing/1.0.0" FileRequestType = "file-request" FileResponseType = "file-response" ChunkSize = 1024 * 1024 // 1MB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressExchangeRequest ¶
type AddressExchangeRequest struct {
PeerID string `json:"peer_id"`
}
AddressExchangeRequest представляет запрос на обмен адресами
type AddressExchangeResponse ¶
type AddressExchangeResponse struct {
Status string `json:"status"`
Addresses []string `json:"addresses"`
}
AddressExchangeResponse представляет ответ на запрос обмена адресами
type FileRequest ¶
type FileRequest struct {
Hash string `json:"hash"`
}
type FileResponse ¶
type Message ¶
type Message struct {
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node представляет P2P узел в сети
func (*Node) FindFileProviders ¶
FindFileProviders ищет пиров, у которых есть файл
func (*Node) PublishFileInfo ¶
PublishFileInfo публикует информацию о файле в DHT
func (*Node) RequestFile ¶
RequestFile запрашивает файл у пира
func (*Node) SetupAddressExchangeProtocol ¶
func (n *Node) SetupAddressExchangeProtocol()
SetupAddressExchangeProtocol настраивает протокол обмена файлами
func (*Node) SetupProtocol ¶
func (n *Node) SetupProtocol()
SetupProtocol настраивает протокол обмена файлами
Click to show internal directories.
Click to hide internal directories.