Skip to content

Commit 4e61bc3

Browse files
committed
[FAB-9980] Fix rwset-protos and ledger interface
This CR fixes some of the recent changes in the rwset protobuf messages and ledger interface based on the final discussion around the ledger support for state based endorsement Change-Id: Ifd585795e76de73f533d96fb5b8ff68467f9610b Signed-off-by: manish <manish.sethi@gmail.com>
1 parent f65e128 commit 4e61bc3

File tree

9 files changed

+293
-476
lines changed

9 files changed

+293
-476
lines changed

common/mocks/ledger/queryexecutor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ func (m *MockQueryExecutor) GetStateMetadata(namespace, key string) (map[string]
7979
return nil, nil
8080
}
8181

82-
func (m *MockQueryExecutor) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
82+
func (m *MockQueryExecutor) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
8383
return nil, nil
8484
}

core/chaincode/mock/tx_simulator.go

+144-290
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/committer/txvalidator/validator_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ func (exec *mockQueryExecutor) GetStateMetadata(namespace, key string) (map[stri
729729
return nil, nil
730730
}
731731

732-
func (exec *mockQueryExecutor) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
732+
func (exec *mockQueryExecutor) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
733733
return nil, nil
734734
}
735735

core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_query_executer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (q *lockBasedQueryExecutor) GetPrivateData(namespace, collection, key strin
6767
return q.helper.getPrivateData(namespace, collection, key)
6868
}
6969

70-
// GetPrivateMetadata implements method in interface `ledger.QueryExecutor`
71-
func (q *lockBasedQueryExecutor) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
70+
// GetPrivateDataMetadata implements method in interface `ledger.QueryExecutor`
71+
func (q *lockBasedQueryExecutor) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
7272
return nil, errors.New("not implemented")
7373
}
7474

core/ledger/kvledger/txmgmt/txmgr/lockbasedtxmgr/lockbased_tx_simulator.go

+5-10
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,8 @@ func (s *lockBasedTxSimulator) SetStateMultipleKeys(namespace string, kvs map[st
7171
return nil
7272
}
7373

74-
// SetStateMetadataEntry implements method in interface `ledger.TxSimulator`
75-
func (s *lockBasedTxSimulator) SetStateMetadataEntry(namespace, key, metakey string, metadata []byte) error {
76-
return errors.New("not implemented")
77-
}
78-
79-
// DeleteStateMetadataEntry implements method in interface `ledger.TxSimulator`
80-
func (s *lockBasedTxSimulator) DeleteStateMetadataEntry(namespace, key, metakey string) error {
74+
// SetStateMetadata implements method in interface `ledger.TxSimulator`
75+
func (s *lockBasedTxSimulator) SetStateMetadata(namespace, key, metadata map[string][]byte) error {
8176
return errors.New("not implemented")
8277
}
8378

@@ -125,8 +120,8 @@ func (s *lockBasedTxSimulator) GetPrivateDataRangeScanIterator(namespace, collec
125120
return s.lockBasedQueryExecutor.GetPrivateDataRangeScanIterator(namespace, collection, startKey, endKey)
126121
}
127122

128-
// SetPrivateMetadataEntry implements method in interface `ledger.TxSimulator`
129-
func (s *lockBasedTxSimulator) SetPrivateMetadataEntry(namespace, collection, key, metakey string, metadata []byte) error {
123+
// SetPrivateDataMetadata implements method in interface `ledger.TxSimulator`
124+
func (s *lockBasedTxSimulator) SetPrivateDataMetadata(namespace, collection, key, metadata map[string][]byte) error {
130125
return errors.New("not implemented")
131126
}
132127

@@ -136,7 +131,7 @@ func (s *lockBasedTxSimulator) DeletePrivateMetadataEntry(namespace, collection,
136131
}
137132

138133
// DeletePrivateMetadata implements method in interface `ledger.TxSimulator`
139-
func (s *lockBasedTxSimulator) DeletePrivateMetadata(namespace, collection, key string) error {
134+
func (s *lockBasedTxSimulator) DeletePrivateDataMetadata(namespace, collection, key string) error {
140135
return errors.New("not implemented")
141136
}
142137

core/ledger/ledger_interface.go

+9-13
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ type QueryExecutor interface {
108108
ExecuteQuery(namespace, query string) (commonledger.ResultsIterator, error)
109109
// GetPrivateData gets the value of a private data item identified by a tuple <namespace, collection, key>
110110
GetPrivateData(namespace, collection, key string) ([]byte, error)
111-
// GetPrivateMetadata gets the metadata of a private data item identified by a tuple <namespace, collection, key>
112-
GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error)
111+
// GetPrivateDataMetadata gets the metadata of a private data item identified by a tuple <namespace, collection, key>
112+
GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error)
113113
// GetPrivateDataMultipleKeys gets the values for the multiple private data items in a single call
114114
GetPrivateDataMultipleKeys(namespace, collection string, keys []string) ([][]byte, error)
115115
// GetPrivateDataRangeScanIterator returns an iterator that contains all the key-values between given key ranges.
@@ -144,11 +144,9 @@ type TxSimulator interface {
144144
DeleteState(namespace string, key string) error
145145
// SetMultipleKeys sets the values for multiple keys in a single call
146146
SetStateMultipleKeys(namespace string, kvs map[string][]byte) error
147-
// SetStateMetadataEntry upserts an entry in the metadata for the given namespace and key
148-
SetStateMetadataEntry(namespace, key, metakey string, metadata []byte) error
149-
// DeleteStateMetadataEntry deletes the given entry from the metadata for the given namespace and key
150-
DeleteStateMetadataEntry(namespace, key, metakey string) error
151-
// DeleteStateMetadata deletes entire metadata for a given key
147+
// SetStateMetadata sets the metadata associated with an existing key-tuple <namespace, key>
148+
SetStateMetadata(namespace, key, metadata map[string][]byte) error
149+
// DeleteStateMetadata deletes the metadata (if any) associated with an existing key-tuple <namespace, key>
152150
DeleteStateMetadata(namespace, key string) error
153151
// ExecuteUpdate for supporting rich data model (see comments on QueryExecutor above)
154152
ExecuteUpdate(query string) error
@@ -158,12 +156,10 @@ type TxSimulator interface {
158156
SetPrivateDataMultipleKeys(namespace, collection string, kvs map[string][]byte) error
159157
// DeletePrivateData deletes the given tuple <namespace, collection, key> from private data
160158
DeletePrivateData(namespace, collection, key string) error
161-
// SetPrivateMetadataEntry upserts an entry in the metadata for a key in the private data state represented by the tuple <namespace, collection, key>
162-
SetPrivateMetadataEntry(namespace, collection, key, metakey string, metadata []byte) error
163-
// DeletePrivateMetadataEntry deletes the given entry from the metadata for a key in the private data state represented by the tuple <namespace, collection, key>
164-
DeletePrivateMetadataEntry(namespace, collection, key, metakey string) error
165-
// DeletePrivateMetadata deletes entire metadata for a given key in the private data state represented by the tuple <namespace, collection, key>
166-
DeletePrivateMetadata(namespace, collection, key string) error
159+
// SetPrivateDataMetadata sets the metadata associated with an existing key-tuple <namespace, collection, key>
160+
SetPrivateDataMetadata(namespace, collection, key, metadata map[string][]byte) error
161+
// DeletePrivateDataMetadata deletes the metadata associated with an existing key-tuple <namespace, collection, key>
162+
DeletePrivateDataMetadata(namespace, collection, key string) error
167163
// GetTxSimulationResults encapsulates the results of the transaction simulation.
168164
// This should contain enough detail for
169165
// - The update in the state that would be caused if the transaction is to be committed

core/mocks/ccprovider/ccprovider.go

+4-12
Original file line numberDiff line numberDiff line change
@@ -115,31 +115,23 @@ func (m *MockTxSim) GetStateMetadata(namespace, key string) (map[string][]byte,
115115
return nil, nil
116116
}
117117

118-
func (m *MockTxSim) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
118+
func (m *MockTxSim) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
119119
return nil, nil
120120
}
121121

122-
func (m *MockTxSim) SetStateMetadataEntry(namespace, key, metakey string, metadata []byte) error {
123-
return nil
124-
}
125-
126-
func (m *MockTxSim) DeleteStateMetadataEntry(namespace, key, metakey string) error {
122+
func (m *MockTxSim) SetStateMetadata(namespace, key, metadata map[string][]byte) error {
127123
return nil
128124
}
129125

130126
func (m *MockTxSim) DeleteStateMetadata(namespace, key string) error {
131127
return nil
132128
}
133129

134-
func (m *MockTxSim) SetPrivateMetadataEntry(namespace, collection, key, metakey string, metadata []byte) error {
135-
return nil
136-
}
137-
138-
func (m *MockTxSim) DeletePrivateMetadataEntry(namespace, collection, key, metakey string) error {
130+
func (m *MockTxSim) SetPrivateDataMetadata(namespace, collection, key, metadata map[string][]byte) error {
139131
return nil
140132
}
141133

142-
func (m *MockTxSim) DeletePrivateMetadata(namespace, collection, key string) error {
134+
func (m *MockTxSim) DeletePrivateDataMetadata(namespace, collection, key string) error {
143135
return nil
144136
}
145137

0 commit comments

Comments
 (0)