Documentation ¶
Overview ¶
Package p2p is a generated GoMock package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNewStream = errors.New("[HOST]: new stream error") ErrMsgWrite = errors.New("[HOST]: send message write error") ErrAddProtocols = errors.New("[HOST]: cannot add protocols") )
Error of host package
Functions ¶
This section is empty.
Types ¶
type BackoffBase ¶
BackoffBase is the base implementation of backoff sleeper. It handles the minimum/current/maximum backoff logic. If maximum backoff is 0, there is no maximum.
func NewBackoffBase ¶
func NewBackoffBase(min, max time.Duration) *BackoffBase
NewBackoffBase creates a new BackOffBase structure
func (*BackoffBase) Backoff ¶
func (b *BackoffBase) Backoff()
Backoff adjusts the duration. Subtypes shall implement this.
func (*BackoffBase) Reset ¶
func (b *BackoffBase) Reset()
Reset the current sleep duration to its minimum value.
func (*BackoffBase) Sleep ¶
func (b *BackoffBase) Sleep()
Sleep for the current duration, then adjust the duration.
type ExpBackoff ¶
type ExpBackoff struct { BackoffBase Factor float64 }
ExpBackoff is an exponential backoff data structure.
func NewExpBackoff ¶
func NewExpBackoff(min, max time.Duration, factor float64) *ExpBackoff
NewExpBackoff creates a new ExpBackOff structure
func (*ExpBackoff) Backoff ¶
func (b *ExpBackoff) Backoff()
Backoff implements the exponential backoff
type GroupReceiver ¶
type GroupReceiver interface { // Close closes this receiver. io.Closer // Receive a message. Receive(ctx context.Context) (msg []byte, sender libp2p_peer.ID, err error) }
GroupReceiver is a multicast group message receiver interface.
type Host ¶
type Host interface { GetSelfPeer() Peer Close() error AddPeer(*Peer) error GetID() libp2p_peer.ID GetP2PHost() libp2p_host.Host GetPeerCount() int //AddIncomingPeer(Peer) //AddOutgoingPeer(Peer) ConnectHostPeer(Peer) // SendMessageToGroups sends a message to one or more multicast groups. SendMessageToGroups(groups []nodeconfig.GroupID, msg []byte) error // GroupReceiver returns a receiver of messages sent to a multicast group. // Each call creates a new receiver. // If multiple receivers are created for the same group, // a message sent to the group will be delivered to all of the receivers. GroupReceiver(nodeconfig.GroupID) (receiver GroupReceiver, err error) }
Host is the client + server in p2p network.
type MockStream ¶
type MockStream struct {
// contains filtered or unexported fields
}
MockStream is a mock of Stream interface
func NewMockStream ¶
func NewMockStream(ctrl *gomock.Controller) *MockStream
NewMockStream creates a new mock instance
func (*MockStream) EXPECT ¶
func (m *MockStream) EXPECT() *MockStreamMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockStream) Read ¶
func (m *MockStream) Read(arg0 []byte) (int, error)
Read mocks base method
func (*MockStream) SetReadDeadline ¶
func (m *MockStream) SetReadDeadline(arg0 time.Time) error
SetReadDeadline mocks base method
type MockStreamMockRecorder ¶
type MockStreamMockRecorder struct {
// contains filtered or unexported fields
}
MockStreamMockRecorder is the mock recorder for MockStream
func (*MockStreamMockRecorder) Close ¶
func (mr *MockStreamMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close
func (*MockStreamMockRecorder) Read ¶
func (mr *MockStreamMockRecorder) Read(arg0 interface{}) *gomock.Call
Read indicates an expected call of Read
func (*MockStreamMockRecorder) SetReadDeadline ¶
func (mr *MockStreamMockRecorder) SetReadDeadline(arg0 interface{}) *gomock.Call
SetReadDeadline indicates an expected call of SetReadDeadline
func (*MockStreamMockRecorder) Write ¶
func (mr *MockStreamMockRecorder) Write(arg0 interface{}) *gomock.Call
Write indicates an expected call of Write
type Peer ¶
type Peer struct { IP string // IP address of the peer Port string // Port number of the peer ConsensusPubKey *bls.PublicKey // Public key of the peer, used for consensus signing Addrs []ma.Multiaddr // MultiAddress of the peer PeerID libp2p_peer.ID // PeerID, the pubkey for communication }
Peer is the object for a p2p peer (node)