mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-19 20:46:45 +00:00

* [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()
26 lines
630 B
Go
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
|
|
}
|