const (
ConnectionProviderLatency time.Duration = 1 // in seconds
DefaultBootstrapAddress string = "dscuss.org:8004"
)
const (
DHTCrawlerTimeout time.Duration = 5 * time.Second
)
type AddressConsumer interface {
AddressFound(a string)
ErrorFindingAddresses(err error)
}
AddressList provider node addresses by reading them from a text file. Implements AddressProvider interface
type AddressList struct {
// contains filtered or unexported fields
}
func NewAddressList(filepath string) *AddressList
func (al *AddressList) RegisterAddressConsumer(ac AddressConsumer)
func (al *AddressList) Start()
func (al *AddressList) Stop()
AddressProvider isolates ConnectionProvider from implementations of various address discovery methods.
type AddressProvider interface {
RegisterAddressConsumer(ac AddressConsumer)
Start()
Stop()
}
Responsible for establishing connections with other peers.
type ConnectionProvider struct {
// contains filtered or unexported fields
}
func NewConnectionProvider(
aps []AddressProvider,
hostport string,
maxInConnCount uint32,
maxOutConnCount uint32,
) *ConnectionProvider
func (cp *ConnectionProvider) AddressFound(a string)
func (cp *ConnectionProvider) ErrorFindingAddresses(err error)
func (cp *ConnectionProvider) Start()
func (cp *ConnectionProvider) Stop()
DHTCrawler discovers new peers via DHT. Implements AddressProvider interface
type DHTCrawler struct {
// contains filtered or unexported fields
}
func NewDHTCrawler(
addr string,
port int,
bootstrap string,
advPort int,
s subs.Subscriptions,
) *DHTCrawler
func (dc *DHTCrawler) RegisterAddressConsumer(ac AddressConsumer)
func (dc *DHTCrawler) Start()
func (dc *DHTCrawler) Stop()
PeerPool is responsible for managing peers. It creates new peers, accounts peers and manages peer life cycle. But it has nothing to do with Entity transferring.
type PeerPool struct {
// contains filtered or unexported fields
}
func NewPeerPool(cp *ConnectionProvider, owner *owner.Owner) *PeerPool
func (pp *PeerPool) ListPeers() []*peer.Info
func (pp *PeerPool) Start()
func (pp *PeerPool) Stop()
func (pp *PeerPool) ValidatePeer(newPeer *peer.Peer) bool
| Name | Synopsis |
|---|---|
| .. | |
| connection | |
| peer | |