Documentation ¶
Index ¶
- type LedgerInfoRetriever
- type Mgr
- func (m *Mgr) Close()
- func (m *Mgr) GetRetriever(ledgerID string, ledgerInfoRetriever LedgerInfoRetriever) *Retriever
- func (m *Mgr) HandleStateUpdates(trigger *ledger.StateUpdateTrigger) error
- func (m *Mgr) ImportConfigHistory(ledgerID string, dir string) error
- func (m *Mgr) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error
- func (m *Mgr) InterestedInNamespaces() []string
- func (m *Mgr) Name() string
- func (m *Mgr) StateCommitDone(ledgerID string)
- type Retriever
- func (r *Retriever) CollectionConfigAt(blockNum uint64, chaincodeName string) (*ledger.CollectionConfigInfo, error)
- func (r *Retriever) ExportConfigHistory(dir string, newHashFunc snapshot.NewHashFunc) (map[string][]byte, error)
- func (r *Retriever) MostRecentCollectionConfigBelow(blockNum uint64, chaincodeName string) (*ledger.CollectionConfigInfo, error)
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) 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 (*Mgr) Initialize ¶
func (m *Mgr) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error
func (*Mgr) InterestedInNamespaces ¶
InterestedInNamespaces implements function from the interface ledger.StateListener
func (*Mgr) StateCommitDone ¶
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