discovery

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2022 License: Apache-2.0, MIT Imports: 20 Imported by: 2

README

p2pdb-route

decentralized,distributed,peer-to-peer database.

Documentation

Index

Constants

View Source
const DiscoveryInterval = time.Hour

DiscoveryInterval is how often we re-publish our mDNS records.

View Source
const DiscoveryServiceTag = "p2pdb-example"

DiscoveryServiceTag is used in our mDNS advertisements to discover other chat peers.

View Source
const LISTEN_ADDRESS_STRINGS = "/ip4/0.0.0.0/tcp/0"

Variables

This section is empty.

Functions

func CidB32

func CidB32(t testing.TB, b58CID string) string

func CreatePeerKey

func CreatePeerKey(key string) (string, error)

func GetPrivateKey

func GetPrivateKey(key string) (string, error)

func GetPublicKey

func GetPublicKey(key string) (string, error)

func MustBytesFromHex

func MustBytesFromHex(t testing.TB, s string) []byte

func MustCID

func MustCID(t testing.TB, s string) cid.Cid

func NewIdentityDataStore

func NewIdentityDataStore(t testing.TB) ds.Datastore

Types

type Discovery

type Discovery interface {
	// create a new libp2p Host that listens on a random TCP port
	//	Connect() (Host string)
	Create(host string) (host.Host, error)
	SetupDiscovery(host host.Host) error
}

type DiscoveryFactory

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

func NewDiscoveryFactory

func NewDiscoveryFactory() *DiscoveryFactory

func (*DiscoveryFactory) Create

func (d *DiscoveryFactory) Create(host string) (host.Host, error)

func (*DiscoveryFactory) GetLocalPeerId

func (d *DiscoveryFactory) GetLocalPeerId() peer.ID

func (*DiscoveryFactory) SetLocalPeerId

func (d *DiscoveryFactory) SetLocalPeerId(id peer.ID)

func (*DiscoveryFactory) SetupDiscovery

func (d *DiscoveryFactory) SetupDiscovery(h host.Host) error

setupDiscovery creates an mDNS discovery service and attaches it to the libp2p Host. This lets us automatically discover peers on the same LAN and connect to them.

type PeeringService

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

PeeringService maintains connections to specified peers, reconnecting on disconnect with a back-off.

func NewPeeringService

func NewPeeringService(host host.Host) *PeeringService

NewPeeringService constructs a new peering service. Peers can be added and removed immediately, but connections won't be formed until `Start` is called.

func (*PeeringService) AddPeer

func (ps *PeeringService) AddPeer(info peer.AddrInfo)

AddPeer adds a peer to the peering service. This function may be safely called at any time: before the service is started, while running, or after it stops.

Add peer may also be called multiple times for the same peer. The new addresses will replace the old.

func (*PeeringService) GetState

func (ps *PeeringService) GetState() State

GetState get the State of the PeeringService

func (*PeeringService) ListPeers

func (ps *PeeringService) ListPeers() []peer.AddrInfo

ListPeers lists peers in the peering service.

func (*PeeringService) RemovePeer

func (ps *PeeringService) RemovePeer(id peer.ID)

RemovePeer removes a peer from the peering service. This function may be safely called at any time: before the service is started, while running, or after it stops.

func (*PeeringService) Start

func (ps *PeeringService) Start() error

Start starts the peering service, connecting and maintaining connections to all registered peers. It returns an error if the service has already been stopped.

func (*PeeringService) Stop

func (ps *PeeringService) Stop() error

Stop stops the peering service.

type State

type State uint
const (
	StateInit State = iota
	StateRunning
	StateStopped
)

func (State) String

func (s State) String() string

Directories

Path Synopsis
Package identityprovider defines a default identity provider for IPFS Log and OrbitDB.
Package identityprovider defines a default identity provider for IPFS Log and OrbitDB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL