driver

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessControl

type AccessControl = interface{}

type BlockNum added in v0.4.0

type BlockNum = uint64

type ByNum

type ByNum struct {
	Txid string
	Code ValidationCode
}

type Committer

type Committer interface {
	Start(context context.Context) error

	// AddTransactionFilter adds a new transaction filter to this commit pipeline.
	// The transaction filter is used to check if an unknown transaction needs to be processed anyway
	AddTransactionFilter(tf TransactionFilter) error

	// AddFinalityListener registers a listener for transaction status for the passed transaction id.
	// If the status is already valid or invalid, the listener is called immediately.
	// When the listener is invoked, then it is also removed.
	// The transaction id must not be empty.
	AddFinalityListener(txID string, listener FinalityListener) error

	// RemoveFinalityListener unregisters the passed listener.
	RemoveFinalityListener(txID string, listener FinalityListener) error
}

Committer models the committer service

type DataRead

type DataRead struct {
	Key string
}

type DataTx

type DataTx interface {
	Put(db string, key string, bytes []byte, a AccessControl) error
	Get(db string, key string) ([]byte, error)
	Commit(sync bool) (string, error)
	Delete(db string, key string) error
	SignAndClose() ([]byte, error)
	AddMustSignUser(userID string)
}

type DataWrite

type DataWrite struct {
	Key   string
	Value []byte
	Acl   interface{}
}

type DeliveryService

type DeliveryService interface {
	// StartDelivery starts the delivery
	StartDelivery(context.Context) error
	// Stop stops delivery
	Stop()
}

DeliveryService models the delivery service

type Envelope

type Envelope interface {
	TxID() string
	Nonce() []byte
	Creator() []byte
	Results() []byte
	Bytes() ([]byte, error)
	FromBytes(raw []byte) error
	String() string
}

type EnvelopeService

type EnvelopeService interface {
	Exists(txid string) bool
	StoreEnvelope(txid string, env interface{}) error
	LoadEnvelope(txid string) ([]byte, error)
}

type Finality

type Finality interface {
	// IsFinal takes in input a transaction id and waits for its confirmation.
	// with the respect to the passed context that can be used to set a deadline
	// for the waiting time.
	IsFinal(ctx context.Context, txID string) error
}

type FinalityListener added in v0.4.0

type FinalityListener = driver.FinalityListener[ValidationCode]

FinalityListener is the interface that must be implemented to receive transaction status change notifications

type Flag

type Flag = int32
const (
	VALID Flag = iota
)

type GetStateOpt

type GetStateOpt = driver.GetStateOpt

type Identity

type Identity struct {
	Name string
	Cert string
	Key  string
}

type IdentityManager

type IdentityManager interface {
	Me() string
	Identity(id string) *Identity
}

type Ledger

type Ledger interface {
	GetTransactionReceipt(txId string) (Flag, error)
}

type ListenerManager added in v0.4.0

type ListenerManager driver.ListenerManager[ValidationCode]

type ListenerManagerProvider added in v0.4.0

type ListenerManagerProvider driver.ListenerManagerProvider[ValidationCode]

type LoadedDataTx

type LoadedDataTx interface {
	ID() string
	Commit() error
	CoSignAndClose() ([]byte, error)
	Reads() map[string][]*DataRead
	Writes() map[string][]*DataWrite
	MustSignUsers() []string
	SignedUsers() []string
}

type MetadataService

type MetadataService interface {
	Exists(txid string) bool
	StoreTransient(txid string, transientMap TransientMap) error
	LoadTransient(txid string) (TransientMap, error)
}

type NetworkConfig added in v0.4.0

type NetworkConfig interface {
	FinalityEventQueueWorkers() int
	FinalityNumRetries() int
	FinalitySleepTime() time.Duration
	PollingTimeout() time.Duration
}

type NetworkConfigProvider added in v0.4.0

type NetworkConfigProvider interface {
	GetNetworkConfig(network string) (NetworkConfig, error)
}

type OrionNetworkService

type OrionNetworkService interface {
	Name() string
	IdentityManager() IdentityManager
	SessionManager() SessionManager
	TransactionManager() TransactionManager
	TransactionService() TransactionService
	MetadataService() MetadataService
	Vault() Vault
	EnvelopeService() EnvelopeService
	ProcessorManager() ProcessorManager
	Finality() Finality
	Committer() Committer
	DeliveryService() DeliveryService
}

OrionNetworkService gives access to a Orion network components

type OrionNetworkServiceProvider

type OrionNetworkServiceProvider interface {
	Names() []string
	DefaultName() string
	// OrionNetworkService returns a OrionNetworkService instance for the passed parameters
	OrionNetworkService(id string) (OrionNetworkService, error)
}

type ProcessTransaction

type ProcessTransaction interface {
	Network() string
	ID() string
	FunctionAndParameters() (string, []string)
}

type Processor

type Processor interface {
	Process(req Request, tx ProcessTransaction, rws RWSet, ns string) error
}

type ProcessorManager

type ProcessorManager interface {
	AddProcessor(ns string, processor Processor) error
	SetDefaultProcessor(processor Processor) error
	ProcessByID(txid string) error
}

type Query

type Query interface {
	// GetDataByRange executes a range query on a given database. The startKey is
	// inclusive but endKey is not. When the startKey is an empty string, it denotes
	// `fetch keys from the beginning` while an empty endKey denotes `fetch keys till the
	// the end`. The limit denotes the number of records to be fetched in total. However,
	// when the limit is set to 0, it denotes no limit. The iterator returned by
	// GetDataByRange is used to retrieve the records.
	GetDataByRange(dbName, startKey, endKey string, limit uint64) (QueryIterator, error)
}

Query allows the developer to perform queries over the orion database

type QueryExecutor

type QueryExecutor = vault.QueryExecutor

type QueryIterator

type QueryIterator interface {
	// Next returns the next record. If there is no more records, it would return a nil value
	// and a false value.
	Next() (string, []byte, uint64, uint64, bool, error)
}

QueryIterator is an iterator over the results of a query

type RWSExtractor

type RWSExtractor interface {
	Extract(tx []byte) (ProcessTransaction, RWSet, error)
}

type RWSet

type RWSet = driver.RWSet

type Request

type Request interface {
	ID() string
}

type SeekEnd

type SeekEnd struct{}

type SeekPos

type SeekPos struct {
	Txid string
}

type SeekStart

type SeekStart struct{}

type Session

type Session interface {
	// DataTx returns a data transaction for the passed id
	DataTx(txID string) (DataTx, error)
	LoadDataTx(env interface{}) (LoadedDataTx, error)
	Ledger() (Ledger, error)
	Query() (Query, error)
}

Session let the developer access orion Any implementation must be thread-safe

type SessionManager

type SessionManager interface {
	// NewSession creates a new session to orion using the passed identity
	NewSession(id string) (Session, error)
}

SessionManager is a session manager that allows the developer to access orion directly

type StatusReporter added in v0.4.0

type StatusReporter interface {
	Status(txID string) (ValidationCode, string, []string, error)
}

type TXIDStore

type TXIDStore interface {
	GetLastTxID() (string, error)
	Iterator(pos interface{}) (TxidIterator, error)
}

type TransactionFilter added in v0.4.0

type TransactionFilter = driver.TransactionFilter

TransactionFilter is used to filter unknown transactions. If the filter accepts, the transaction is processed by the commit pipeline anyway.

type TransactionManager

type TransactionManager interface {
	ComputeTxID(id *TxID) string
	NewEnvelope() Envelope
	CommitEnvelope(session Session, envelope Envelope) error
}

type TransactionService

type TransactionService interface {
	Exists(txid string) bool
	StoreTransaction(txid string, raw []byte) error
	LoadTransaction(txid string) ([]byte, error)
}

type TransactionStatusChanged

type TransactionStatusChanged struct {
	ThisTopic         string
	TxID              string
	VC                ValidationCode
	ValidationMessage string
}

TransactionStatusChanged is the message sent when the status of a transaction changes

func (*TransactionStatusChanged) Message

func (t *TransactionStatusChanged) Message() interface{}

Message returns the message itself

func (*TransactionStatusChanged) Topic

func (t *TransactionStatusChanged) Topic() string

Topic returns the topic for the message

type TransientMap

type TransientMap map[string][]byte

type TxID

type TxID struct {
	Nonce   []byte
	Creator []byte
}

type TxNum added in v0.4.0

type TxNum = uint64

type TxValidationStatus added in v0.4.0

type TxValidationStatus = driver2.TxValidationStatus[ValidationCode]

type TxidIterator

type TxidIterator = collections.Iterator[*ByNum]

type ValidationCode

type ValidationCode = int
const (
	Valid   ValidationCode // Transaction is valid and committed
	Invalid                // Transaction is invalid and has been discarded
	Busy                   // Transaction does not yet have a validity state
	Unknown                // Transaction is unknown
)

type ValidationCodeProvider added in v0.4.0

type ValidationCodeProvider struct{}

func (*ValidationCodeProvider) Busy added in v0.4.0

func (*ValidationCodeProvider) FromInt32 added in v0.4.0

func (p *ValidationCodeProvider) FromInt32(code int32) ValidationCode

func (*ValidationCodeProvider) Invalid added in v0.4.0

func (*ValidationCodeProvider) NotFound added in v0.4.0

func (p *ValidationCodeProvider) NotFound() ValidationCode

func (*ValidationCodeProvider) ToInt32 added in v0.4.0

func (p *ValidationCodeProvider) ToInt32(code ValidationCode) int32

func (*ValidationCodeProvider) Unknown added in v0.4.0

func (*ValidationCodeProvider) Valid added in v0.4.0

type Vault

type Vault interface {
	driver2.Vault[ValidationCode]
	GetLastTxID() (string, error)
}

Vault models a key value store that can be updated by committing rwsets

Jump to

Keyboard shortcuts

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