Documentation
¶
Overview ¶
Package network is a generated GoMock package.
Index ¶
- Constants
- type Config
- type EventType
- type MockTransactions
- func (m *MockTransactions) AddressBook() []transport.Contact
- func (m *MockTransactions) CleanupSubscriberEvents(subcriberName, errorPrefix string) error
- func (m *MockTransactions) CreateTransaction(ctx context.Context, spec Template) (dag.Transaction, error)
- func (m *MockTransactions) DiscoverServices(updatedDID did.DID)
- func (m *MockTransactions) EXPECT() *MockTransactionsMockRecorder
- func (m *MockTransactions) GetTransaction(transactionRef hash.SHA256Hash) (dag.Transaction, error)
- func (m *MockTransactions) GetTransactionPayload(transactionRef hash.SHA256Hash) ([]byte, error)
- func (m *MockTransactions) ListTransactionsInRange(startInclusive, endExclusive uint32) ([]dag.Transaction, error)
- func (m *MockTransactions) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
- func (m *MockTransactions) Reprocess(ctx context.Context, contentType string) (*ReprocessReport, error)
- func (m *MockTransactions) Subscribe(name string, receiver dag.ReceiverFn, filters ...SubscriberOption) error
- func (m *MockTransactions) Subscribers() []dag.Notifier
- func (m *MockTransactions) WithPersistency() SubscriberOption
- type MockTransactionsMockRecorder
- func (mr *MockTransactionsMockRecorder) AddressBook() *gomock.Call
- func (mr *MockTransactionsMockRecorder) CleanupSubscriberEvents(subcriberName, errorPrefix interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) CreateTransaction(ctx, spec interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) DiscoverServices(updatedDID interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) GetTransaction(transactionRef interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) GetTransactionPayload(transactionRef interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) ListTransactionsInRange(startInclusive, endExclusive interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) PeerDiagnostics() *gomock.Call
- func (mr *MockTransactionsMockRecorder) Reprocess(ctx, contentType interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) Subscribe(name, receiver interface{}, filters ...interface{}) *gomock.Call
- func (mr *MockTransactionsMockRecorder) Subscribers() *gomock.Call
- func (mr *MockTransactionsMockRecorder) WithPersistency() *gomock.Call
- type Network
- func (n *Network) AddressBook() []transport.Contact
- func (n *Network) CheckHealth() map[string]core.Health
- func (n *Network) CleanupSubscriberEvents(subscriberName, errorPrefix string) error
- func (n *Network) Config() interface{}
- func (n *Network) Configure(config core.ServerConfig) error
- func (n *Network) CreateTransaction(ctx context.Context, template Template) (dag.Transaction, error)
- func (n *Network) Diagnostics() []core.DiagnosticResult
- func (n *Network) DiscoverServices(updatedDID did.DID)
- func (n *Network) GetTransaction(transactionRef hash.SHA256Hash) (dag.Transaction, error)
- func (n *Network) GetTransactionPayload(transactionRef hash.SHA256Hash) ([]byte, error)
- func (n *Network) ListTransactionsInRange(startInclusive uint32, endExclusive uint32) ([]dag.Transaction, error)
- func (n *Network) Migrate() error
- func (n *Network) Name() string
- func (n *Network) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
- func (n *Network) Reprocess(ctx context.Context, contentType string) (*ReprocessReport, error)
- func (n *Network) Shutdown() error
- func (n *Network) Start() error
- func (n *Network) Subscribe(name string, subscriber dag.ReceiverFn, options ...SubscriberOption) error
- func (n *Network) Subscribers() []dag.Notifier
- func (n *Network) WithPersistency() SubscriberOption
- type Receiver
- type ReprocessReport
- type SubscriberOption
- type Template
- type Transactions
Constants ¶
const AnyPayloadType = "*"
AnyPayloadType is a wildcard that matches with any payload type.
const MaxReprocessBufferSize = 1000000
MaxReprocessBufferSize is the maximum number of events for Nats resulting from a Reprocess
const (
// ModuleName specifies the name of this module.
ModuleName = "Network"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Socket address for gRPC to listen on
GrpcAddr string `koanf:"grpcaddr"`
// ConnectionTimeout specifies the timeout before an outbound connection attempt times out (in milliseconds).
ConnectionTimeout int `koanf:"connectiontimeout"`
// MaxBackoff specifies the maximum backoff for outbound connections
MaxBackoff time.Duration `koanf:"maxbackoff"`
// IdleTimeout specifies the period without any received message after which a connection to a peer is closed.
// Peers send gossip and diagnostics messages at a fixed interval, so a silent connection is a dead one. Zero disables the check.
IdleTimeout time.Duration `koanf:"idletimeout"`
// Public address of this nodes other nodes can use to connect to this node.
BootstrapNodes []string `koanf:"bootstrapnodes"`
// Protocols is the list of network protocols to enable on the server. They are specified by version (v1, v2).
Protocols []int `koanf:"protocols"`
// EnableDiscovery tells the node to automatically connect to other nodes
EnableDiscovery bool `koanf:"enablediscovery"`
// NodeDID defines the DID of the organization that operates this node, typically a vendor for EPD software.
// It is used to identify it on the network.
NodeDID string `koanf:"nodedid"`
// ProtocolV2 specifies config for protocol v2
ProtocolV2 v2.Config `koanf:"v2"`
}
Config holds the config for Transactions
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default NetworkEngine configuration.
func TestNetworkConfig ¶
func TestNetworkConfig() Config
TestNetworkConfig creates new network config with a test directory as data path.
func (Config) IsProtocolEnabled ¶
IsProtocolEnabled returns true if the protocol is enabled, otherwise false.
type EventType ¶
type EventType string
EventType defines a type for specifying the kind of events that can be published/subscribed on the Network.
type MockTransactions ¶
type MockTransactions struct {
// contains filtered or unexported fields
}
MockTransactions is a mock of Transactions interface.
func NewMockTransactions ¶
func NewMockTransactions(ctrl *gomock.Controller) *MockTransactions
NewMockTransactions creates a new mock instance.
func (*MockTransactions) AddressBook ¶
func (m *MockTransactions) AddressBook() []transport.Contact
AddressBook mocks base method.
func (*MockTransactions) CleanupSubscriberEvents ¶
func (m *MockTransactions) CleanupSubscriberEvents(subcriberName, errorPrefix string) error
CleanupSubscriberEvents mocks base method.
func (*MockTransactions) CreateTransaction ¶
func (m *MockTransactions) CreateTransaction(ctx context.Context, spec Template) (dag.Transaction, error)
CreateTransaction mocks base method.
func (*MockTransactions) DiscoverServices ¶
func (m *MockTransactions) DiscoverServices(updatedDID did.DID)
DiscoverServices mocks base method.
func (*MockTransactions) EXPECT ¶
func (m *MockTransactions) EXPECT() *MockTransactionsMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTransactions) GetTransaction ¶
func (m *MockTransactions) GetTransaction(transactionRef hash.SHA256Hash) (dag.Transaction, error)
GetTransaction mocks base method.
func (*MockTransactions) GetTransactionPayload ¶
func (m *MockTransactions) GetTransactionPayload(transactionRef hash.SHA256Hash) ([]byte, error)
GetTransactionPayload mocks base method.
func (*MockTransactions) ListTransactionsInRange ¶
func (m *MockTransactions) ListTransactionsInRange(startInclusive, endExclusive uint32) ([]dag.Transaction, error)
ListTransactionsInRange mocks base method.
func (*MockTransactions) PeerDiagnostics ¶
func (m *MockTransactions) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
PeerDiagnostics mocks base method.
func (*MockTransactions) Reprocess ¶
func (m *MockTransactions) Reprocess(ctx context.Context, contentType string) (*ReprocessReport, error)
Reprocess mocks base method.
func (*MockTransactions) Subscribe ¶
func (m *MockTransactions) Subscribe(name string, receiver dag.ReceiverFn, filters ...SubscriberOption) error
Subscribe mocks base method.
func (*MockTransactions) Subscribers ¶
func (m *MockTransactions) Subscribers() []dag.Notifier
Subscribers mocks base method.
func (*MockTransactions) WithPersistency ¶
func (m *MockTransactions) WithPersistency() SubscriberOption
WithPersistency mocks base method.
type MockTransactionsMockRecorder ¶
type MockTransactionsMockRecorder struct {
// contains filtered or unexported fields
}
MockTransactionsMockRecorder is the mock recorder for MockTransactions.
func (*MockTransactionsMockRecorder) AddressBook ¶
func (mr *MockTransactionsMockRecorder) AddressBook() *gomock.Call
AddressBook indicates an expected call of AddressBook.
func (*MockTransactionsMockRecorder) CleanupSubscriberEvents ¶
func (mr *MockTransactionsMockRecorder) CleanupSubscriberEvents(subcriberName, errorPrefix interface{}) *gomock.Call
CleanupSubscriberEvents indicates an expected call of CleanupSubscriberEvents.
func (*MockTransactionsMockRecorder) CreateTransaction ¶
func (mr *MockTransactionsMockRecorder) CreateTransaction(ctx, spec interface{}) *gomock.Call
CreateTransaction indicates an expected call of CreateTransaction.
func (*MockTransactionsMockRecorder) DiscoverServices ¶
func (mr *MockTransactionsMockRecorder) DiscoverServices(updatedDID interface{}) *gomock.Call
DiscoverServices indicates an expected call of DiscoverServices.
func (*MockTransactionsMockRecorder) GetTransaction ¶
func (mr *MockTransactionsMockRecorder) GetTransaction(transactionRef interface{}) *gomock.Call
GetTransaction indicates an expected call of GetTransaction.
func (*MockTransactionsMockRecorder) GetTransactionPayload ¶
func (mr *MockTransactionsMockRecorder) GetTransactionPayload(transactionRef interface{}) *gomock.Call
GetTransactionPayload indicates an expected call of GetTransactionPayload.
func (*MockTransactionsMockRecorder) ListTransactionsInRange ¶
func (mr *MockTransactionsMockRecorder) ListTransactionsInRange(startInclusive, endExclusive interface{}) *gomock.Call
ListTransactionsInRange indicates an expected call of ListTransactionsInRange.
func (*MockTransactionsMockRecorder) PeerDiagnostics ¶
func (mr *MockTransactionsMockRecorder) PeerDiagnostics() *gomock.Call
PeerDiagnostics indicates an expected call of PeerDiagnostics.
func (*MockTransactionsMockRecorder) Reprocess ¶
func (mr *MockTransactionsMockRecorder) Reprocess(ctx, contentType interface{}) *gomock.Call
Reprocess indicates an expected call of Reprocess.
func (*MockTransactionsMockRecorder) Subscribe ¶
func (mr *MockTransactionsMockRecorder) Subscribe(name, receiver interface{}, filters ...interface{}) *gomock.Call
Subscribe indicates an expected call of Subscribe.
func (*MockTransactionsMockRecorder) Subscribers ¶
func (mr *MockTransactionsMockRecorder) Subscribers() *gomock.Call
Subscribers indicates an expected call of Subscribers.
func (*MockTransactionsMockRecorder) WithPersistency ¶
func (mr *MockTransactionsMockRecorder) WithPersistency() *gomock.Call
WithPersistency indicates an expected call of WithPersistency.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network implements Transactions interface and Engine functions.
func NewNetworkInstance ¶
func NewNetworkInstance( config Config, store didstore.Store, keyStore crypto.KeyStore, eventPublisher events.Event, storeProvider storage.Provider, pkiValidator pki.Validator, ) *Network
NewNetworkInstance creates a new Network engine instance.
func NewTestNetworkInstance ¶
NewTestNetworkInstance creates a new Transactions instance that writes it data to a test directory.
func (*Network) AddressBook ¶
func (*Network) CheckHealth ¶
CheckHealth performs health checks for the network engine.
func (*Network) CleanupSubscriberEvents ¶
func (*Network) Config ¶
func (n *Network) Config() interface{}
Config returns a pointer to the actual config of the module.
func (*Network) Configure ¶
func (n *Network) Configure(config core.ServerConfig) error
Configure configures the Network subsystem
func (*Network) CreateTransaction ¶
func (n *Network) CreateTransaction(ctx context.Context, template Template) (dag.Transaction, error)
CreateTransaction creates a new transaction from the given template.
func (*Network) Diagnostics ¶
func (n *Network) Diagnostics() []core.DiagnosticResult
Diagnostics collects and returns diagnostics for the Network engine.
func (*Network) DiscoverServices ¶
func (*Network) GetTransaction ¶
func (n *Network) GetTransaction(transactionRef hash.SHA256Hash) (dag.Transaction, error)
GetTransaction retrieves the transaction for the given reference. If the transaction is not known, an error is returned.
func (*Network) GetTransactionPayload ¶
func (n *Network) GetTransactionPayload(transactionRef hash.SHA256Hash) ([]byte, error)
GetTransactionPayload retrieves the transaction Payload for the given transaction. If the transaction or Payload is not found nil is returned.
func (*Network) ListTransactionsInRange ¶
func (n *Network) ListTransactionsInRange(startInclusive uint32, endExclusive uint32) ([]dag.Transaction, error)
ListTransactionsInRange returns all transactions known to this Network instance with lamport clock value between startInclusive and endExclusive.
func (*Network) PeerDiagnostics ¶
func (n *Network) PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
PeerDiagnostics returns a map containing diagnostic information of the node's peers. The key contains the remote peer's ID.
func (*Network) Subscribe ¶
func (n *Network) Subscribe(name string, subscriber dag.ReceiverFn, options ...SubscriberOption) error
Subscribe registers a receiverFn with specific options. The receiver is called when a transaction is added to the DAG. It's only called if the given dag.NotificationFilter's match.
func (*Network) Subscribers ¶
func (*Network) WithPersistency ¶
func (n *Network) WithPersistency() SubscriberOption
WithPersistency creates the SubscriberOption that creates the NotifierOption for persistency with the correct DAG KVStore
type Receiver ¶
type Receiver func(transaction dag.Transaction, payload []byte) error
Receiver defines a callback function for processing transactions/payloads received by the DAG.
type ReprocessReport ¶
type ReprocessReport struct {
}
ReprocessReport describes the reprocess exection.
type SubscriberOption ¶
type SubscriberOption func() dag.NotifierOption
SubscriberOption creates a dag.NotifierOption
func WithSelectionFilter ¶
func WithSelectionFilter(filter dag.NotificationFilter) SubscriberOption
WithSelectionFilter creates a SubscriberOption that creates a dag.NotifierOption with the given filter
type Template ¶
type Template struct {
Key crypto.Key
Payload []byte
Type string
AttachKey bool
Timestamp time.Time
AdditionalPrevs []hash.SHA256Hash
Participants dag.PAL
}
Template is used to build a spec for new transactions.
func TransactionTemplate ¶
TransactionTemplate creates a new Template with the given required properties.
func (Template) WithAdditionalPrevs ¶
func (t Template) WithAdditionalPrevs(additionalPrevs []hash.SHA256Hash) Template
WithAdditionalPrevs specifies additional `prev` hashes, which are added to the set of prevs of the new transaction (current HEADs of the DAG). This is used to update entities that are mutable. By referring to the previous transaction of an entity, conflicts through parallel updates can be detected.
func (Template) WithAttachKey ¶
WithAttachKey specifies that the signing key must be attached to the transaction, because it wasn't published before.
func (Template) WithPrivate ¶
WithPrivate specifies that the transaction is private, and should only be readable by the given Participants.
type Transactions ¶
type Transactions interface {
// Subscribe registers a receiver for the specified transaction type.
// A filter can be passed as option with the WithSelectionFilter function.
// The events for the receiver can be made persistent by passing the network.WithPersistency() option.
Subscribe(name string, receiver dag.ReceiverFn, filters ...SubscriberOption) error
// Subscribers returns the list of notifiers on the DAG that emit events to subscribers.
Subscribers() []dag.Notifier
// CleanupSubscriberEvents removes events. Example use is cleaning up events that errored but should be removed due to a bugfix.
CleanupSubscriberEvents(subcriberName, errorPrefix string) error
// GetTransactionPayload retrieves the transaction Payload for the given transaction.
// If the transaction or Payload is not found, dag.ErrPayloadNotFound is returned.
GetTransactionPayload(transactionRef hash.SHA256Hash) ([]byte, error)
// GetTransaction retrieves the transaction for the given reference.
// If the transaction is not found, a dag.ErrTransactionNotFound is returned.
GetTransaction(transactionRef hash.SHA256Hash) (dag.Transaction, error)
// CreateTransaction creates a new transaction according to the given spec.
CreateTransaction(ctx context.Context, spec Template) (dag.Transaction, error)
// ListTransactionsInRange returns all transactions known to this Network instance with lamport clock value between startInclusive and endExclusive.
// endExclusive must be larger than startInclusive.
ListTransactionsInRange(startInclusive uint32, endExclusive uint32) ([]dag.Transaction, error)
// PeerDiagnostics returns a map containing diagnostic information of the node's peers. The key contains the remote peer's ID.
PeerDiagnostics() map[transport.PeerID]transport.Diagnostics
// Reprocess walks the DAG and publishes all transactions matching the contentType via Nats
Reprocess(ctx context.Context, contentType string) (*ReprocessReport, error)
// WithPersistency returns a SubscriberOption for persistency. It allows the DAG KVStore to be used as persistent store for notifications.
// The notifications will then have ACID properties
WithPersistency() SubscriberOption
// DiscoverServices should be called by the VDR to let the network know it has processed and verified a document (update) for the DID.
DiscoverServices(updatedDID did.DID)
// AddressBook returns the list of contacts in the address book.
AddressBook() []transport.Contact
}
Transactions is the interface that defines the API for creating, reading and subscribing to Nuts Network transactions.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
api
|
|
|
v1
Package v1 provides primitives to interact with the openapi HTTP API.
|
Package v1 provides primitives to interact with the openapi HTTP API. |
|
Package dag is a generated GoMock package.
|
Package dag is a generated GoMock package. |
|
Package transport is a generated GoMock package.
|
Package transport is a generated GoMock package. |
|
grpc
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. |
|
v2/gossip
Package gossip is a generated GoMock package.
|
Package gossip is a generated GoMock package. |