orion

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 14 Imported by: 5

Documentation

Index

Constants

View Source
const (
	VALID = driver.VALID
	INVALID_MVCC_CONFLICT_WITHIN_BLOCK
	INVALID_MVCC_CONFLICT_WITH_COMMITTED_STATE
	INVALID_DATABASE_DOES_NOT_EXIST
	INVALID_NO_PERMISSION
	INVALID_INCORRECT_ENTRIES
	INVALID_UNAUTHORISED
	INVALID_MISSING_SIGNATURE
)

Variables

This section is empty.

Functions

func GetOrionNetworkNames

func GetOrionNetworkNames(sp view2.ServiceProvider) []string

Types

type AccessControl

type AccessControl = driver.AccessControl

type Committer

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

Committer models the committer service

func NewCommitter

func NewCommitter(c driver.Committer) *Committer

func (*Committer) SubscribeTxStatusChanges

func (c *Committer) SubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) error

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.

func (*Committer) UnsubscribeTxStatusChanges

func (c *Committer) UnsubscribeTxStatusChanges(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.

type DataRead

type DataRead = driver.DataRead

type DataWrite

type DataWrite = driver.DataWrite

type Envelope

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

func (*Envelope) Bytes

func (e *Envelope) Bytes() ([]byte, error)

func (*Envelope) Creator

func (e *Envelope) Creator() []byte

func (*Envelope) FromBytes

func (e *Envelope) FromBytes(raw []byte) error

func (*Envelope) MarshalJSON

func (e *Envelope) MarshalJSON() ([]byte, error)

func (*Envelope) Nonce

func (e *Envelope) Nonce() []byte

func (*Envelope) Results

func (e *Envelope) Results() []byte

func (*Envelope) String

func (e *Envelope) String() string

func (*Envelope) TxID

func (e *Envelope) TxID() string

func (*Envelope) UnmarshalJSON

func (e *Envelope) UnmarshalJSON(raw []byte) error

type EnvelopeService

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

func (*EnvelopeService) Exists

func (e *EnvelopeService) Exists(txid string) bool

func (*EnvelopeService) LoadEnvelope

func (e *EnvelopeService) LoadEnvelope(txid string) ([]byte, error)

func (*EnvelopeService) StoreEnvelope

func (e *EnvelopeService) StoreEnvelope(txid string, env interface{}) error

type Finality

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

func (*Finality) IsFinal

func (c *Finality) IsFinal(ctx context.Context, txID string) error

func (*Finality) IsFinalForParties

func (c *Finality) IsFinalForParties(txID string, parties ...view.Identity) error

type Flag

type Flag = driver.Flag

type GetStateOpt

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

type IdentityManager

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

func (*IdentityManager) Me

func (im *IdentityManager) Me() string

type Ledger

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

func (*Ledger) GetTransactionByID

func (l *Ledger) GetTransactionByID(txID string) (*ProcessedTransaction, error)

type LoadedTransaction

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

func (*LoadedTransaction) CoSignAndClose

func (t *LoadedTransaction) CoSignAndClose() ([]byte, error)

func (*LoadedTransaction) Commit

func (t *LoadedTransaction) Commit() error

func (*LoadedTransaction) ID

func (t *LoadedTransaction) ID() string

func (*LoadedTransaction) MustSignUsers

func (t *LoadedTransaction) MustSignUsers() []string

func (*LoadedTransaction) Reads

func (t *LoadedTransaction) Reads() map[string][]*DataRead

func (*LoadedTransaction) SignedUsers

func (t *LoadedTransaction) SignedUsers() []string

func (*LoadedTransaction) Writes

func (t *LoadedTransaction) Writes() map[string][]*DataWrite

type MetadataService

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

func (*MetadataService) Exists

func (m *MetadataService) Exists(txid string) bool

func (*MetadataService) LoadTransient

func (m *MetadataService) LoadTransient(txid string) (TransientMap, error)

func (*MetadataService) StoreTransient

func (m *MetadataService) StoreTransient(txid string, transientMap TransientMap) error

type NetworkService

type NetworkService struct {
	SP view2.ServiceProvider
	// contains filtered or unexported fields
}

NetworkService models a Orion Network

func GetDefaultONS

func GetDefaultONS(sp view2.ServiceProvider) *NetworkService

GetDefaultONS returns the default Orion Network Service

func GetOrionNetworkService

func GetOrionNetworkService(sp view2.ServiceProvider, id string) *NetworkService

GetOrionNetworkService returns the Orion Network Service for the passed id, nil if not found

func (*NetworkService) Committer

func (n *NetworkService) Committer() *Committer

Committer returns the committer service

func (*NetworkService) EnvelopeService

func (n *NetworkService) EnvelopeService() *EnvelopeService

func (*NetworkService) Finality

func (n *NetworkService) Finality() *Finality

func (*NetworkService) IdentityManager

func (n *NetworkService) IdentityManager() *IdentityManager

func (*NetworkService) MetadataService

func (n *NetworkService) MetadataService() *MetadataService

func (*NetworkService) Name

func (n *NetworkService) Name() string

Name of this network

func (*NetworkService) ProcessorManager

func (n *NetworkService) ProcessorManager() *ProcessorManager

ProcessorManager returns the processor manager of this network

func (*NetworkService) SessionManager

func (n *NetworkService) SessionManager() *SessionManager

func (*NetworkService) TransactionManager

func (n *NetworkService) TransactionManager() *TransactionManager

TransactionManager returns the transaction manager of this network

func (*NetworkService) Vault

func (n *NetworkService) Vault() *Vault

type NetworkServiceProvider

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

func GetNetworkServiceProvider

func GetNetworkServiceProvider(sp view2.ServiceProvider) *NetworkServiceProvider

func NewNetworkServiceProvider

func NewNetworkServiceProvider(sp view2.ServiceProvider) *NetworkServiceProvider

func (*NetworkServiceProvider) NetworkService

func (nsp *NetworkServiceProvider) NetworkService(id string) (*NetworkService, error)

type ProcessTransaction

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

type ProcessedTransaction

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

ProcessedTransaction models a transaction that has been processed by Fabric

func (*ProcessedTransaction) TxID

func (pt *ProcessedTransaction) TxID() string

TxID returns the transaction's id

func (*ProcessedTransaction) ValidationCode

func (pt *ProcessedTransaction) ValidationCode() Flag

ValidationCode returns the transaction's validation code

type Processor

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

type ProcessorManager

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

func (*ProcessorManager) AddProcessor

func (pm *ProcessorManager) AddProcessor(ns string, p Processor) error

func (*ProcessorManager) SetDefaultProcessor

func (pm *ProcessorManager) SetDefaultProcessor(p Processor) error

type QueryExecutor

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

func (*QueryExecutor) Done

func (qe *QueryExecutor) Done()

func (*QueryExecutor) GetState

func (qe *QueryExecutor) GetState(namespace string, key string) ([]byte, error)

func (*QueryExecutor) GetStateMetadata

func (qe *QueryExecutor) GetStateMetadata(namespace, key string) (map[string][]byte, uint64, uint64, error)

func (*QueryExecutor) GetStateRangeScanIterator

func (qe *QueryExecutor) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (*ResultsIterator, error)

type QueryIterator

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

func (*QueryIterator) Next

func (i *QueryIterator) Next() (string, []byte, uint64, uint64, bool, error)

type RWSet

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

func (*RWSet) AppendRWSet

func (r *RWSet) AppendRWSet(raw []byte, nss ...string) error

func (*RWSet) Bytes

func (r *RWSet) Bytes() ([]byte, error)

func (*RWSet) Clear

func (r *RWSet) Clear(ns string) error

func (*RWSet) DeleteState

func (r *RWSet) DeleteState(namespace string, key string) error

DeleteState deletes the given namespace and key

func (*RWSet) Done

func (r *RWSet) Done()

func (*RWSet) Equals

func (r *RWSet) Equals(rws interface{}, nss ...string) error

func (*RWSet) GetReadAt

func (r *RWSet) GetReadAt(ns string, i int) (string, []byte, 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.

func (*RWSet) GetReadKeyAt

func (r *RWSet) GetReadKeyAt(ns string, i int) (string, error)

func (*RWSet) GetState

func (r *RWSet) GetState(namespace string, key string, opts ...GetStateOpt) ([]byte, error)

func (*RWSet) GetStateMetadata

func (r *RWSet) GetStateMetadata(namespace, key string, opts ...GetStateOpt) (map[string][]byte, error)

func (*RWSet) GetWriteAt

func (r *RWSet) GetWriteAt(ns string, i int) (string, []byte, error)

GetWriteAt returns the i-th write (key, value) in the namespace ns of this rwset.

func (*RWSet) IsValid

func (r *RWSet) IsValid() error

func (*RWSet) Namespaces

func (r *RWSet) Namespaces() []string

Namespaces returns the namespace labels in this rwset.

func (*RWSet) NumReads

func (r *RWSet) NumReads(ns string) int

NumReads returns the number of reads in the namespace ns of this rwset.

func (*RWSet) NumWrites

func (r *RWSet) NumWrites(ns string) int

NumWrites returns the number of writes in the namespace ns of this rwset.

func (*RWSet) RWS

func (r *RWSet) RWS() driver.RWSet

func (*RWSet) SetState

func (r *RWSet) SetState(namespace string, key string, value []byte) error

SetState sets the given value for the given namespace and key.

func (*RWSet) SetStateMetadata

func (r *RWSet) SetStateMetadata(namespace, key string, metadata map[string][]byte) error

SetStateMetadata sets the metadata associated with an existing key-tuple <namespace, key>

type Read

type Read struct {
	Key          string
	Raw          []byte
	Block        uint64
	IndexInBlock int
}

func (*Read) K

func (v *Read) K() string

func (*Read) V

func (v *Read) V() []byte

type Request

type Request interface {
	ID() string
}

type ResultsIterator

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

ResultsIterator models an query result iterator

func (*ResultsIterator) Close

func (r *ResultsIterator) Close()

Close releases resources occupied by the iterator

func (*ResultsIterator) Next

func (r *ResultsIterator) Next() (*Read, error)

Next returns the next item in the result set. The `QueryResult` is expected to be nil when the iterator gets exhausted

type Session

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

func (*Session) Ledger

func (s *Session) Ledger() (*Ledger, error)

func (*Session) QueryExecutor

func (s *Session) QueryExecutor(db string) (*SessionQueryExecutor, error)

type SessionManager

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

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

func (*SessionManager) NewSession

func (sm *SessionManager) NewSession(id string) (*Session, error)

NewSession creates a new session to orion using the passed identity

type SessionQueryExecutor

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

func (*SessionQueryExecutor) Get

func (d *SessionQueryExecutor) Get(key string) ([]byte, error)

func (*SessionQueryExecutor) GetDataByRange

func (d *SessionQueryExecutor) GetDataByRange(startKey, endKey string, limit uint64) (*QueryIterator, error)

GetDataByRange executes a range query. 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.

type Transaction

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

func (*Transaction) AddMustSignUser

func (d *Transaction) AddMustSignUser(userID string)

func (*Transaction) Commit

func (d *Transaction) Commit(sync bool) (string, error)

func (*Transaction) Delete

func (d *Transaction) Delete(db string, key string) error

func (*Transaction) Get

func (d *Transaction) Get(db string, key string) ([]byte, error)

func (*Transaction) Put

func (d *Transaction) Put(db string, key string, bytes []byte, a AccessControl) error

func (*Transaction) SignAndClose

func (d *Transaction) SignAndClose() ([]byte, error)

type TransactionManager

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

func (*TransactionManager) CommitEnvelope

func (t *TransactionManager) CommitEnvelope(session *Session, envelope *Envelope) error

func (*TransactionManager) ComputeTxID

func (t *TransactionManager) ComputeTxID(id *TxID) string

func (*TransactionManager) NewEnvelope

func (t *TransactionManager) NewEnvelope() *Envelope

func (*TransactionManager) NewLoadedTransaction

func (t *TransactionManager) NewLoadedTransaction(env []byte, creator string) (*LoadedTransaction, error)

func (*TransactionManager) NewTransaction

func (t *TransactionManager) NewTransaction(txID string, creator string) (*Transaction, error)

type TransientMap

type TransientMap map[string][]byte

func (TransientMap) Exists

func (m TransientMap) Exists(key string) bool

func (TransientMap) Get

func (m TransientMap) Get(id string) []byte

func (TransientMap) GetState

func (m TransientMap) GetState(key string, state interface{}) error

func (TransientMap) IsEmpty

func (m TransientMap) IsEmpty() bool

func (TransientMap) Set

func (m TransientMap) Set(key string, raw []byte) error

func (TransientMap) SetState

func (m TransientMap) SetState(key string, state interface{}) error

type TxID

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

func (*TxID) String

func (t *TxID) String() string

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 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 struct {
	// contains filtered or unexported fields
}

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

func (*Vault) CommitTX

func (v *Vault) CommitTX(txid string, block uint64, indexInBloc int) error

func (*Vault) DiscardTx

func (v *Vault) DiscardTx(txID string) error

func (*Vault) GetLastTxID

func (v *Vault) GetLastTxID() (string, error)

GetLastTxID returns the last transaction id committed

func (*Vault) GetRWSet

func (v *Vault) GetRWSet(id string, results []byte) (*RWSet, error)

func (*Vault) NewQueryExecutor

func (v *Vault) NewQueryExecutor() (*QueryExecutor, error)

func (*Vault) NewRWSet

func (v *Vault) NewRWSet(txid string) (*RWSet, error)

func (*Vault) Status

func (v *Vault) Status(txID string) (ValidationCode, error)

func (*Vault) StoreEnvelope

func (v *Vault) StoreEnvelope(id string, env []byte) error

func (*Vault) StoreTransaction

func (v *Vault) StoreTransaction(id string, raw []byte) error

func (*Vault) StoreTransient

func (v *Vault) StoreTransient(id string, tm TransientMap) error

Directories

Path Synopsis
generic/vault/mocks
Code generated by counterfeiter.
Code generated by counterfeiter.
services
db
otx

Jump to

Keyboard shortcuts

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