Documentation ¶
Index ¶
- Constants
- type BasicPeerInfo
- type BcastMsgPacket
- type Head
- type NewconnCb
- type P2PServer
- func (s *P2PServer) AddPeer(peer *Peer) error
- func (s *P2PServer) DelPeer(index uint16) bool
- func (s *P2PServer) GetPeer(index uint16) *PeerInfo
- func (s *P2PServer) GetPeerP2PInfo() []Peer
- func (s *P2PServer) GetPeers() []PeerInfo
- func (s *P2PServer) GetPeersData() PeerDataSet
- func (s *P2PServer) IsPeerExist(index uint16) bool
- func (s *P2PServer) IsPeerInfoExist(info PeerInfo) bool
- func (s *P2PServer) SendBroadcast(packet BcastMsgPacket)
- func (s *P2PServer) SendUnicast(packet UniMsgPacket)
- func (s *P2PServer) SetCallback(conn NewconnCb)
- func (s *P2PServer) Start()
- type Packet
- type Peer
- type PeerData
- type PeerDataSet
- type PeerInfo
- type SendupCb
- type UniMsgPacket
Constants ¶
const ( PEER_STATE_INIT = 1 PEER_STATE_HANDSHAKE = 2 )
DO NOT EDIT
const (
MAX_PACKET_LEN = 10000000
)
DO NOT EDIT
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicPeerInfo ¶
type BasicPeerInfo struct {
ChainId string
}
BasicPeerInfo define struct for PeerInfo signature
var BasicLocalPeerInfo BasicPeerInfo
BasicLocalPeerInfo
type BcastMsgPacket ¶
BcastMsgPacket it is a multicast packet , Indexs is filter peers index which not send to
type P2PServer ¶
type P2PServer struct {
// contains filtered or unexported fields
}
P2PServer p2p server
var Runner *P2PServer
Runner p2p global instance
func MakeP2PServer ¶
func MakeP2PServer(p *config.P2PConfig, roleIntf role.RoleInterface) *P2PServer
MakeP2PServer create instance
func (*P2PServer) GetPeerP2PInfo ¶
GetPeerP2P get all peers
func (*P2PServer) GetPeersData ¶
func (s *P2PServer) GetPeersData() PeerDataSet
GetPeersData get a peer's info
func (*P2PServer) IsPeerExist ¶
IsPeerExist judege if a peer exist or not by index
func (*P2PServer) IsPeerInfoExist ¶
IsPeerInfoExist judge if a peer exist or not by peer info
func (*P2PServer) SendBroadcast ¶
func (s *P2PServer) SendBroadcast(packet BcastMsgPacket)
SendBroadcast send a packet to some peer which is not set filter
func (*P2PServer) SendUnicast ¶
func (s *P2PServer) SendUnicast(packet UniMsgPacket)
SendUnicast send a packet to a peer
func (*P2PServer) SetCallback ¶
SetCallback set new connection call back
type Peer ¶
type Peer struct { Info PeerInfo Index uint16 /*peer state*/ State int In bool // contains filtered or unexported fields }
Peer peer...
func CreatePeer ¶
CreatePeer create a instance
type PeerInfo ¶
type PeerInfo struct { //Id peer id Id string //Addr peer address Addr string //Port peer port Port string //ChainId peer work chain id ChainId string //Signature peer auth Signature []byte //Version Version uint32 }
PeerInfo peer's info
var LocalPeerInfo PeerInfo
LocalPeerInfo ourself node info
func (*PeerInfo) IsIncomplete ¶
IsIncomplete judege peer's info is complete or not
type UniMsgPacket ¶
UniMsgPacket it is a unicast packet , Index is peer id to send to