Skip to content

Commit

Permalink
Merge "[FAB-9980] Fix rwset-protos and ledger interface"
Browse files Browse the repository at this point in the history
  • Loading branch information
C0rWin authored and Gerrit Code Review committed May 10, 2018
2 parents 12f7f1d + 4e61bc3 commit fc733e6
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 476 deletions.
2 changes: 1 addition & 1 deletion common/mocks/ledger/queryexecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ func (m *MockQueryExecutor) GetStateMetadata(namespace, key string) (map[string]
return nil, nil
}

func (m *MockQueryExecutor) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
func (m *MockQueryExecutor) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
return nil, nil
}
434 changes: 144 additions & 290 deletions core/chaincode/mock/tx_simulator.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/committer/txvalidator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ func (exec *mockQueryExecutor) GetStateMetadata(namespace, key string) (map[stri
return nil, nil
}

func (exec *mockQueryExecutor) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
func (exec *mockQueryExecutor) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
return nil, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (q *lockBasedQueryExecutor) GetPrivateData(namespace, collection, key strin
return q.helper.getPrivateData(namespace, collection, key)
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ func (s *lockBasedTxSimulator) SetStateMultipleKeys(namespace string, kvs map[st
return nil
}

// SetStateMetadataEntry implements method in interface `ledger.TxSimulator`
func (s *lockBasedTxSimulator) SetStateMetadataEntry(namespace, key, metakey string, metadata []byte) error {
return errors.New("not implemented")
}

// DeleteStateMetadataEntry implements method in interface `ledger.TxSimulator`
func (s *lockBasedTxSimulator) DeleteStateMetadataEntry(namespace, key, metakey string) error {
// SetStateMetadata implements method in interface `ledger.TxSimulator`
func (s *lockBasedTxSimulator) SetStateMetadata(namespace, key, metadata map[string][]byte) error {
return errors.New("not implemented")
}

Expand Down Expand Up @@ -125,8 +120,8 @@ func (s *lockBasedTxSimulator) GetPrivateDataRangeScanIterator(namespace, collec
return s.lockBasedQueryExecutor.GetPrivateDataRangeScanIterator(namespace, collection, startKey, endKey)
}

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

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

// DeletePrivateMetadata implements method in interface `ledger.TxSimulator`
func (s *lockBasedTxSimulator) DeletePrivateMetadata(namespace, collection, key string) error {
func (s *lockBasedTxSimulator) DeletePrivateDataMetadata(namespace, collection, key string) error {
return errors.New("not implemented")
}

Expand Down
22 changes: 9 additions & 13 deletions core/ledger/ledger_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ type QueryExecutor interface {
ExecuteQuery(namespace, query string) (commonledger.ResultsIterator, error)
// GetPrivateData gets the value of a private data item identified by a tuple <namespace, collection, key>
GetPrivateData(namespace, collection, key string) ([]byte, error)
// GetPrivateMetadata gets the metadata of a private data item identified by a tuple <namespace, collection, key>
GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error)
// GetPrivateDataMetadata gets the metadata of a private data item identified by a tuple <namespace, collection, key>
GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error)
// GetPrivateDataMultipleKeys gets the values for the multiple private data items in a single call
GetPrivateDataMultipleKeys(namespace, collection string, keys []string) ([][]byte, error)
// GetPrivateDataRangeScanIterator returns an iterator that contains all the key-values between given key ranges.
Expand Down Expand Up @@ -144,11 +144,9 @@ type TxSimulator interface {
DeleteState(namespace string, key string) error
// SetMultipleKeys sets the values for multiple keys in a single call
SetStateMultipleKeys(namespace string, kvs map[string][]byte) error
// SetStateMetadataEntry upserts an entry in the metadata for the given namespace and key
SetStateMetadataEntry(namespace, key, metakey string, metadata []byte) error
// DeleteStateMetadataEntry deletes the given entry from the metadata for the given namespace and key
DeleteStateMetadataEntry(namespace, key, metakey string) error
// DeleteStateMetadata deletes entire metadata for a given key
// SetStateMetadata sets the metadata associated with an existing key-tuple <namespace, key>
SetStateMetadata(namespace, key, metadata map[string][]byte) error
// DeleteStateMetadata deletes the metadata (if any) associated with an existing key-tuple <namespace, key>
DeleteStateMetadata(namespace, key string) error
// ExecuteUpdate for supporting rich data model (see comments on QueryExecutor above)
ExecuteUpdate(query string) error
Expand All @@ -158,12 +156,10 @@ type TxSimulator interface {
SetPrivateDataMultipleKeys(namespace, collection string, kvs map[string][]byte) error
// DeletePrivateData deletes the given tuple <namespace, collection, key> from private data
DeletePrivateData(namespace, collection, key string) error
// SetPrivateMetadataEntry upserts an entry in the metadata for a key in the private data state represented by the tuple <namespace, collection, key>
SetPrivateMetadataEntry(namespace, collection, key, metakey string, metadata []byte) error
// DeletePrivateMetadataEntry deletes the given entry from the metadata for a key in the private data state represented by the tuple <namespace, collection, key>
DeletePrivateMetadataEntry(namespace, collection, key, metakey string) error
// DeletePrivateMetadata deletes entire metadata for a given key in the private data state represented by the tuple <namespace, collection, key>
DeletePrivateMetadata(namespace, collection, key string) error
// SetPrivateDataMetadata sets the metadata associated with an existing key-tuple <namespace, collection, key>
SetPrivateDataMetadata(namespace, collection, key, metadata map[string][]byte) error
// DeletePrivateDataMetadata deletes the metadata associated with an existing key-tuple <namespace, collection, key>
DeletePrivateDataMetadata(namespace, collection, key string) error
// GetTxSimulationResults encapsulates the results of the transaction simulation.
// This should contain enough detail for
// - The update in the state that would be caused if the transaction is to be committed
Expand Down
16 changes: 4 additions & 12 deletions core/mocks/ccprovider/ccprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,31 +115,23 @@ func (m *MockTxSim) GetStateMetadata(namespace, key string) (map[string][]byte,
return nil, nil
}

func (m *MockTxSim) GetPrivateMetadata(namespace, collection, key string) (map[string][]byte, error) {
func (m *MockTxSim) GetPrivateDataMetadata(namespace, collection, key string) (map[string][]byte, error) {
return nil, nil
}

func (m *MockTxSim) SetStateMetadataEntry(namespace, key, metakey string, metadata []byte) error {
return nil
}

func (m *MockTxSim) DeleteStateMetadataEntry(namespace, key, metakey string) error {
func (m *MockTxSim) SetStateMetadata(namespace, key, metadata map[string][]byte) error {
return nil
}

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

func (m *MockTxSim) SetPrivateMetadataEntry(namespace, collection, key, metakey string, metadata []byte) error {
return nil
}

func (m *MockTxSim) DeletePrivateMetadataEntry(namespace, collection, key, metakey string) error {
func (m *MockTxSim) SetPrivateDataMetadata(namespace, collection, key, metadata map[string][]byte) error {
return nil
}

func (m *MockTxSim) DeletePrivateMetadata(namespace, collection, key string) error {
func (m *MockTxSim) DeletePrivateDataMetadata(namespace, collection, key string) error {
return nil
}

Expand Down
Loading

0 comments on commit fc733e6

Please sign in to comment.