Documentation ¶
Index ¶
- Constants
- Variables
- type LibP2P
- func (p *LibP2P) AddDefaultTopics()
- func (p *LibP2P) AddTopic(topicName string)
- func (p *LibP2P) ConnectBootNodes() error
- func (p *LibP2P) GetBootNodes() (peers []peerstore.ID)
- func (p *LibP2P) LocalID() peerstore.ID
- func (p *LibP2P) LocalIdString() string
- func (p *LibP2P) PubP2P(topic string, msg []byte) error
- func (p *LibP2P) RequestPeer(peerID peerstore.ID, code int, request []byte) ([]byte, error)
- func (p *LibP2P) SetHandlers(handlers map[int]dev.P2pHandler)
- func (p *LibP2P) SubP2P(topic string) ([]byte, error)
- type MockP2p
- func (m *MockP2p) AddTopic(topicName string)
- func (m *MockP2p) ConnectBootNodes() error
- func (m *MockP2p) GetBootNodes() []peer.ID
- func (m *MockP2p) LocalID() peer.ID
- func (m *MockP2p) LocalIdString() string
- func (m *MockP2p) PubP2P(topic string, msg []byte) error
- func (m *MockP2p) RequestPeer(peerID peer.ID, code int, request []byte) (response []byte, err error)
- func (m *MockP2p) SetHandlers(handlers map[int]dev.P2pHandler)
- func (m *MockP2p) SubP2P(topic string) ([]byte, error)
- type P2pNetwork
Constants ¶
View Source
const (
RequestCodeBytesLen = 3
)
Variables ¶
View Source
var ( TopicsMap = make(map[string]*pubsub.Topic, 0) SubsMap = make(map[string]*pubsub.Subscription, 0) )
Functions ¶
This section is empty.
Types ¶
type LibP2P ¶
type LibP2P struct {
// contains filtered or unexported fields
}
todo: use stream pool to optimize it
func (*LibP2P) AddDefaultTopics ¶
func (p *LibP2P) AddDefaultTopics()
func (*LibP2P) ConnectBootNodes ¶
func (*LibP2P) GetBootNodes ¶
func (*LibP2P) LocalIdString ¶
func (*LibP2P) RequestPeer ¶
func (*LibP2P) SetHandlers ¶
func (p *LibP2P) SetHandlers(handlers map[int]dev.P2pHandler)
type MockP2p ¶
type MockP2p struct {
// contains filtered or unexported fields
}
func NewMockP2p ¶
func (*MockP2p) ConnectBootNodes ¶
func (*MockP2p) GetBootNodes ¶
func (*MockP2p) LocalIdString ¶
func (*MockP2p) RequestPeer ¶
func (*MockP2p) SetHandlers ¶
func (m *MockP2p) SetHandlers(handlers map[int]dev.P2pHandler)
type P2pNetwork ¶
type P2pNetwork interface { LocalID() peer.ID LocalIdString() string GetBootNodes() []peer.ID ConnectBootNodes() error AddTopic(topicName string) SetHandlers(handlers map[int]dev.P2pHandler) RequestPeer(peerID peer.ID, code int, request []byte) (response []byte, err error) PubP2P(topic string, msg []byte) error SubP2P(topic string) ([]byte, error) }
func NewP2P ¶
func NewP2P(cfg *config.P2pConf) P2pNetwork
Click to show internal directories.
Click to hide internal directories.