Documentation
¶
Index ¶
- func PeerAddrsToAddrInfo(addrs []string) ([]lp2ppeer.AddrInfo, error)
- func TestRandomPeerID() peer.ID
- type BootstrapConfig
- type BroadcastData
- type Config
- type Event
- type EventType
- type GossipMessage
- type MockNetwork
- func (mock *MockNetwork) AddAnotherNetwork(net *MockNetwork)
- func (mock *MockNetwork) Broadcast(data []byte, tid TopicID) error
- func (mock *MockNetwork) CloseConnection(pid peer.ID)
- func (mock *MockNetwork) EventChannel() <-chan Event
- func (mock *MockNetwork) IsClosed(pid peer.ID) bool
- func (mock *MockNetwork) JoinConsensusTopic() error
- func (mock *MockNetwork) JoinGeneralTopic() error
- func (mock *MockNetwork) NumConnectedPeers() int
- func (mock *MockNetwork) SelfID() peer.ID
- func (mock *MockNetwork) SendTo(data []byte, pid lp2pcore.PeerID) error
- func (mock *MockNetwork) SendToOthers(data []byte, target *peer.ID)
- func (mock *MockNetwork) Start() error
- func (mock *MockNetwork) Stop()
- type Network
- type StreamMessage
- type TopicID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PeerAddrsToAddrInfo ¶
PeerAddrsToAddrInfo converts a slice of string peer addresses to AddrInfo.
Types ¶
type BootstrapConfig ¶
type BootstrapConfig struct {
Addresses []string `toml:"addresses"`
MinThreshold int `toml:"min_threshold"`
MaxThreshold int `toml:"max_threshold"`
Period time.Duration `toml:"period"`
}
BootstrapConfig holds all configuration options related to bootstrap nodes.
type BroadcastData ¶
type Config ¶
type Config struct {
Name string `toml:"name"`
Listens []string `toml:"listens"`
NodeKey string `toml:"node_key"`
EnableDHT bool `toml:"enable_dht"`
EnableNAT bool `toml:"enable_nat"`
EnableRelay bool `toml:"enable_relay"`
EnablePing bool `toml:"enable_ping"`
EnableMdns bool `toml:"enable_mdns"`
Bootstrap *BootstrapConfig `toml:"bootstrap"`
}
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) SanityCheck ¶
SanityCheck is a basic checks for config.
type GossipMessage ¶
`GossipMessage` represents message from PubSub module. `source` is the ID of the peer that initiate the message and `from` is the ID of the peer that we received a message from. They are not necessarily the same, especially in a decentralized network.
func (*GossipMessage) Type ¶
func (*GossipMessage) Type() EventType
type MockNetwork ¶
type MockNetwork struct {
BroadcastCh chan BroadcastData
EventCh chan Event
ID peer.ID
OtherNets []*MockNetwork
}
func MockingNetwork ¶
func MockingNetwork(id peer.ID) *MockNetwork
func (*MockNetwork) AddAnotherNetwork ¶
func (mock *MockNetwork) AddAnotherNetwork(net *MockNetwork)
func (*MockNetwork) CloseConnection ¶
func (mock *MockNetwork) CloseConnection(pid peer.ID)
func (*MockNetwork) EventChannel ¶
func (mock *MockNetwork) EventChannel() <-chan Event
func (*MockNetwork) JoinConsensusTopic ¶
func (mock *MockNetwork) JoinConsensusTopic() error
func (*MockNetwork) JoinGeneralTopic ¶
func (mock *MockNetwork) JoinGeneralTopic() error
func (*MockNetwork) NumConnectedPeers ¶
func (mock *MockNetwork) NumConnectedPeers() int
func (*MockNetwork) SelfID ¶
func (mock *MockNetwork) SelfID() peer.ID
func (*MockNetwork) SendTo ¶
func (mock *MockNetwork) SendTo(data []byte, pid lp2pcore.PeerID) error
func (*MockNetwork) SendToOthers ¶
func (mock *MockNetwork) SendToOthers(data []byte, target *peer.ID)
func (*MockNetwork) Start ¶
func (mock *MockNetwork) Start() error
func (*MockNetwork) Stop ¶
func (mock *MockNetwork) Stop()
type Network ¶
type Network interface {
Start() error
Stop()
EventChannel() <-chan Event
Broadcast([]byte, TopicID) error
SendTo([]byte, lp2pcore.PeerID) error
JoinGeneralTopic() error
JoinConsensusTopic() error
CloseConnection(pid lp2pcore.PeerID)
SelfID() lp2pcore.PeerID
NumConnectedPeers() int
}
func NewNetwork ¶
type StreamMessage ¶
type StreamMessage struct {
Source lp2pcore.PeerID
Reader io.ReadCloser
}
`GossipMessage` represents message from stream module.
func (*StreamMessage) Type ¶
func (*StreamMessage) Type() EventType
Click to show internal directories.
Click to hide internal directories.