Documentation ¶
Index ¶
- type Peer
- func (p *Peer) Connect() error
- func (p *Peer) Disconnect()
- func (p *Peer) GetBloomFilter()
- func (p *Peer) GetPeerList(responseChannel chan string)
- func (p *Peer) SendCommand(Command string) (int, error)
- func (p *Peer) SendRequest(Command string, responseChannel chan string, ...)
- func (p *Peer) TestConnection()
- type PeerList
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Peer ¶
type Peer struct { Status State Conn *net.Conn IPPort string BloomFilter bloomfilter.BloomFilter MessageBus *message_handler.MessageHandler UniqueID string sync.Mutex // contains filtered or unexported fields }
Peer Houses the state for remote Peers
func NewPeer ¶
func NewPeer(conn *net.Conn, mh *message_handler.MessageHandler, config *config.Cfg) *Peer
NewPeer handles creating a new peer to be used in communicating between nodes
func NewPeerByIP ¶
func NewPeerByIP(ipPort string, mh *message_handler.MessageHandler, config config.Cfg) *Peer
NewPeerByIP handles creating a peer by its ip, opening a connection, &c.
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect()
Disconnect closes a connection to a remote peer.
func (*Peer) GetBloomFilter ¶
func (p *Peer) GetBloomFilter()
GetBloomFilter handles retrieving a remote node's bloom filter.
func (*Peer) GetPeerList ¶
GetPeerListAsync handles retrieving all known peers from a remote node.
func (*Peer) SendCommand ¶
SendCommand Handles sending a command to a remote node. Command is like this "hash:Command"
func (*Peer) SendRequest ¶
func (p *Peer) SendRequest(Command string, responseChannel chan string, mh *message_handler.MessageHandler)
SendRequest handles taking in a peer object and a command and sending a command which will be responded to the calling channel once the request has been fulfilled
func (*Peer) TestConnection ¶
func (p *Peer) TestConnection()
Ping handles intelligently sending heartbeats to a remote node. After 10 successive failures to ping, the remote node is considered failed and the status is set to Timeout
type PeerList ¶
type PeerList struct { Peers []*Peer BackupPeers []*Peer PeerMap *map[string]bool MessageBus *message_handler.MessageHandler sync.Mutex // contains filtered or unexported fields }
PeerList is a data structure which represents remote Olivia nodes.
func NewPeerList ¶
func NewPeerList(mh *message_handler.MessageHandler, config config.Cfg) *PeerList
NewPeerList Creates a new peer list
func (*PeerList) AddPeer ¶
AddPeer handles intelligently putting a peer into our peer list. Priority of insertion is towards Peers first and then BackupPeers.
func (*PeerList) ConnectAllPeers ¶
ConnectAllPeers connects all peers (or at least attempts to)
func (*PeerList) DisconnectAllPeers ¶
func (p *PeerList) DisconnectAllPeers()
DisconnectAllPeers disconnects all peers
type State ¶
type State int
State represents the state that the remote peer is in.
const ( // Disconnected signifies that the remote node is not yet connected. Disconnected State = iota // Connected signifies that there is a working connection between the // remote peer and our current node. Connected // Timeout signifies that the remote node has timed out and a // connection couldn't be established. Timeout )