Skip to content

Commit 3df2ed3

Browse files
committed
Rename transient store functions
This CR is mainly a clean up CR that cleans up the transient store code After having removed the unused functions, this CR now renames the functions that are used to their original concise names FAB-16552 #done Change-Id: I57b2fc2985e55d3027dac89313e34cb41fc8200f Signed-off-by: manish <manish.sethi@gmail.com>
1 parent 0b9cccc commit 3df2ed3

File tree

13 files changed

+91
-97
lines changed

13 files changed

+91
-97
lines changed

core/endorser/mocks/store.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/endorser/plugin_endorser_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ type rwsetScanner struct {
155155
data []*rwset.TxPvtReadWriteSet
156156
}
157157

158-
func (rws *rwsetScanner) NextWithConfig() (*transientstore.EndorserPvtSimulationResultsWithConfig, error) {
158+
func (rws *rwsetScanner) Next() (*transientstore.EndorserPvtSimulationResults, error) {
159159
if len(rws.data) == 0 {
160160
return nil, nil
161161
}
162162
res := rws.data[0]
163163
rws.data = rws.data[1:]
164-
return &transientstore.EndorserPvtSimulationResultsWithConfig{
164+
return &transientstore.EndorserPvtSimulationResults{
165165
PvtSimulationResultsWithConfig: &transientstore2.TxPvtReadWriteSetWithConfigInfo{
166166
PvtRwset: res,
167167
},

core/endorser/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (sc *StateContext) GetTransientByTXID(txID string) ([]*rwset.TxPvtReadWrite
5454
defer scanner.Close()
5555
var data []*rwset.TxPvtReadWriteSet
5656
for {
57-
res, err := scanner.NextWithConfig()
57+
res, err := scanner.Next()
5858
if err != nil {
5959
return nil, errors.WithStack(err)
6060
}

core/transientstore/store.go

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ import (
2121

2222
var logger = flogging.MustGetLogger("transientstore")
2323

24-
var emptyValue = []byte{}
25-
var nilByte = byte('\x00')
26-
27-
// ErrStoreEmpty is used to indicate that there are no entries in transient store
28-
var ErrStoreEmpty = errors.New("Transient store is empty")
24+
var (
25+
emptyValue = []byte{}
26+
nilByte = byte('\x00')
27+
// ErrStoreEmpty is used to indicate that there are no entries in transient store
28+
ErrStoreEmpty = errors.New("Transient store is empty")
29+
)
2930

3031
//////////////////////////////////////////////
3132
// Interfaces and data types
@@ -39,12 +40,10 @@ type StoreProvider interface {
3940

4041
// RWSetScanner provides an iterator for EndorserPvtSimulationResults
4142
type RWSetScanner interface {
42-
// NextWithConfig returns the next EndorserPvtSimulationResultsWithConfig from the RWSetScanner.
43+
// Next returns the next EndorserPvtSimulationResults from the RWSetScanner.
4344
// It may return nil, nil when it has no further data, and also may return an error
4445
// on failure
45-
// TODO: Once the related gossip changes are made as per FAB-5096, remove the above function
46-
// and rename the below function to Next form NextWithConfig.
47-
NextWithConfig() (*EndorserPvtSimulationResultsWithConfig, error)
46+
Next() (*EndorserPvtSimulationResults, error)
4847
// Close frees the resources associated with this RWSetScanner
4948
Close()
5049
}
@@ -53,11 +52,9 @@ type RWSetScanner interface {
5352
// Ideally, a ledger can remove the data from this storage when it is committed to
5453
// the permanent storage or the pruning of some data items is enforced by the policy
5554
type Store interface {
56-
// TODO: Once the related gossip changes are made as per FAB-5096, remove the above function
57-
// and rename the below function to Persist form PersistWithConfig.
58-
// PersistWithConfig stores the private write set of a transaction along with the collection config
55+
// Persist stores the private write set of a transaction along with the collection config
5956
// in the transient store based on txid and the block height the private data was received at
60-
PersistWithConfig(txid string, blockHeight uint64, privateSimulationResultsWithConfig *transientstore.TxPvtReadWriteSetWithConfigInfo) error
57+
Persist(txid string, blockHeight uint64, privateSimulationResultsWithConfig *transientstore.TxPvtReadWriteSetWithConfigInfo) error
6158
// GetTxPvtRWSetByTxid returns an iterator due to the fact that the txid may have multiple private
6259
// write sets persisted from different endorsers (via Gossip)
6360
GetTxPvtRWSetByTxid(txid string, filter ledger.PvtNsCollFilter) (RWSetScanner, error)
@@ -76,8 +73,8 @@ type Store interface {
7673
Shutdown()
7774
}
7875

79-
// EndorserPvtSimulationResultsWithConfig captures the details of the simulation results specific to an endorser
80-
type EndorserPvtSimulationResultsWithConfig struct {
76+
// EndorserPvtSimulationResults captures the details of the simulation results specific to an endorser
77+
type EndorserPvtSimulationResults struct {
8178
ReceivedAtBlockHeight uint64
8279
PvtSimulationResultsWithConfig *transientstore.TxPvtReadWriteSetWithConfigInfo
8380
}
@@ -126,11 +123,9 @@ func (provider *storeProvider) Close() {
126123
provider.dbProvider.Close()
127124
}
128125

129-
// PersistWithConfig stores the private write set of a transaction along with the collection config
126+
// Persist stores the private write set of a transaction along with the collection config
130127
// in the transient store based on txid and the block height the private data was received at
131-
// TODO: Once the related gossip changes are made as per FAB-5096, rename this function to Persist
132-
// form PersistWithConfig.
133-
func (s *store) PersistWithConfig(txid string, blockHeight uint64,
128+
func (s *store) Persist(txid string, blockHeight uint64,
134129
privateSimulationResultsWithConfig *transientstore.TxPvtReadWriteSetWithConfigInfo) error {
135130

136131
logger.Debugf("Persisting private data to transient store for txid [%s] at block height [%d]", txid, blockHeight)
@@ -312,9 +307,8 @@ func (s *store) Shutdown() {
312307
}
313308

314309
// Next moves the iterator to the next key/value pair.
315-
// It returns whether the iterator is exhausted.
316-
// TODO: Once the related gossip changes are made as per FAB-5096, rename this function to Next
317-
func (scanner *RwsetScanner) NextWithConfig() (*EndorserPvtSimulationResultsWithConfig, error) {
310+
// It returns <nil, nil> when the iterator is exhausted.
311+
func (scanner *RwsetScanner) Next() (*EndorserPvtSimulationResults, error) {
318312
if !scanner.dbItr.Next() {
319313
return nil, nil
320314
}
@@ -351,7 +345,7 @@ func (scanner *RwsetScanner) NextWithConfig() (*EndorserPvtSimulationResultsWith
351345

352346
txPvtRWSetWithConfig.PvtRwset = filteredTxPvtRWSet
353347

354-
return &EndorserPvtSimulationResultsWithConfig{
348+
return &EndorserPvtSimulationResults{
355349
ReceivedAtBlockHeight: blockHeight,
356350
PvtSimulationResultsWithConfig: txPvtRWSetWithConfig,
357351
}, nil

0 commit comments

Comments
 (0)