peer

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const CtxResponsiblePeers = "*"

Variables

View Source
var (
	ErrPeerIdNotFoundInContext       = errors.New("peer id not found in context")
	ErrProtoVersionNotFoundInContext = errors.New("proto version 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 CtxPeerClientVersion added in v0.2.2

func CtxPeerClientVersion(ctx context.Context) string

CtxPeerClientVersion returns peer client version

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 CtxProtoVersion added in v0.4.23

func CtxProtoVersion(ctx context.Context) (uint32, error)

CtxProtoVersion returns peer protocol version

func CtxPubKey

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

CtxPubKey returns identity unmarshalled from proto in crypto.PubKey model

func CtxWithClientVersion added in v0.2.2

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

CtxWithClientVersion sets peer clientVersion to the context

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

func CtxWithProtoVersion added in v0.4.23

func CtxWithProtoVersion(ctx context.Context, version uint32) context.Context

CtxWithProtoVersion sets peer protocol version

Types

type Peer

type Peer interface {
	Id() string
	Context() context.Context

	AcquireDrpcConn(ctx context.Context) (drpc.Conn, error)
	ReleaseDrpcConn(conn drpc.Conn)
	DoDrpc(ctx context.Context, do func(conn drpc.Conn) error) error

	IsClosed() bool
	CloseChan() <-chan struct{}

	// SetTTL overrides the default pool ttl
	SetTTL(ttl time.Duration)

	TryClose(objectTTL time.Duration) (res bool, err error)

	ocache.Object
}

func NewPeer

func NewPeer(mc transport.MultiConn, ctrl connCtrl) (p Peer, err error)

Directories

Path Synopsis
Package mock_peer is a generated GoMock package.
Package mock_peer is a generated GoMock package.

Jump to

Keyboard shortcuts

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