peer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPeerIdNotFoundInContext   = errors.New("peer id not found in context")
	ErrIdentityNotFoundInContext = errors.New("identity not found in context")
)

Functions

func CtxIdentity

func CtxIdentity(ctx context.Context) ([]byte, error)

CtxIdentity returns identity from context

func CtxPeerAddr

func CtxPeerAddr(ctx context.Context) string

CtxPeerAddr returns peer address

func CtxPeerId

func CtxPeerId(ctx context.Context) (string, error)

CtxPeerId first tries to get peer id under our own key, but if it is not found tries to get through DRPC key

func CtxPubKey

func CtxPubKey(ctx context.Context) (crypto.PubKey, error)

CtxPubKey returns identity unmarshalled from proto in crypto.PubKey model

func CtxWithIdentity

func CtxWithIdentity(ctx context.Context, identity []byte) context.Context

CtxWithIdentity sets identity in the context

func CtxWithPeerAddr

func CtxWithPeerAddr(ctx context.Context, addr string) context.Context

CtxWithPeerAddr sets peer address to the context

func CtxWithPeerId

func CtxWithPeerId(ctx context.Context, peerId string) context.Context

CtxWithPeerId sets peer id in the context

Types

type Peer

type Peer interface {
	Id() string
	LastUsage() time.Time
	UpdateLastUsage()
	Addr() string
	TryClose(objectTTL time.Duration) (res bool, err error)
	drpc.Conn
}

func NewPeer

func NewPeer(sc sec.SecureConn, conn drpc.Conn) Peer

Jump to

Keyboard shortcuts

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