comm

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// NonceSize is the default NonceSize
	NonceSize = 24
)

Variables

View Source
var File_messages_proto protoreflect.FileDescriptor

Functions

func GetRandomBytes

func GetRandomBytes(len int) ([]byte, error)

GetRandomBytes returns len random looking bytes

func GetRandomNonce

func GetRandomNonce() ([]byte, error)

GetRandomNonce returns a random byte array of length NonceSize

func NewDelimitedReader

func NewDelimitedReader(r io2.Reader, maxSize int) io.ReadCloser

func P2PLayerTestRound added in v0.4.0

func P2PLayerTestRound(t *testing.T, bootstrapNode *HostNode, node *HostNode)

func SessionsForMPCTestRound added in v0.4.0

func SessionsForMPCTestRound(t *testing.T, bootstrapNode *HostNode, node *HostNode)

func SessionsTestRound added in v0.4.0

func SessionsTestRound(t *testing.T, bootstrapNode *HostNode, node *HostNode)

Types

type ConfigService

type ConfigService interface {
	GetString(key string) string
	GetPath(key string) string
}

type EndpointService

type EndpointService interface {
	Resolve(party view2.Identity) (view2.Identity, map[view.PortName]string, []byte, error)
	GetIdentity(label string, pkID []byte) (view2.Identity, error)
}

type HostNode added in v0.4.0

type HostNode struct {
	*P2PNode
	ID      host2.PeerID
	Address host2.PeerIPAddress
}

type Metrics added in v0.3.0

type Metrics struct {
	Sessions       metrics.Gauge
	StreamHashes   metrics.Gauge
	ActiveStreams  metrics.Gauge
	OpenedStreams  metrics.Counter
	ClosedStreams  metrics.Counter
	StreamHandlers metrics.Gauge
}

type NetworkStreamSession

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

NetworkStreamSession implements view.Session

func (*NetworkStreamSession) Close

func (n *NetworkStreamSession) Close()

Close releases all the resources allocated by this session

func (*NetworkStreamSession) Info

func (*NetworkStreamSession) Receive

func (n *NetworkStreamSession) Receive() <-chan *view.Message

Receive returns a channel of messages received from the endpoint

func (*NetworkStreamSession) Send

func (n *NetworkStreamSession) Send(payload []byte) error

Send sends the payload to the endpoint

func (*NetworkStreamSession) SendError

func (n *NetworkStreamSession) SendError(payload []byte) error

SendError sends an error to the endpoint with the passed payload

func (*NetworkStreamSession) SendErrorWithContext added in v0.4.0

func (n *NetworkStreamSession) SendErrorWithContext(ctx context.Context, payload []byte) error

func (*NetworkStreamSession) SendWithContext added in v0.4.0

func (n *NetworkStreamSession) SendWithContext(ctx context.Context, payload []byte) error

type P2PNode

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

func NewNode

func NewNode(h host2.P2PHost, _ trace.TracerProvider, metricsProvider metrics.Provider) (*P2PNode, error)

func (*P2PNode) DeleteSessions

func (p *P2PNode) DeleteSessions(_ context.Context, sessionID string)

func (*P2PNode) Lookup

func (p *P2PNode) Lookup(peerID string) ([]string, bool)

func (*P2PNode) MasterSession

func (p *P2PNode) MasterSession() (view.Session, error)

func (*P2PNode) NewSession

func (p *P2PNode) NewSession(callerViewID string, contextID string, endpoint string, pkid []byte) (view.Session, error)

func (*P2PNode) NewSessionWithID

func (p *P2PNode) NewSessionWithID(sessionID, contextID, endpoint string, pkid []byte, caller view.Identity, msg *view.Message) (view.Session, error)

func (*P2PNode) Start

func (p *P2PNode) Start(ctx context.Context)

func (*P2PNode) Stop

func (p *P2PNode) Stop()

type PKExtractor added in v0.4.0

type PKExtractor struct{}

func (*PKExtractor) ExtractPublicKey added in v0.4.0

func (p *PKExtractor) ExtractPublicKey(id view.Identity) (any, error)

type Service

type Service struct {
	HostProvider    host.GeneratorProvider
	EndpointService EndpointService
	ConfigService   ConfigService
	DefaultIdentity view2.Identity

	Node     *P2PNode
	NodeSync sync.RWMutex
	// contains filtered or unexported fields
}

func NewService

func NewService(hostProvider host.GeneratorProvider, endpointService EndpointService, configService ConfigService, defaultIdentity view2.Identity, tracerProvider trace.TracerProvider, metricsProvider metrics.Provider) (*Service, error)

func (*Service) Addresses added in v0.3.0

func (s *Service) Addresses(id view2.Identity) ([]string, error)

func (*Service) DeleteSessions

func (s *Service) DeleteSessions(ctx context.Context, sessionID string)

func (*Service) MasterSession

func (s *Service) MasterSession() (view2.Session, error)

func (*Service) NewSession

func (s *Service) NewSession(caller string, contextID string, endpoint string, pkid []byte) (view2.Session, error)

func (*Service) NewSessionWithID

func (s *Service) NewSessionWithID(sessionID, contextID, endpoint string, pkid []byte, caller view2.Identity, msg *view2.Message) (view2.Session, error)

func (*Service) Start

func (s *Service) Start(ctx context.Context)

func (*Service) Stop

func (s *Service) Stop()

type ViewPacket

type ViewPacket struct {
	SessionID string `protobuf:"bytes,1,opt,name=sessionID,proto3" json:"sessionID,omitempty"`
	ContextID string `protobuf:"bytes,2,opt,name=contextID,proto3" json:"contextID,omitempty"`
	Status    int32  `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"`
	Payload   []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
	Caller    string `protobuf:"bytes,5,opt,name=caller,proto3" json:"caller,omitempty"`
	// contains filtered or unexported fields
}

func (*ViewPacket) Descriptor deprecated

func (*ViewPacket) Descriptor() ([]byte, []int)

Deprecated: Use ViewPacket.ProtoReflect.Descriptor instead.

func (*ViewPacket) GetCaller

func (x *ViewPacket) GetCaller() string

func (*ViewPacket) GetContextID

func (x *ViewPacket) GetContextID() string

func (*ViewPacket) GetPayload

func (x *ViewPacket) GetPayload() []byte

func (*ViewPacket) GetSessionID

func (x *ViewPacket) GetSessionID() string

func (*ViewPacket) GetStatus

func (x *ViewPacket) GetStatus() int32

func (*ViewPacket) ProtoMessage

func (*ViewPacket) ProtoMessage()

func (*ViewPacket) ProtoReflect

func (x *ViewPacket) ProtoReflect() protoreflect.Message

func (*ViewPacket) Reset

func (x *ViewPacket) Reset()

func (*ViewPacket) String

func (x *ViewPacket) String() string

Directories

Path Synopsis
io

Jump to

Keyboard shortcuts

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