confighistory

package
v0.0.0-...-98d3023 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LedgerInfoRetriever

type LedgerInfoRetriever interface {
	GetBlockchainInfo() (*common.BlockchainInfo, error)
	NewQueryExecutor() (ledger.QueryExecutor, error)
}

LedgerInfoRetriever retrieves the relevant info from ledger

type Mgr

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

Mgr manages the history of configurations such as chaincode's collection configurations. It should be registered as a state listener. The state listener builds the history.

func NewMgr

func NewMgr(dbPath string, ccInfoProvider ledger.DeployedChaincodeInfoProvider) (*Mgr, error)

NewMgr constructs an instance that implements interface `Mgr`

func (*Mgr) Close

func (m *Mgr) Close()

Close implements the function in the interface 'Mgr'

func (*Mgr) GetRetriever

func (m *Mgr) GetRetriever(ledgerID string, ledgerInfoRetriever LedgerInfoRetriever) *Retriever

GetRetriever returns an implementation of `ledger.ConfigHistoryRetriever` for the given ledger id.

func (*Mgr) HandleStateUpdates

func (m *Mgr) HandleStateUpdates(trigger *ledger.StateUpdateTrigger) error

HandleStateUpdates implements function from the interface ledger.StateListener In this implementation, the latest collection config package is retrieved via ledger.DeployedChaincodeInfoProvider and is persisted as a separate entry in a separate db. The composite key for the entry is a tuple of <blockNum, namespace, key>

func (*Mgr) ImportConfigHistory

func (m *Mgr) ImportConfigHistory(ledgerID string, dir string) error

func (*Mgr) Initialize

func (m *Mgr) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error

func (*Mgr) InterestedInNamespaces

func (m *Mgr) InterestedInNamespaces() []string

InterestedInNamespaces implements function from the interface ledger.StateListener

func (*Mgr) Name

func (m *Mgr) Name() string

Name returns the name of the listener

func (*Mgr) StateCommitDone

func (m *Mgr) StateCommitDone(ledgerID string)

StateCommitDone implements function from the interface ledger.StateListener

type Retriever

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

func (*Retriever) CollectionConfigAt

func (r *Retriever) CollectionConfigAt(blockNum uint64, chaincodeName string) (*ledger.CollectionConfigInfo, error)

CollectionConfigAt implements function from the interface ledger.ConfigHistoryRetriever

func (*Retriever) ExportConfigHistory

func (r *Retriever) ExportConfigHistory(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error)

ExportConfigHistory exports configuration history from the confighistoryDB to a file. Currently, we store only one type of configuration in the db, i.e., private data collection configuration. We write the full key and value stored in the database as is to the file. Though we could decode the key and write a proto message with exact ns, key, block number, and collection config, we store the full key and value to avoid unnecessary encoding and decoding of proto messages. The key format stored in db is "s" + ns + byte(0) + key + "~collection" + byte(0) + blockNum. As we store the key as is, we store 13 extra bytes. For a million records, it would add only 12 MB overhead. Note that the protobuf also adds some extra bytes. Further, the collection config namespace is not expected to have millions of entries.

func (*Retriever) MostRecentCollectionConfigBelow

func (r *Retriever) MostRecentCollectionConfigBelow(blockNum uint64, chaincodeName string) (*ledger.CollectionConfigInfo, error)

MostRecentCollectionConfigBelow implements function from the interface ledger.ConfigHistoryRetriever

Jump to

Keyboard shortcuts

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