driver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 5 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 ByNum

type ByNum struct {
	Txid string
	Code ValidationCode
}

type Committer

type Committer interface {
	// SubscribeTxStatusChanges registers a listener for transaction status changes for the passed transaction id.
	// If the transaction id is empty, the listener will be called for all transactions.
	SubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) error

	// UnsubscribeTxStatusChanges unregisters a listener for transaction status changes for the passed transaction id.
	// If the transaction id is empty, the listener will be called for all transactions.
	UnsubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) 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

	// IsFinalForParties takes in input a transaction id and an array of identities.
	// The identities are contacted to gather information about the finality of the
	// passed transaction
	IsFinalForParties(txID string, parties ...view.Identity) error
}

type Flag

type Flag = int32
const (
	VALID Flag = iota
)

type GetStateOpt

type GetStateOpt int
const (
	FromStorage GetStateOpt = iota
	FromIntermediate
	FromBoth
)

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 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 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 interface {
	GetState(namespace string, key string) ([]byte, error)
	GetStateMetadata(namespace, key string) (map[string][]byte, uint64, uint64, error)
	GetStateRangeScanIterator(namespace string, startKey string, endKey string) (driver.VersionedResultsIterator, error)
	Done()
}

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 interface {
	IsValid() error

	Clear(ns string) error

	// SetState sets the given value for the given namespace and key.
	SetState(namespace string, key string, value []byte) error

	GetState(namespace string, key string, opts ...GetStateOpt) ([]byte, error)

	// DeleteState deletes the given namespace and key
	DeleteState(namespace string, key string) error

	GetStateMetadata(namespace, key string, opts ...GetStateOpt) (map[string][]byte, error)

	// SetStateMetadata sets the metadata associated with an existing key-tuple <namespace, key>
	SetStateMetadata(namespace, key string, metadata map[string][]byte) error

	GetReadKeyAt(ns string, i int) (string, error)

	// GetReadAt returns the i-th read (key, value) in the namespace ns  of this rwset.
	// The value is loaded from the ledger, if present. If the key's version in the ledger
	// does not match the key's version in the read, then it returns an error.
	GetReadAt(ns string, i int) (string, []byte, error)

	// GetWriteAt returns the i-th write (key, value) in the namespace ns of this rwset.
	GetWriteAt(ns string, i int) (string, []byte, error)

	// NumReads returns the number of reads in the namespace ns  of this rwset.
	NumReads(ns string) int

	// NumWrites returns the number of writes in the namespace ns of this rwset.
	NumWrites(ns string) int

	// Namespaces returns the namespace labels in this rwset.
	Namespaces() []string

	AppendRWSet(raw []byte, nss ...string) error

	Bytes() ([]byte, error)

	Done()

	Equals(rws interface{}, nss ...string) error
}

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

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 TXIDStore

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

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
}

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 TxStatusChangeListener

type TxStatusChangeListener interface {
	// OnStatusChange is called when the status of a transaction changes
	OnStatusChange(txID string, status int) error
}

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

type TxidIterator

type TxidIterator interface {
	Next() (*ByNum, error)
	Close()
}

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
	HasDependencies                // Transaction is unknown but has known dependencies
)

type Vault

type Vault interface {
	GetLastTxID() (string, error)
	NewQueryExecutor() (QueryExecutor, error)
	NewRWSet(txid string) (RWSet, error)
	GetRWSet(id string, results []byte) (RWSet, error)
	Status(txID string) (ValidationCode, error)
	DiscardTx(txid string) error
	CommitTX(txid string, block uint64, indexInBloc int) 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