Documentation ¶
Index ¶
- func MakePeer(addr string) (*lp2ppeer.AddrInfo, error)
- func PeerAddrsToAddrInfo(addrs []string) ([]lp2ppeer.AddrInfo, error)
- 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, _ 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 ¶
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"` NetworkKey string `toml:"network_key"` EnableNAT bool `toml:"enable_nat"` EnableRelay bool `toml:"enable_relay"` RelayAddrs []string `toml:"relay_addresses"` EnableMdns bool `toml:"enable_mdns"` Bootstrap *BootstrapConfig `toml:"bootstrap"` }
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) SanityCheck ¶
SanityCheck performs basic checks on the configuration.
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 { *testsuite.TestSuite BroadcastCh chan BroadcastData EventCh chan Event ID peer.ID OtherNets []*MockNetwork SendError error }
func MockingNetwork ¶
func MockingNetwork(ts *testsuite.TestSuite, 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 }
StreamMessage represents message from stream module.
func (*StreamMessage) Type ¶
func (*StreamMessage) Type() EventType
Click to show internal directories.
Click to hide internal directories.