const (
TransientBlockRetentionDefault = 1000
)
func GetBtlPullMargin() uint64
func GetTransientBlockRetention() uint64
func NewPuller(metrics *metrics.PrivdataMetrics, cs privdata.CollectionStore, g gossip, dataRetriever PrivateDataRetriever, factory CollectionAccessFactory, channel string, btlPullMargin uint64) *puller
NewPuller creates new private data puller
go:generate mockery -dir ./ -name AppCapabilities -case underscore -output mocks/ appCapabilities local interface used to generate mock for foreign interface.
type AppCapabilities interface { channelconfig.ApplicationCapabilities }
CapabilityProvider contains functions to retrieve capability information for a channel
type CapabilityProvider interface { // Capabilities defines the capabilities for the application portion of this channel Capabilities() channelconfig.ApplicationCapabilities }
CollectionAccessFactory an interface to generate collection access policy
type CollectionAccessFactory interface { // AccessPolicy based on collection configuration AccessPolicy(config *common.CollectionConfig, chainID string) (privdata.CollectionAccessPolicy, error) }
func NewCollectionAccessFactory(factory IdentityDeserializerFactory) CollectionAccessFactory
NewCollectionAccessFactory
Coordinator orchestrates the flow of the new blocks arrival and in flight transient data, responsible to complete missing parts of transient data for given block.
type Coordinator interface { // StoreBlock deliver new block with underlined private data // returns missing transaction ids StoreBlock(block *common.Block, data util.PvtDataCollections) error // StorePvtData used to persist private data into transient store StorePvtData(txid string, privData *transientstore2.TxPvtReadWriteSetWithConfigInfo, blckHeight uint64) error // GetPvtDataAndBlockByNum get block by number and returns also all related private data // the order of private data in slice of PvtDataCollections doesn't implies the order of // transactions in the block related to these private data, to get the correct placement // need to read TxPvtData.SeqInBlock field GetPvtDataAndBlockByNum(seqNum uint64, peerAuth common.SignedData) (*common.Block, util.PvtDataCollections, error) // Get recent block sequence number LedgerHeight() (uint64, error) // Close coordinator, shuts down coordinator service Close() }
func NewCoordinator(support Support, selfSignedData common.SignedData, metrics *metrics.PrivdataMetrics, config CoordinatorConfig) Coordinator
NewCoordinator creates a new instance of coordinator
type CoordinatorConfig struct { TransientBlockRetention uint64 PullRetryThreshold time.Duration SkipPullingInvalidTransactions bool }
DataStore defines set of APIs need to get private data from underlined data store
type DataStore interface { // GetTxPvtRWSetByTxid returns an iterator due to the fact that the txid may have multiple private // RWSets persisted from different endorsers (via Gossip) GetTxPvtRWSetByTxid(txid string, filter ledger.PvtNsCollFilter) (transientstore.RWSetScanner, error) // GetPvtDataByNum returns a slice of the private data from the ledger // for given block and based on the filter which indicates a map of // collections and namespaces of private data to retrieve GetPvtDataByNum(blockNum uint64, filter ledger.PvtNsCollFilter) ([]*ledger.TxPvtData, error) // GetConfigHistoryRetriever returns the ConfigHistoryRetriever GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error) // Get recent block sequence number LedgerHeight() (uint64, error) }
Dig2PvtRWSetWithConfig
type Dig2PvtRWSetWithConfig map[privdatacommon.DigKey]*util.PrivateRWSetWithConfig
Fetcher interface which defines API to fetch missing private data elements
type Fetcher interface {
// contains filtered or unexported methods
}
IdentityDeserializerFactory is a factory interface to create IdentityDeserializer for given channel
type IdentityDeserializerFactory interface { // GetIdentityDeserializer returns an IdentityDeserializer // instance for the specified chain GetIdentityDeserializer(chainID string) msp.IdentityDeserializer }
NoOpReconciler non functional reconciler to be used in case reconciliation has been disabled
type NoOpReconciler struct { }
func (*NoOpReconciler) Start()
func (*NoOpReconciler) Stop()
PrivateDataRetriever interface which defines API capable of retrieving required private data
type PrivateDataRetriever interface { // CollectionRWSet returns the bytes of CollectionPvtReadWriteSet for a given txID and collection from the transient store CollectionRWSet(dig []*proto.PvtDataDigest, blockNum uint64) (Dig2PvtRWSetWithConfig, bool, error) }
PvtDataDistributor interface to defines API of distributing private data
type PvtDataDistributor interface { // Distribute broadcast reliably private data read write set based on policies Distribute(txID string, privData *transientstore.TxPvtReadWriteSetWithConfigInfo, blkHt uint64) error }
func NewDistributor(chainID string, gossip gossipAdapter, factory CollectionAccessFactory, metrics *metrics.PrivdataMetrics, pushAckTimeout time.Duration) PvtDataDistributor
NewDistributor a constructor for private data distributor capable to send private read write sets for underlying collection
Reconciler completes missing parts of private data that weren't available during commit time. this is done by getting from the ledger a list of missing private data and pulling it from the other peers.
type PvtDataReconciler interface { // Start function start the reconciler based on a scheduler, as was configured in reconciler creation Start() // Stop function stops reconciler Stop() }
type Reconciler struct { ReconciliationFetcher committer.Committer // contains filtered or unexported fields }
func NewReconciler(channel string, metrics *metrics.PrivdataMetrics, c committer.Committer, fetcher ReconciliationFetcher, config *ReconcilerConfig) *Reconciler
NewReconciler creates a new instance of reconciler
func (r *Reconciler) Start()
func (r *Reconciler) Stop()
ReconcilerConfig holds config flags that are read from core.yaml
type ReconcilerConfig struct { SleepInterval time.Duration BatchSize int IsEnabled bool }
func GetReconcilerConfig() *ReconcilerConfig
this func reads reconciler configuration values from core.yaml and returns ReconcilerConfig
ReconciliationFetcher interface which defines API to fetch private data elements that have to be reconciled
type ReconciliationFetcher interface { FetchReconciledItems(dig2collectionConfig privdatacommon.Dig2CollectionConfig) (*privdatacommon.FetchedPvtDataContainer, error) }
StorageDataRetriever defines an API to retrieve private date from the storage
type StorageDataRetriever interface { // CollectionRWSet retrieves for give digest relevant private data if // available otherwise returns nil, bool which is true if data fetched from ledger and false if was fetched from transient store, and an error CollectionRWSet(dig []*gossip2.PvtDataDigest, blockNum uint64) (Dig2PvtRWSetWithConfig, bool, error) }
func NewDataRetriever(store DataStore) StorageDataRetriever
NewDataRetriever constructing function for implementation of the StorageDataRetriever interface
Support encapsulates set of interfaces to aggregate required functionality by single struct
type Support struct { ChainID string privdata.CollectionStore txvalidator.Validator committer.Committer TransientStore Fetcher CapabilityProvider }
TransientStore holds private data that the corresponding blocks haven't been committed yet into the ledger
type TransientStore interface { // PersistWithConfig stores the private write set of a transaction along with the collection config // in the transient store based on txid and the block height the private data was received at PersistWithConfig(txid string, blockHeight uint64, privateSimulationResultsWithConfig *transientstore2.TxPvtReadWriteSetWithConfigInfo) error // Persist stores the private write set of a transaction in the transient store Persist(txid string, blockHeight uint64, privateSimulationResults *rwset.TxPvtReadWriteSet) error // GetTxPvtRWSetByTxid returns an iterator due to the fact that the txid may have multiple private // write sets persisted from different endorsers (via Gossip) GetTxPvtRWSetByTxid(txid string, filter ledger.PvtNsCollFilter) (transientstore.RWSetScanner, error) // PurgeByTxids removes private read-write sets for a given set of transactions from the // transient store PurgeByTxids(txids []string) error // PurgeByHeight removes private write sets at block height lesser than // a given maxBlockNumToRetain. In other words, Purge only retains private write sets // that were persisted at block height of maxBlockNumToRetain or higher. Though the private // write sets stored in transient store is removed by coordinator using PurgebyTxids() // after successful block commit, PurgeByHeight() is still required to remove orphan entries (as // transaction that gets endorsed may not be submitted by the client for commit) PurgeByHeight(maxBlockNumToRetain uint64) error }