...

Package p2p

import "vminko.org/dscuss/p2p"
Overview
Index
Subdirectories

Overview ▾

Constants

const (
    ConnectionProviderLatency time.Duration = 1 // in seconds
    DefaultBootstrapAddress   string        = "dscuss.org:8004"
)
const (
    DHTCrawlerTimeout time.Duration = 5 * time.Second
)

type AddressConsumer

type AddressConsumer interface {
    AddressFound(a string)
    ErrorFindingAddresses(err error)
}

type AddressList

AddressList provider node addresses by reading them from a text file. Implements AddressProvider interface

type AddressList struct {
    // contains filtered or unexported fields
}

func NewAddressList

func NewAddressList(filepath string) *AddressList

func (*AddressList) RegisterAddressConsumer

func (al *AddressList) RegisterAddressConsumer(ac AddressConsumer)

func (*AddressList) Start

func (al *AddressList) Start()

func (*AddressList) Stop

func (al *AddressList) Stop()

type AddressProvider

AddressProvider isolates ConnectionProvider from implementations of various address discovery methods.

type AddressProvider interface {
    RegisterAddressConsumer(ac AddressConsumer)
    Start()
    Stop()
}

type ConnectionProvider

Responsible for establishing connections with other peers.

type ConnectionProvider struct {
    // contains filtered or unexported fields
}

func NewConnectionProvider

func NewConnectionProvider(
    aps []AddressProvider,
    hostport string,
    maxInConnCount uint32,
    maxOutConnCount uint32,
) *ConnectionProvider

func (*ConnectionProvider) AddressFound

func (cp *ConnectionProvider) AddressFound(a string)

func (*ConnectionProvider) ErrorFindingAddresses

func (cp *ConnectionProvider) ErrorFindingAddresses(err error)

func (*ConnectionProvider) Start

func (cp *ConnectionProvider) Start()

func (*ConnectionProvider) Stop

func (cp *ConnectionProvider) Stop()

type DHTCrawler

DHTCrawler discovers new peers via DHT. Implements AddressProvider interface

type DHTCrawler struct {
    // contains filtered or unexported fields
}

func NewDHTCrawler

func NewDHTCrawler(
    addr string,
    port int,
    bootstrap string,
    advPort int,
    s subs.Subscriptions,
) *DHTCrawler

func (*DHTCrawler) RegisterAddressConsumer

func (dc *DHTCrawler) RegisterAddressConsumer(ac AddressConsumer)

func (*DHTCrawler) Start

func (dc *DHTCrawler) Start()

func (*DHTCrawler) Stop

func (dc *DHTCrawler) Stop()

type PeerPool

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

func NewPeerPool(cp *ConnectionProvider, owner *owner.Owner) *PeerPool

func (*PeerPool) ListPeers

func (pp *PeerPool) ListPeers() []*peer.Info

func (*PeerPool) Start

func (pp *PeerPool) Start()

func (*PeerPool) Stop

func (pp *PeerPool) Stop()

func (*PeerPool) ValidatePeer

func (pp *PeerPool) ValidatePeer(newPeer *peer.Peer) bool

Subdirectories

Name Synopsis
..
connection
peer