/
peer.go
20 lines (18 loc) · 1.1 KB
/
peer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package interfaces
// The Peer interface allows Factom to connect to any implementation of a p2p network.
// The simulator uses an implementation of IPeer to simulate various networks
type IPeer interface {
Init(nameTo, nameFrom string) IPeer // Name of peer
GetNameTo() string // Return the name of the peer
GetNameFrom() string // Return the name of the peer
Send(IMsg) error // Send a message to this peer
Receive() (IMsg, error) // Receive a message from this peer; nil if no message is ready.
Len() int // Returns the number of messages waiting to be read
Equals(IPeer) bool // Is this connection equal to parm connection
Weight() int // How many nodes does this peer represent?
BytesOut() int // Bytes sent out per second from this peer
BytesIn() int // Bytes received per second from this peer
}