client

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 15 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelProviders added in v0.1.1

type ChannelProviders struct {
	Ledger           PeerLedger
	Distributor      PvtDataDistributor
	ConfigRetriever  support.CollectionConfigRetriever
	IdentityProvider collcommon.IdentityProvider
}

ChannelProviders holds all of the providers required by the client

type Client

type Client struct {
	*ChannelProviders
	// contains filtered or unexported fields
}

Client allows you to put and get Client from outside of a chaincode

func New

func New(channelID string, providers *ChannelProviders) *Client

New returns a new collection client

func (*Client) Delete

func (d *Client) Delete(ns, coll string, keys ...string) error

Delete deletes the given key(s)

func (*Client) Get

func (d *Client) Get(ns, coll, key string) ([]byte, error)

Get retrieves the value for the given key

func (*Client) GetMultipleKeys

func (d *Client) GetMultipleKeys(ns, coll string, keys ...string) ([][]byte, error)

GetMultipleKeys retrieves the values for the given keys

func (*Client) Put

func (d *Client) Put(ns, coll, key string, value []byte) error

Put puts the value for the given key

func (*Client) PutMultipleValues

func (d *Client) PutMultipleValues(ns, coll string, kvs []*KeyValue) error

PutMultipleValues puts the given key/values

func (*Client) Query

func (d *Client) Query(ns, coll, query string) (commonledger.ResultsIterator, error)

Query executes the given query and returns an iterator that contains results. Only used for state databases that support query. (Note that this function is not supported by transient data collections) The returned ResultsIterator contains results of type *KV which is defined in protos/ledger/queryresult.

type KeyValue

type KeyValue struct {
	Key   string
	Value []byte
}

KeyValue holds a key-value pair

type OffLedger added in v0.1.1

type OffLedger interface {
	// Put puts the value for the given key
	Put(ns, coll, key string, value []byte) error

	// PutMultipleValues puts the given key/values
	PutMultipleValues(ns, coll string, kvs []*KeyValue) error

	// Delete deletes the given key(s)
	Delete(ns, coll string, keys ...string) error

	// Get retrieves the value for the given key
	Get(ns, coll, key string) ([]byte, error)

	// GetMultipleKeys retrieves the values for the given keys
	GetMultipleKeys(ns, coll string, keys ...string) ([][]byte, error)

	// Query executes the given query and returns an iterator that contains results.
	// Only used for state databases that support query.
	// The returned ResultsIterator contains results of type *KV which is defined in protos/ledger/queryresult.
	Query(ns, coll, query string) (commonledger.ResultsIterator, error)
}

OffLedger defines the functions of an off-ledger client

type PeerLedger

type PeerLedger interface {
	// NewQueryExecutor gives handle to a query executor.
	// A client can obtain more than one 'QueryExecutor's for parallel execution.
	// Any synchronization should be performed at the implementation level if required
	NewQueryExecutor() (ledger.QueryExecutor, error)
	// NewTxSimulator gives handle to a transaction simulator.
	// A client can obtain more than one 'TxSimulator's for parallel execution.
	// Any snapshoting/synchronization should be performed at the implementation level if required
	NewTxSimulator(txid string) (ledger.TxSimulator, error)
	// GetBlockchainInfo returns basic info about blockchain
	GetBlockchainInfo() (*cb.BlockchainInfo, error)
}

PeerLedger defines the ledger functions required by the client

type Provider added in v0.1.1

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

Provider manages multiple clients - one per channel

func NewProvider added in v0.1.1

func NewProvider(providers *Providers) *Provider

NewProvider returns a new client provider

func (*Provider) ForChannel added in v0.1.1

func (p *Provider) ForChannel(channelID string) (OffLedger, error)

ForChannel returns the client for the given channel

type Providers added in v0.1.1

type Providers struct {
	LedgerProvider   collcommon.LedgerProvider
	GossipProvider   collcommon.GossipProvider
	ConfigProvider   collcommon.CollectionConfigProvider
	IdentityProvider collcommon.IdentityProvider
}

Providers contains all of the dependencies for the client

type PvtDataDistributor added in v0.1.1

type PvtDataDistributor interface {
	DistributePrivateData(chainID string, txID string, privateData *transientstore.TxPvtReadWriteSetWithConfigInfo, blkHt uint64) error
}

PvtDataDistributor distributes private data to the peers in the collections according to policies induced by the PolicyStore and PolicyParser

Directories

Path Synopsis
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