transport

package
v5.4.39 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package transport is a generated GoMock package.

Package transport is a generated GoMock package.

Index

Constants

View Source
const NutsCommServiceType = "NutsComm"

NutsCommServiceType holds the DID document service type that specifies the Nuts network service address of the Nuts node.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionManager

type ConnectionManager interface {
	core.Diagnosable

	// Connect attempts to make an outbound connection to the given peer, after the delay has expired.
	// If the delay is 0 it will immediately start connecting. It will take the existing backoff into account when it is nil.
	Connect(peerAddress string, peerDID did.DID, delay *time.Duration)

	// Peers returns a slice containing the peers that are currently connected.
	Peers() []Peer

	// Contacts returns a slice containing the contacts that are currently known (to which we try to connect).
	Contacts() []Contact

	// RegisterObserver allows to register a callback function for stream state changes
	RegisterObserver(callback StreamStateObserverFunc)

	// Start instructs the ConnectionManager to start accepting connections and prepare to make outbound connections.
	Start() error

	// Stop shuts down the connections made by the ConnectionManager.
	Stop()
}

ConnectionManager manages the connections to peers, making outbound connections if required. It also determines the network layout.

type Contact

type Contact struct {
	// Address holds the target address the connector is connecting to.
	Address string
	// DID holds the target DID for the given Address. Is empty for bootstrap nodes
	DID did.DID
	// Attempts holds the number of times the node tried to connect to the peer.
	Attempts uint32
	// LastAttempt holds the time of the last connection attempt.
	LastAttempt *time.Time
	// NextAttempt holds the time of the next connection attempt.
	NextAttempt *time.Time
	// Error holds the errors that occurred during the connection attempts.
	Error *string
}

Contact holds statistics of an outbound connector.

type Diagnostics

type Diagnostics struct {
	// Uptime the uptime (time since the node started) in seconds.
	Uptime time.Duration `json:"uptime"`
	// Peers contains the peer IDs of the node's peers.
	Peers []PeerID `json:"peers"`
	// NumberOfTransactions contains the total number of transactions on the node's DAG.
	NumberOfTransactions uint32 `json:"transactionNum"`
	// SoftwareVersion contains an indication of the software version of the node. It's recommended to use a (Git) commit ID that uniquely resolves to a code revision, alternatively a semantic version could be used (e.g. 1.2.5).
	SoftwareVersion string `json:"softwareVersion"`
	// SoftwareID contains an indication of the vendor of the software of the node. For open source implementations it's recommended to specify URL to the public, open source repository.
	// Proprietary implementations could specify the product's or vendor's name.
	SoftwareID string `json:"softwareID"`
	// Certificate contains the certificate presented by the peer during the TLS handshake.
	Certificate string `json:"certificate"`
	// NodeDID of the connection.
	NodeDID string `json:"nodeDID"`
	// Address is NutsComm on outbound, or IP for inbound connections.
	Address string `json:"address"`
}

Diagnostics contains information that is shared to this node's peers on request.

type MockConnectionManager

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

MockConnectionManager is a mock of ConnectionManager interface.

func NewMockConnectionManager

func NewMockConnectionManager(ctrl *gomock.Controller) *MockConnectionManager

NewMockConnectionManager creates a new mock instance.

func (*MockConnectionManager) Connect

func (m *MockConnectionManager) Connect(peerAddress string, peerDID did.DID, delay *time.Duration)

Connect mocks base method.

func (*MockConnectionManager) Contacts

func (m *MockConnectionManager) Contacts() []Contact

Contacts mocks base method.

func (*MockConnectionManager) Diagnostics

func (m *MockConnectionManager) Diagnostics() []core.DiagnosticResult

Diagnostics mocks base method.

func (*MockConnectionManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConnectionManager) Peers

func (m *MockConnectionManager) Peers() []Peer

Peers mocks base method.

func (*MockConnectionManager) RegisterObserver

func (m *MockConnectionManager) RegisterObserver(callback StreamStateObserverFunc)

RegisterObserver mocks base method.

func (*MockConnectionManager) Start

func (m *MockConnectionManager) Start() error

Start mocks base method.

func (*MockConnectionManager) Stop

func (m *MockConnectionManager) Stop()

Stop mocks base method.

type MockConnectionManagerMockRecorder

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

MockConnectionManagerMockRecorder is the mock recorder for MockConnectionManager.

func (*MockConnectionManagerMockRecorder) Connect

func (mr *MockConnectionManagerMockRecorder) Connect(peerAddress, peerDID, delay interface{}) *gomock.Call

Connect indicates an expected call of Connect.

func (*MockConnectionManagerMockRecorder) Contacts

Contacts indicates an expected call of Contacts.

func (*MockConnectionManagerMockRecorder) Diagnostics

func (mr *MockConnectionManagerMockRecorder) Diagnostics() *gomock.Call

Diagnostics indicates an expected call of Diagnostics.

func (*MockConnectionManagerMockRecorder) Peers

Peers indicates an expected call of Peers.

func (*MockConnectionManagerMockRecorder) RegisterObserver

func (mr *MockConnectionManagerMockRecorder) RegisterObserver(callback interface{}) *gomock.Call

RegisterObserver indicates an expected call of RegisterObserver.

func (*MockConnectionManagerMockRecorder) Start

Start indicates an expected call of Start.

func (*MockConnectionManagerMockRecorder) Stop

Stop indicates an expected call of Stop.

type MockProtocol

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

MockProtocol is a mock of Protocol interface.

func NewMockProtocol

func NewMockProtocol(ctrl *gomock.Controller) *MockProtocol

NewMockProtocol creates a new mock instance.

func (*MockProtocol) Configure

func (m *MockProtocol) Configure(peerID PeerID) error

Configure mocks base method.

func (*MockProtocol) Diagnostics

func (m *MockProtocol) Diagnostics() []core.DiagnosticResult

Diagnostics mocks base method.

func (*MockProtocol) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockProtocol) PeerDiagnostics

func (m *MockProtocol) PeerDiagnostics() map[PeerID]Diagnostics

PeerDiagnostics mocks base method.

func (*MockProtocol) Start

func (m *MockProtocol) Start() error

Start mocks base method.

func (*MockProtocol) Stop

func (m *MockProtocol) Stop()

Stop mocks base method.

func (*MockProtocol) Version

func (m *MockProtocol) Version() int

Version mocks base method.

type MockProtocolMockRecorder

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

MockProtocolMockRecorder is the mock recorder for MockProtocol.

func (*MockProtocolMockRecorder) Configure

func (mr *MockProtocolMockRecorder) Configure(peerID interface{}) *gomock.Call

Configure indicates an expected call of Configure.

func (*MockProtocolMockRecorder) Diagnostics

func (mr *MockProtocolMockRecorder) Diagnostics() *gomock.Call

Diagnostics indicates an expected call of Diagnostics.

func (*MockProtocolMockRecorder) PeerDiagnostics

func (mr *MockProtocolMockRecorder) PeerDiagnostics() *gomock.Call

PeerDiagnostics indicates an expected call of PeerDiagnostics.

func (*MockProtocolMockRecorder) Start

func (mr *MockProtocolMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start.

func (*MockProtocolMockRecorder) Stop

func (mr *MockProtocolMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop.

func (*MockProtocolMockRecorder) Version

func (mr *MockProtocolMockRecorder) Version() *gomock.Call

Version indicates an expected call of Version.

type NutsCommURL

type NutsCommURL struct {
	url.URL
}

NutsCommURL is the type which can be used to store a NutsComm endpoint in a DID Document. It contains the checks to validate if the endpoint is valid.

func (*NutsCommURL) UnmarshalJSON

func (s *NutsCommURL) UnmarshalJSON(bytes []byte) error

type Peer

type Peer struct {
	// ID holds the unique identifier of the peer
	ID PeerID `json:"id"`
	// Address holds the remote address of the node we're actually connected to
	Address string `json:"address"`
	// NodeDID holds the DID that the peer uses to identify its node on the network.
	// If Authenticated is true the NodeDID is verified.
	NodeDID did.DID `json:"nodedid"`
	// Authenticated is true when NodeDID is set and authentication is successful.
	Authenticated bool `json:"authenticated"`
	// Certificate presented by peer during TLS handshake.
	Certificate *x509.Certificate `json:"-" yaml:"-"`
}

Peer holds the properties of a remote node we're connected to

func (Peer) CertificateAsPem

func (p Peer) CertificateAsPem() string

func (Peer) Key

func (p Peer) Key() string

Key returns a unique key for this Peer including PeerID and NodeDID. Usable as map index, not usable for presentation.

func (Peer) String

func (p Peer) String() string

String returns the peer as string.

func (Peer) ToFields

func (p Peer) ToFields() logrus.Fields

ToFields returns the peer as a map of fields, to be used when logging the peer details.

type PeerID

type PeerID string

PeerID defines a peer's unique identifier.

func (PeerID) String

func (p PeerID) String() string

String returns the PeerID as string.

type Protocol

type Protocol interface {
	// Configure configures the Protocol implementation, must be called before Start().
	Configure(peerID PeerID) error
	// Start starts the Protocol implementation.
	Start() error
	// Stop stops the Protocol implementation.
	Stop()
	// Diagnostics collects and returns diagnostical information on the protocol.
	Diagnostics() []core.DiagnosticResult
	// PeerDiagnostics collects and returns diagnostical information on the peers the protocol is communicating with.
	PeerDiagnostics() map[PeerID]Diagnostics
	// Version returns the version of the protocol
	Version() int
}

Protocol is a self-contained process that can exchange network data (e.g. DAG transactions or private credentials) with other parties on the network.

type StreamState

type StreamState string

StreamState is a type for defining connection states

const (
	// StateConnected is passed to the connection observers when a stream state changed to connected
	StateConnected StreamState = "connected"
	// StateDisconnected is passed to the connection observers when a stream state changed to disconnected
	StateDisconnected StreamState = "disconnected"
)

type StreamStateObserverFunc

type StreamStateObserverFunc func(peer Peer, state StreamState, protocol Protocol)

StreamStateObserverFunc is a function that can be registered on the connection manager. If a stream state changes this callback will be called. It's called per protocol.

Directories

Path Synopsis
Package grpc is a generated GoMock package.
Package grpc is a generated GoMock package.
v2
Package v2 is a generated GoMock package.
Package v2 is a generated GoMock package.
gossip
Package gossip is a generated GoMock package.
Package gossip is a generated GoMock package.

Jump to

Keyboard shortcuts

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