Documentation
¶
Index ¶
- type Config
- type Dispatcher
- type Message
- type Network
- func (n *Network) Close()
- func (n *Network) Connected() chan struct{}
- func (n *Network) EndpointMisbehaving(name string, score int, desc string)
- func (n *Network) EndpointsByQuality() []string
- func (n *Network) SendChannel() chan<- Message
- func (n *Network) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type PeerAddress
- type PeersByQuality
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Number of peers the network should aim to connect to. DesiredConnections int // Path to file used to storing good peers for loading on next startup. PeerStorageFile string // List of hostnames that will be looked up in DNS to get IPs of peers. SeedHostnames []string // Channel to send all received messages that are not handled at the // connection or network layer. Will not be written to after Close() // returns. OutputChannel chan<- Message }
Config passed when creating a new Network.
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher(input <-chan Message) *Dispatcher
Create a new dispatcher that reads from input. Closing the input channel will shut down the dispatcher. It's still recommended to call Close() to block until it's safe to close subscribing channels.
func (*Dispatcher) Close ¶
func (d *Dispatcher) Close()
Close the connection. Blocks until it's safe to close subscribing channels.
func (*Dispatcher) Run ¶
func (d *Dispatcher) Run()
func (*Dispatcher) Subscribe ¶
func (d *Dispatcher) Subscribe(key string, ch chan<- Message)
Subscribe adds a new subscriber for a type of message. Don't call on running dispatcher.
func (*Dispatcher) Unsubscribe ¶
func (d *Dispatcher) Unsubscribe(key string)
Unsubscribe deletes an existing subscription. Only call on running dispatcher.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network sets up a communication network with peers fed to it from DNS, loaded from its storage, and shared from existing peers. The aim is to get a robust network that will give the creator a good overview of the complete Bitcoin network, even if some of the peers are bad actors.
func (*Network) Close ¶
func (n *Network) Close()
Close will shut down the whole network cleanly, with the caveat that it's unsafe to call any further methods on the network object while or after Close() has been called.
func (*Network) Connected ¶
func (n *Network) Connected() chan struct{}
Connected returns a channel that closes once an initial connection has been established.
func (*Network) EndpointMisbehaving ¶
EndpointMisbehaving allows upper levels to report that a endpoint is misbehaving. This will lower the quality score of the associated peer, potentially disconnecting or banning it. Score should be in the range [1,100], where 1 is the least severe misbehaviour and 100 is the worst.
func (*Network) EndpointsByQuality ¶
EndpointsByQuality returns a list of the currently connected endpoint sorted by quality, starting with the best. The quality score is determined by factors like responsiveness and honesty.
func (*Network) SendChannel ¶
type PeerAddress ¶
type PeerAddress struct { Address string Reporter string Services uint64 Time time.Time FailureTime time.Time }
func (PeerAddress) String ¶
func (a PeerAddress) String() string
type PeersByQuality ¶
type PeersByQuality []*peer
func (PeersByQuality) Len ¶
func (slice PeersByQuality) Len() int
func (PeersByQuality) Less ¶
func (slice PeersByQuality) Less(i, j int) bool
func (PeersByQuality) Swap ¶
func (slice PeersByQuality) Swap(i, j int)