network

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Drivers

func Drivers() []string

Drivers returns a sorted list of the names of the registered drivers.

func Register

func Register(name string, driver driver.Driver)

Register makes a kvs driver available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

Types

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 GetFunc

type GetFunc func() (view.Identity, []byte, error)

type Ledger

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

func (*Ledger) Status

func (l *Ledger) Status(id string) (ValidationCode, error)

type LocalMembership

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

func (*LocalMembership) AnonymousIdentity

func (l *LocalMembership) AnonymousIdentity() view.Identity

func (*LocalMembership) DefaultIdentity

func (l *LocalMembership) DefaultIdentity() view.Identity

type Network

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

Network provides access to the remote network

func GetInstance

func GetInstance(sp view2.ServiceProvider, network, channel string) *Network

GetInstance returns a network instance for the given network and channel

func (*Network) AnonymousIdentity

func (n *Network) AnonymousIdentity() view.Identity

AnonymousIdentity returns a fresh anonymous identity

func (*Network) AreTokensSpent

func (n *Network) AreTokensSpent(context view.Context, namespace string, IDs []string) ([]bool, error)

AreTokensSpent retrieves the spent flag for the passed ids

func (*Network) Broadcast

func (n *Network) Broadcast(context context.Context, blob interface{}) error

Broadcast sends the given blob to the network

func (*Network) Channel

func (n *Network) Channel() string

Channel returns the channel name

func (*Network) ComputeTxID

func (n *Network) ComputeTxID(id *TxID) string

ComputeTxID computes the transaction ID in the target network format for the given tx id

func (*Network) ExistEnvelope

func (n *Network) ExistEnvelope(id string) bool

func (*Network) ExistTransient

func (n *Network) ExistTransient(id string) bool

func (*Network) FetchPublicParameters

func (n *Network) FetchPublicParameters(namespace string) ([]byte, error)

FetchPublicParameters returns the public parameters for the given namespace

func (*Network) GetEnrollmentID

func (n *Network) GetEnrollmentID(raw []byte) (string, error)

GetEnrollmentID returns the enrollment ID bound to the passed marshalled audit info

func (*Network) GetRWSet

func (n *Network) GetRWSet(id string, results []byte) (*RWSet, error)

GetRWSet returns the read-write set unmarshalled from the given bytes and bound to the given id

func (*Network) GetTransient

func (n *Network) GetTransient(id string) (TransientMap, error)

GetTransient retrieves the transient map bound to the passed id

func (*Network) IsFinal

func (n *Network) IsFinal(ctx context.Context, id string) error

IsFinal returns true if the given transaction is final

func (*Network) IsFinalForParties

func (n *Network) IsFinalForParties(id string, endpoints ...view.Identity) error

IsFinalForParties returns true if the given transaction is final for the given parties

func (*Network) Ledger

func (n *Network) Ledger(namespace string) (*Ledger, error)

func (*Network) LocalMembership

func (n *Network) LocalMembership() *LocalMembership

LocalMembership returns the local membership for this network

func (*Network) LookupTransferMetadataKey

func (n *Network) LookupTransferMetadataKey(namespace, startingTxID, key string, timeout time.Duration, opts ...token.ServiceOption) ([]byte, error)

LookupTransferMetadataKey searches for a transfer metadata key containing the passed sub-key starting from the passed transaction id in the given namespace. The operation gets canceled if the passed timeout gets reached.

func (*Network) Name

func (n *Network) Name() string

Name returns the name of the network

func (*Network) NewEnvelope

func (n *Network) NewEnvelope() *Envelope

NewEnvelope creates a new envelope

func (*Network) ProcessNamespace added in v0.3.0

func (n *Network) ProcessNamespace(namespace string) error

func (*Network) QueryTokens

func (n *Network) QueryTokens(context view.Context, namespace string, IDs []*token2.ID) ([][]byte, error)

QueryTokens returns the tokens corresponding to the given token ids int the given namespace

func (*Network) RequestApproval

func (n *Network) RequestApproval(context view.Context, tms *token.ManagementService, requestRaw []byte, signer view.Identity, txID TxID) (*Envelope, error)

RequestApproval requests approval for the given token request

func (*Network) StoreEnvelope

func (n *Network) StoreEnvelope(id string, env []byte) error

StoreEnvelope stores locally the given transaction envelope and associated it with the given id

func (*Network) StoreTransient

func (n *Network) StoreTransient(id string, transient TransientMap) error

StoreTransient stores locally the given transient data and associated it with the given id

func (*Network) SubscribeTxStatusChanges

func (n *Network) SubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) error

SubscribeTxStatusChanges register a listener for transaction status updates for the given id.

func (*Network) UnsubscribeTxStatusChanges

func (n *Network) UnsubscribeTxStatusChanges(id string, listener TxStatusChangeListener) error

UnsubscribeTxStatusChanges unregisters a listener for transaction status changes for the passed id

func (*Network) Vault

func (n *Network) Vault(namespace string) (*Vault, error)

Vault returns the vault for the given namespace

type Provider

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

Provider returns an instance of network provider

func NewProvider

func NewProvider(sp view2.ServiceProvider) *Provider

NewProvider returns a new instance of network provider

func (*Provider) GetNetwork

func (np *Provider) GetNetwork(network string, channel string) (*Network, error)

GetNetwork returns a network instance for the given network and channel

type RWSet

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

func (*RWSet) Done

func (s *RWSet) Done()

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 UnspentTokensIterator

type UnspentTokensIterator = driver.UnspentTokensIterator

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
}

func (*Vault) DiscardTx

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

func (*Vault) Exists

func (v *Vault) Exists(id *token2.ID) bool

func (*Vault) GetLastTxID

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

func (*Vault) ListUnspentTokens

func (v *Vault) ListUnspentTokens() (*token2.UnspentTokens, error)

func (*Vault) PruneInvalidUnspentTokens

func (v *Vault) PruneInvalidUnspentTokens(context view.Context) ([]*token2.ID, error)

PruneInvalidUnspentTokens checks that each unspent token is actually available on the ledger. Those that are not available are deleted. The function returns the list of deleted token ids

func (*Vault) Status

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

func (*Vault) Store

func (v *Vault) Store(certifications map[*token2.ID][]byte) error

func (*Vault) TokenVault

func (v *Vault) TokenVault() *vault.Vault

func (*Vault) UnspentTokensIterator

func (v *Vault) UnspentTokensIterator() (UnspentTokensIterator, error)

func (*Vault) UnspentTokensIteratorBy

func (v *Vault) UnspentTokensIteratorBy(id, typ string) (UnspentTokensIterator, error)

Directories

Path Synopsis
tcc
tcc/mock
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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