Versions in this module Expand all Collapse all v1 v1.0.0 Jul 13, 2019 Changes in this version + const OPLength + const PreP2PLength + const RPCIDLength + var ErrPipeClosed = errors.New("p2p: read or write on closed message pipe") + var ErrShuttingDown = errors.New("shutting down") + var OPNonRPCMap = map[P2PCommandOp]func(P2PCommandOp, []byte) + var OPSerializerMap = map[P2PCommandOp]interface + var OpRPCMap = map[P2PCommandOp]msgHandleSt + var PeerShardOpRPCMap = map[P2PCommandOp]msgHandleSt + func Encrypt(metadata Metadata, op P2PCommandOp, ipcID uint64, cmd interface{}) ([]byte, error) + func ExpectMsg(r MsgReader, code uint64, content interface{}) error + func GetPrivateKeyFromConfig(configKey string) (*ecdsa.PrivateKey, error) + func MsgPipe() (*MsgPipeRW, *MsgPipeRW) + func NewQKCRlp(fd net.Conn) transport + func Send(w MsgWriter, msgcode uint64, data interface{}) error + func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error + type Cap struct + Name string + Version uint + func (cap Cap) String() string + type Config struct + BootstrapNodes []*enode.Node + BootstrapNodesV5 []*discv5.Node + DialRatio int + Dialer NodeDialer + DiscoveryV5 bool + EnableMsgEvents bool + ListenAddr string + Logger log.Logger + MaxPeers int + MaxPendingPeers int + NAT nat.Interface + Name string + NetRestrict *netutil.Netlist + NoDial bool + NoDiscovery bool + NodeDatabase string + PrivateKey *ecdsa.PrivateKey + Protocols []Protocol + StaticNodes []*enode.Node + TrustedNodes []*enode.Node + type DiscReason uint + const DiscAlreadyConnected + const DiscIncompatibleVersion + const DiscInvalidIdentity + const DiscNetworkError + const DiscProtocolError + const DiscQuitting + const DiscReadTimeout + const DiscRequested + const DiscSelf + const DiscSubprotocolError + const DiscTooManyPeers + const DiscUnexpectedIdentity + const DiscUselessPeer + func (d DiscReason) Error() string + func (d DiscReason) String() string + type GetMinorBlockHeaderListRequest struct + BlockHash common.Hash + Branch account.Branch + Direction uint8 + Limit uint32 + type GetMinorBlockHeaderListResponse struct + BlockHeaderList []*types.MinorBlockHeader + RootTip *types.RootBlockHeader + ShardTip *types.MinorBlockHeader + type GetMinorBlockListRequest struct + MinorBlockHashList []common.Hash + type GetMinorBlockListResponse struct + MinorBlockList []*types.MinorBlock + type GetPeerListRequest struct + MaxPeers uint32 + type GetPeerListResponse struct + PeerInfoList []P2PeerInfo + type GetRootBlockHeaderListRequest struct + BlockHash common.Hash + Direction uint8 + Limit uint32 + type GetRootBlockHeaderListResponse struct + BlockHeaderList []*types.RootBlockHeader + RootTip *types.RootBlockHeader + type GetRootBlockListRequest struct + RootBlockHashList []common.Hash + type GetRootBlockListResponse struct + RootBlockList []*types.RootBlock + type HelloCmd struct + ChainMaskList []uint32 + NetWorkID uint32 + PeerID common.Hash + PeerIP *serialize.Uint128 + PeerPort uint16 + RootBlockHeader *types.RootBlockHeader + Version uint32 + type Metadata struct + Branch uint32 + func (m Metadata) Size() int + type Msg struct + Code uint64 + Payload io.Reader + ReceivedAt time.Time + Size uint32 + func MakeMsg(op P2PCommandOp, rpcID uint64, metadata Metadata, msg interface{}) (Msg, error) + func (msg Msg) Decode(val interface{}) error + func (msg Msg) Discard() error + func (msg Msg) String() string + type MsgPipeRW struct + func (p *MsgPipeRW) Close() error + func (p *MsgPipeRW) ReadMsg() (Msg, error) + func (p *MsgPipeRW) WriteMsg(msg Msg) error + type MsgReadWriter interface + type MsgReader interface + ReadMsg func() (Msg, error) + type MsgWriter interface + WriteMsg func(Msg) error + type NewBlockMinor struct + Block *types.MinorBlock + type NewTransactionList struct + TransactionList []*types.Transaction + type NodeDialer interface + Dial func(*enode.Node) (net.Conn, error) + type NodeInfo struct + ENR string + Enode string + ID string + IP string + ListenAddr string + Name string + Ports struct{ ... } + Protocols map[string]interface{} + type P2PCommandOp byte + const GetMinorBlockHeaderListRequestMsg + const GetMinorBlockHeaderListResponseMsg + const GetMinorBlockListRequestMsg + const GetMinorBlockListResponseMsg + const GetPeerListRequestMsg + const GetPeerListResponseMsg + const GetRootBlockHeaderListRequestMsg + const GetRootBlockHeaderListResponseMsg + const GetRootBlockListRequestMsg + const GetRootBlockListResponseMsg + const Hello + const MaxOPNum + const NewBlockMinorMsg + const NewTipMsg + const NewTransactionListMsg + func (p P2PCommandOp) String() string + type P2PeerInfo struct + IP *serialize.Uint128 + Port uint16 + type Peer struct + func NewPeer(id enode.ID, name string, caps []Cap) *Peer + func (p *Peer) Caps() []Cap + func (p *Peer) Disconnect(reason DiscReason) + func (p *Peer) ID() enode.ID + func (p *Peer) Inbound() bool + func (p *Peer) Info() *PeerInfo + func (p *Peer) LocalAddr() net.Addr + func (p *Peer) Log() log.Logger + func (p *Peer) Name() string + func (p *Peer) Node() *enode.Node + func (p *Peer) RemoteAddr() net.Addr + func (p *Peer) String() string + type PeerEvent struct + Error string + MsgCode *uint64 + MsgSize *uint32 + Peer enode.ID + Protocol string + Type PeerEventType + type PeerEventType string + const PeerEventTypeAdd + const PeerEventTypeDrop + const PeerEventTypeMsgRecv + const PeerEventTypeMsgSend + type PeerInfo struct + Caps []string + Enode string + ID string + Name string + Network struct{ ... } + Protocols map[string]interface{} + type Protocol struct + Attributes []enr.Entry + Length uint64 + Name string + NodeInfo func() interface{} + PeerInfo func(id enode.ID) interface{} + Run func(peer *Peer, rw MsgReadWriter) error + Version uint + type QKCMsg struct + Data []byte + MetaData Metadata + Op P2PCommandOp + RpcID uint64 + func DecodeQKCMsg(body []byte) (QKCMsg, error) + type Server struct + DiscV5 *discv5.Network + func (srv *Server) AddPeer(node *enode.Node) + func (srv *Server) AddTrustedPeer(node *enode.Node) + func (srv *Server) NodeInfo() *NodeInfo + func (srv *Server) PeerCount() int + func (srv *Server) Peers() []*Peer + func (srv *Server) PeersInfo() []*PeerInfo + func (srv *Server) RemovePeer(node *enode.Node) + func (srv *Server) RemoveTrustedPeer(node *enode.Node) + func (srv *Server) Self() *enode.Node + func (srv *Server) SetupConn(fd net.Conn, flags connFlag, dialDest *enode.Node) error + func (srv *Server) Start() (err error) + func (srv *Server) Stop() + func (srv *Server) SubscribeEvents(ch chan *PeerEvent) event.Subscription + type TCPDialer struct + func (t TCPDialer) Dial(dest *enode.Node) (net.Conn, error) + type Tip struct + MinorBlockHeaderList []*types.MinorBlockHeader + RootBlockHeader *types.RootBlockHeader