Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Name node's name Name string //`toml:"-"` // ECDSAKey dumped string of Node's ecdsa.PrivateKey ECDSAKey string // PrivateKey Node's ecdsa.PrivateKey PrivateKey *ecdsa.PrivateKey // MyNodeID public key extracted from PrivateKey, so need not load from config MyNodeID string `toml:"-"` // MaxPeers max number of peers that can be connected MaxPeers int // MaxPendingPeers is the maximum number of peers that can be pending in the // handshake phase, counted separately for inbound and outbound connections. // Zero defaults to preset values. MaxPendingPeers int `toml:",omitempty"` // pre-configured nodes. StaticNodes []*discovery.Node // KadPort udp port for Kad network KadPort string // Protocols should contain the protocols supported by the server. Protocols []ProtocolInterface `toml:"-"` // p2p.server will listen for incoming tcp connections. ListenAddr string }
Config holds Server options.
type Message ¶
type Message struct { MsgCode uint16 // message code, defined in each protocol Payload []byte ReceivedAt time.Time CurPeer *Peer // peer that handle this message }
Message exposed for high level layer to receive
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
Peer represents a connected remote node.
func (*Peer) Disconnect ¶
Disconnect terminates the peer connection with the given reason. It returns immediately and does not wait until the connection is closed.
type ProtoHandShake ¶
ProtoHandShake handshake message for two peer to exchage base information TODO add public key or other information for encryption?
type Protocol ¶
type Protocol struct { // Name should contain the official protocol name, // often a three-letter word. Name string // Version should contain the version number of the protocol. Version uint // AddPeerCh a peer joins protocol, SubProtocol should handle the channel AddPeerCh chan *Peer // DelPeerCh a peer leaves protocol DelPeerCh chan *Peer // ReadMsgCh a whole Message has recved, SubProtocol can handle as quickly as possible ReadMsgCh chan *Message // IsSelfConnect if value is true, means SubProtocol maintains peers itself, for example when to initiate a tcp connection. // Otherwise, all SubProtols share one tcp connection which is initiated by p2p.scheduleTasks IsSelfConnect bool }
Protocol base class for high level transfer protocol.
type ProtocolInterface ¶
type ProtocolInterface interface { Run() GetBaseProtocol() *Protocol }
ProtocolInterface high level protocol should implement this interface
Directories ¶
Path | Synopsis |
---|---|
* * @file * @copyright defined in go-seele/LICENSE
|
* * @file * @copyright defined in go-seele/LICENSE |
Click to show internal directories.
Click to hide internal directories.