Documentation
¶
Index ¶
- type ConnectReply
- type ConnectRequest
- type FindPeerReply
- type Peer
- func (p *Peer) AcceptConnect(request *ConnectRequest, reply *ConnectReply) error
- func (p *Peer) ConnectPeer(port string, id int)
- func (p *Peer) ConnectServer()
- func (p *Peer) RegisterFile(fileName string) error
- func (p *Peer) RequestFile(port string, id int, file string)
- func (p *Peer) SearchForFile(fileName string) error
- func (p *Peer) ServeFile(request *RequestFileArgs, reply *RequestFileReply) error
- type PeerInfo
- type PeerSendFile
- type RequestFileArgs
- type RequestFileReply
- type ServerReceiveFile
- type SwarmMaster
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectReply ¶
Reply RPC for Peer's to connect.
type ConnectRequest ¶
Request RPC for Peer's to connect.
type FindPeerReply ¶
Sent by the SwarmMaster to a Peer indicating the details regarding a Peer that possesses a particular file. Used in Peer.SearchForFile() and SwarmMaster.SearchFile().
type Peer ¶
Struct type for the Peers.
func (*Peer) AcceptConnect ¶
func (p *Peer) AcceptConnect(request *ConnectRequest, reply *ConnectReply) error
Handles incoming connection RPCs (ConnectRequest{}) from other Peers.
func (*Peer) ConnectPeer ¶
Connects the Peer to the provided Peer.
func (*Peer) RegisterFile ¶
Registers a file that a Peer has on disk into the FileShare system.
func (*Peer) RequestFile ¶
Requests a given file from a given Peer.
func (*Peer) SearchForFile ¶
Asks the SwarmMaster for a particular file. The SwarmMaster will search the network of Peers and find the Peer with the requested file, and then send the connection details back to the requesting Peer.
func (*Peer) ServeFile ¶
func (p *Peer) ServeFile(request *RequestFileArgs, reply *RequestFileReply) error
Handles file request RPCs (RequestFileArgs{}) from other Peers.
type PeerInfo ¶
type PeerInfo struct { PeerID int Port string Files [10]string // contains filtered or unexported fields }
A lightweight data type for the SwarmMaster and Peers to hold relevant information about the Peers connected to it, including their port and the files they posses.
type PeerSendFile ¶
RPC for a Peer to send a file to the server.
type RequestFileArgs ¶
Sent by the Peer to the SwarmMaster when searching for a file in the network using Peer.SearchForFile().
type RequestFileReply ¶
type RequestFileReply struct { PeerID int FileExists bool ErrorMessage string File string FileContents string }
Used by a peer to send another Peer a file in Peer.RequestFile() and Peer.ServeFile().
type ServerReceiveFile ¶
RPC for the server to confirm it received the file.
type SwarmMaster ¶
type SwarmMaster struct {
// contains filtered or unexported fields
}
SwarmMaster data type for the server.
func (*SwarmMaster) ConnectPeer ¶
func (m *SwarmMaster) ConnectPeer(request *ConnectRequest, reply *ConnectReply) error
RPC handler for when a Peer wishes to connect to the SwarmMaster.
func (*SwarmMaster) MasterTest ¶
func (m *SwarmMaster) MasterTest()
Simple function to let us know when the SwarmMaster has successfully been built.
func (*SwarmMaster) Register ¶
func (m *SwarmMaster) Register(request *PeerSendFile, reply *ServerReceiveFile) error
RPC handler for when a Peer registers a file in the FileShare system to be shareable. This function will update the SwarmMaster's peers data to include the new file.
func (*SwarmMaster) SearchFile ¶
func (m *SwarmMaster) SearchFile(request *RequestFileArgs, reply *FindPeerReply) error
RPC handler for when a Peer is in search of a file. This function will search the registered files in each Peer's file list to find which Peer contains the requested file. Then a FindPeerReply RPC will be sent to the requesting Peer telling it how to contact the Peer with the desired file.