Svarog 8e624e057e
[NOD-1134] Integrate Protocol into main (#788)
* [NOD-1134] Integrate Protocol into main

* [NOD-1134] Fix typo

* [NOD-1134] Added comments

* [NOD-1134] A series of renames to protocol

* [NOD-1134] Fix comment

* [NOD-1134] protocol.ProtocolManager -> Manager

* [NOD-1134] Update comment

* [NOD-1134] protocol.New() -> protocol.NewManager()
2020-07-08 11:52:53 +03:00

26 lines
630 B
Go

package server
import (
"github.com/kaspanet/kaspad/wire"
)
// PeerConnectedHandler is a function that is to be called
// once a new Connection is successfully established.
type PeerConnectedHandler func(connection Connection)
// Server represents a p2p server.
type Server interface {
SetPeerConnectedHandler(peerConnectedHandler PeerConnectedHandler)
Connect(address string) (Connection, error)
Connections() []Connection
Start() error
Stop() error
}
// Connection represents a p2p server connection.
type Connection interface {
Send(message wire.Message) error
Receive() (wire.Message, error)
Disconnect() error
}