Documentation ¶
Index ¶
- type Mgr
- func (m *Mgr) Close()
- func (m *Mgr) Drop(ledgerid string) error
- func (m *Mgr) GetRetriever(ledgerID string) *Retriever
- func (m *Mgr) HandleStateUpdates(trigger *ledger.StateUpdateTrigger) error
- func (m *Mgr) ImportFromSnapshot(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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
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) ImportFromSnapshot ¶
ImportConfigHistory imports the collection config history associated with a given ledgerID from the snapshot files present in the dir
func (*Mgr) Initialize ¶
func (m *Mgr) Initialize(ledgerID string, qe ledger.SimpleQueryExecutor) error
Initialize implements function from the interface ledger.StateListener
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
}
Retriever helps consumer retrieve collection config history
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