Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddPeer ¶
type AddPeer struct {
Peer
}
AddPeer is a packet that adds a new peer to a node. Use an array instead of a slice to use it has map hashed key.
type ChangeState ¶
ChangeState is a packet that change global P2P state.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection is a TCP connection to another peer.
func (*Connection) Close ¶
func (conn *Connection) Close() error
Close closes this connection. Implements the io.Closer interface.
func (*Connection) Connect ¶
func (conn *Connection) Connect(destination string) error
Connect connects to a remote peer specified in the destination argument.
func (*Connection) Receive ¶
func (conn *Connection) Receive(length int) ([]byte, error)
Receive returns a byte slice with its length specified as argument, filled with bytes read from this connection.
func (*Connection) Send ¶
func (conn *Connection) Send(data []byte) error
Send sends a byte slice to the other peer in this connection. Length of the data sent is the length of the data slice.
type Counter ¶
type Counter int32
Counter is the number of connected peers.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is current running peer in the network. It has a listener on a specific port and contains connections with other peers.
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer is another peer in the P2P network.
func (Peer) GetAddress ¶
GetAddress returns the string representation of IP address of current Peer.
func (Peer) GetAddressAndPort ¶
GetAddressAndPort returns the string representation of IP address and port of current Peer.
func (*Peer) SetAddress ¶
SetAddress parses an address and save it to current Peer.
type Peers ¶
type Peers struct {
// contains filtered or unexported fields
}
Peers is a map that contains all connected peers.
func (*Peers) Add ¶
func (p *Peers) Add(key Peer, value *Connection)
Add adds a peer to the peers map.
type SimplyGui ¶
type SimplyGui struct {
// contains filtered or unexported fields
}
SimplyGui is a simple graphic interface that show the current state and some buttons to change its value.