Skip to content

Commit

Permalink
[FAB-10029] Extend committer API to get coll. conf.
Browse files Browse the repository at this point in the history
Add new function to the Committer interface to expose capablity of
acquiring collections configuration based on chaincode namespace and the
ledger height.

Change-Id: I3cb9b039895503992375e4675c87fd85a1894ce8
Signed-off-by: Artem Barger <[email protected]>
  • Loading branch information
C0rWin committed May 15, 2018
1 parent ff31dd1 commit 9e9090e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/committer/committer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ type Committer interface {
// Gets blocks with sequence numbers provided in the slice
GetBlocks(blockSeqs []uint64) []*common.Block

// GetConfigHistoryRetriever returns the ConfigHistoryRetriever
GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error)

// Closes committing service
Close()
}
2 changes: 2 additions & 0 deletions core/committer/committer_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type PeerLedgerSupport interface {

GetBlockByNumber(blockNumber uint64) (*common.Block, error)

GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error)

Close()
}

Expand Down
5 changes: 5 additions & 0 deletions core/committer/committer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ type mockLedger struct {
mock.Mock
}

func (m *mockLedger) GetConfigHistoryRetriever() (ledger2.ConfigHistoryRetriever, error) {
args := m.Called()
return args.Get(0).(ledger2.ConfigHistoryRetriever), args.Error(1)
}

func (m *mockLedger) GetBlockchainInfo() (*common.BlockchainInfo, error) {
info := &common.BlockchainInfo{
Height: m.height,
Expand Down
5 changes: 5 additions & 0 deletions gossip/privdata/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ type committerMock struct {
mock.Mock
}

func (mock *committerMock) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error) {
args := mock.Called()
return args.Get(0).(ledger.ConfigHistoryRetriever), args.Error(1)
}

func (mock *committerMock) GetPvtDataByNum(blockNum uint64, filter ledger.PvtNsCollFilter) ([]*ledger.TxPvtData, error) {
args := mock.Called(blockNum, filter)
return args.Get(0).([]*ledger.TxPvtData), args.Error(1)
Expand Down
3 changes: 3 additions & 0 deletions gossip/privdata/dataretriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type DataStore interface {
// 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)
}
Expand Down
5 changes: 5 additions & 0 deletions gossip/privdata/dataretriever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ type mockedDataStore struct {
mock.Mock
}

func (ds *mockedDataStore) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error) {
args := ds.Called()
return args.Get(0).(ledger.ConfigHistoryRetriever), args.Error(1)
}

func (ds *mockedDataStore) GetTxPvtRWSetByTxid(txid string, filter ledger.PvtNsCollFilter) (transientstore.RWSetScanner, error) {
args := ds.Called(txid, filter)
return args.Get(0).(transientstore.RWSetScanner), args.Error(1)
Expand Down
4 changes: 4 additions & 0 deletions gossip/service/gossip_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ type mockLedgerInfo struct {
Height uint64
}

func (li *mockLedgerInfo) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error) {
panic("implement me")
}

func (li *mockLedgerInfo) GetPvtDataByNum(blockNum uint64, filter ledger.PvtNsCollFilter) ([]*ledger.TxPvtData, error) {
panic("implement me")
}
Expand Down
9 changes: 9 additions & 0 deletions gossip/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ type mockCommitter struct {
sync.Mutex
}

func (mc *mockCommitter) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error) {
args := mc.Called()
return args.Get(0).(ledger.ConfigHistoryRetriever), args.Error(1)
}

func (mc *mockCommitter) GetPvtDataByNum(blockNum uint64, filter ledger.PvtNsCollFilter) ([]*ledger.TxPvtData, error) {
args := mc.Called(blockNum, filter)
return args.Get(0).([]*ledger.TxPvtData), args.Error(1)
Expand Down Expand Up @@ -241,6 +246,10 @@ type ramLedger struct {
sync.RWMutex
}

func (mock *ramLedger) GetConfigHistoryRetriever() (ledger.ConfigHistoryRetriever, error) {
panic("implement me")
}

func (mock *ramLedger) GetPvtDataAndBlockByNum(blockNum uint64, filter ledger.PvtNsCollFilter) (*ledger.BlockAndPvtData, error) {
mock.RLock()
defer mock.RUnlock()
Expand Down

0 comments on commit 9e9090e

Please sign in to comment.