Skip to content

Commit

Permalink
rm DB interface from privacyenabledstate pkg (#1242)
Browse files Browse the repository at this point in the history
rm privacyenabledstate.DB interface

As part of FAB-10794, we would be making changes to
LoadCommittedVersions(). Before doing that, we remove unnecessary
interface from the privacyenabledstate which includes
LoadCommittedVersions() API.

After we have removed privacyenabledstate.DB interface, the filename
db.go does not make sense. Hence, we rename it to types.go as it holds
all private data related types. Further, db_test.go contains tests that
should be in common_storage_db_test.go. Hence, we also move those test
to the correct location and rename db_test.go to types_test.go.

Further, we have renamed CommonStorageDB to DB, removed
DBProvider interface, and removed the term CommonStorage from variables.

FAB-17880

Signed-off-by: senthil <cendhu@gmail.com>

rename common_storage_db.go to db.go

Signed-off-by: senthil <cendhu@gmail.com>
  • Loading branch information
cendhu authored May 14, 2020
1 parent 3271b6d commit 6316b46
Show file tree
Hide file tree
Showing 23 changed files with 771 additions and 797 deletions.
2 changes: 1 addition & 1 deletion core/ledger/kvledger/history/pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newTestHistoryEnv(t *testing.T) *levelDBLockBasedHistoryEnv {

blockStorageTestEnv := newBlockStorageTestEnv(t)

testDBEnv := &privacyenabledstate.LevelDBCommonStorageTestEnv{}
testDBEnv := &privacyenabledstate.LevelDBTestEnv{}
testDBEnv.Init(t)
testDB := testDBEnv.GetDBHandle(testLedgerID)
testBookkeepingEnv := bookkeeping.NewTestEnv(t)
Expand Down
6 changes: 3 additions & 3 deletions core/ledger/kvledger/kv_ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type lgrInitializer struct {
ledgerID string
blockStore *blkstorage.BlockStore
pvtdataStore *pvtdatastorage.Store
versionedDB privacyenabledstate.DB
stateDB *privacyenabledstate.DB
historyDB *history.DB
configHistoryMgr confighistory.Mgr
stateListeners []ledger.StateListener
Expand All @@ -85,7 +85,7 @@ func newKVLedger(initializer *lgrInitializer) (*kvLedger, error) {

txmgrInitializer := &lockbasedtxmgr.Initializer{
LedgerID: ledgerID,
DB: initializer.versionedDB,
DB: initializer.stateDB,
StateListeners: initializer.stateListeners,
BtlPolicy: btlPolicy,
BookkeepingProvider: initializer.bookkeeperProvider,
Expand Down Expand Up @@ -116,7 +116,7 @@ func newKVLedger(initializer *lgrInitializer) (*kvLedger, error) {
// TODO Move the function `GetChaincodeEventListener` to ledger interface and
// this functionality of registering for events to ledgermgmt package so that this
// is reused across other future ledger implementations
ccEventListener := initializer.versionedDB.GetChaincodeEventListener()
ccEventListener := initializer.stateDB.GetChaincodeEventListener()
logger.Debugf("Register state db for chaincode lifecycle events: %t", ccEventListener != nil)
if ccEventListener != nil {
cceventmgmt.GetMgr().Register(ledgerID, ccEventListener)
Expand Down
12 changes: 6 additions & 6 deletions core/ledger/kvledger/kv_ledger_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type Provider struct {
idStore *idStore
blkStoreProvider *blkstorage.BlockStoreProvider
pvtdataStoreProvider *pvtdatastorage.Provider
vdbProvider privacyenabledstate.DBProvider
dbProvider *privacyenabledstate.DBProvider
historydbProvider *history.DBProvider
configHistoryMgr confighistory.Mgr
stateListeners []ledger.StateListener
Expand Down Expand Up @@ -238,7 +238,7 @@ func (p *Provider) initStateDBProvider() error {
LevelDBPath: StateDBPath(p.initializer.Config.RootFSPath),
}
sysNamespaces := p.initializer.DeployedChaincodeInfoProvider.Namespaces()
p.vdbProvider, err = privacyenabledstate.NewCommonStorageDBProvider(
p.dbProvider, err = privacyenabledstate.NewDBProvider(
p.bookkeepingProvider,
p.initializer.MetricsProvider,
p.initializer.HealthCheckRegistry,
Expand Down Expand Up @@ -319,7 +319,7 @@ func (p *Provider) open(ledgerID string) (ledger.PeerLedger, error) {
p.collElgNotifier.registerListener(ledgerID, pvtdataStore)

// Get the versioned database (state database) for a chain/ledger
vDB, err := p.vdbProvider.GetDBHandle(ledgerID)
db, err := p.dbProvider.GetDBHandle(ledgerID)
if err != nil {
return nil, err
}
Expand All @@ -337,7 +337,7 @@ func (p *Provider) open(ledgerID string) (ledger.PeerLedger, error) {
ledgerID: ledgerID,
blockStore: blockStore,
pvtdataStore: pvtdataStore,
versionedDB: vDB,
stateDB: db,
historyDB: historyDB,
configHistoryMgr: p.configHistoryMgr,
stateListeners: p.stateListeners,
Expand Down Expand Up @@ -377,8 +377,8 @@ func (p *Provider) Close() {
if p.pvtdataStoreProvider != nil {
p.pvtdataStoreProvider.Close()
}
if p.vdbProvider != nil {
p.vdbProvider.Close()
if p.dbProvider != nil {
p.dbProvider.Close()
}
if p.bookkeepingProvider != nil {
p.bookkeepingProvider.Close()
Expand Down
Loading

0 comments on commit 6316b46

Please sign in to comment.