Documentation ¶
Index ¶
- Constants
- func CidB32(t testing.TB, b58CID string) string
- func CreatePeerKey(key string) (string, error)
- func GetPrivateKey(key string) (string, error)
- func GetPublicKey(key string) (string, error)
- func MustBytesFromHex(t testing.TB, s string) []byte
- func MustCID(t testing.TB, s string) cid.Cid
- func NewIdentityDataStore(t testing.TB) ds.Datastore
- type Discovery
- type DiscoveryFactory
- type PeeringService
- type State
Constants ¶
const DiscoveryInterval = time.Hour
DiscoveryInterval is how often we re-publish our mDNS records.
const DiscoveryServiceTag = "p2pdb-example"
DiscoveryServiceTag is used in our mDNS advertisements to discover other chat peers.
const LISTEN_ADDRESS_STRINGS = "/ip4/0.0.0.0/tcp/0"
Variables ¶
This section is empty.
Functions ¶
func CreatePeerKey ¶
func GetPrivateKey ¶
func GetPublicKey ¶
Types ¶
type DiscoveryFactory ¶
type DiscoveryFactory struct {
// contains filtered or unexported fields
}
func NewDiscoveryFactory ¶
func NewDiscoveryFactory() *DiscoveryFactory
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.
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. |