Skip to content

Commit b0347cf

Browse files
author
Jason Yellick
committed
FAB-16158 Remove unused interface methods
The ccprovider.ChaincodeDefinition interface needs to go away. We should instead have lifecycle return a concrete type. However, as there are currently no consumers of the name or hash fields of this interface, let's remove them to prevent new deps from forming. Change-Id: I11512af8e1a1fec116b6a602ed08a3a1f9332710 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent ca2e59f commit b0347cf

File tree

7 files changed

+0
-47
lines changed

7 files changed

+0
-47
lines changed

core/chaincode/chaincode_ginkgo_support_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var _ = Describe("CheckInvocation", func() {
5555

5656
BeforeEach(func() {
5757
chaincodeDefinition = &lifecycle.LegacyDefinition{
58-
Name: "definition-name",
5958
Version: "definition-version",
6059
CCIDField: "definition-ccid",
6160
}

core/chaincode/chaincode_support_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ func initMockPeer(chainIDs ...string) (*peer.Peer, *ChaincodeSupport, func(), er
183183
}, nil
184184
case "lscc":
185185
return &lifecycle.LegacyDefinition{
186-
Name: "lscc",
187186
Version: "syscc",
188187
CCIDField: "lscc.syscc",
189188
}, nil

core/chaincode/exectransaction_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ func initPeer(chainIDs ...string) (*cm.Lifecycle, net.Listener, *ChaincodeSuppor
111111
switch name {
112112
case "lscc":
113113
return &lifecycle.LegacyDefinition{
114-
Name: "lscc",
115114
Version: "syscc",
116115
CCIDField: "lscc.syscc",
117116
}, nil
@@ -619,7 +618,6 @@ func TestChaincodeInvokeChaincode(t *testing.T) {
619618
switch name {
620619
case "lscc":
621620
return &lifecycle.LegacyDefinition{
622-
Name: "lscc",
623621
Version: "syscc",
624622
CCIDField: "lscc.syscc",
625623
}, nil
@@ -758,7 +756,6 @@ func TestChaincodeInvokeChaincodeErrorCase(t *testing.T) {
758756
switch name {
759757
case "lscc":
760758
return &lifecycle.LegacyDefinition{
761-
Name: "lscc",
762759
Version: "syscc",
763760
CCIDField: "lscc.syscc",
764761
}, nil

core/chaincode/lifecycle/legacy_lifecycle.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77
package lifecycle
88

99
import (
10-
"github.com/hyperledger/fabric/common/util"
1110
"github.com/hyperledger/fabric/core/common/ccprovider"
1211
"github.com/hyperledger/fabric/core/ledger"
1312
"github.com/hyperledger/fabric/core/scc"
@@ -34,26 +33,12 @@ type ChaincodeInfoCache interface {
3433
// It is a different data-type to allow differentiation at cast-time from
3534
// chaincode definitions which require validaiton of instantiation policy.
3635
type LegacyDefinition struct {
37-
Name string
3836
Version string
3937
EndorsementPlugin string
4038
RequiresInitField bool
4139
CCIDField string
4240
}
4341

44-
// CCName returns the chaincode name
45-
func (ld *LegacyDefinition) CCName() string {
46-
return ld.Name
47-
}
48-
49-
// Hash returns the hash of <name>:<version>. This is useless, but
50-
// is a hack to allow the rest of the code to have consistent view of
51-
// what hash means for a chaincode definition. Ultimately, this should
52-
// be removed.
53-
func (ld *LegacyDefinition) Hash() []byte {
54-
return util.ComputeSHA256([]byte(ld.Name + ":" + ld.Version))
55-
}
56-
5742
// CCVersion returns the version of the chaincode.
5843
func (ld *LegacyDefinition) CCVersion() string {
5944
return ld.Version
@@ -135,7 +120,6 @@ func (cei *ChaincodeEndorsementInfo) CachedChaincodeInfo(channelID, chaincodeNam
135120
func (cei *ChaincodeEndorsementInfo) ChaincodeDefinition(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (ccprovider.ChaincodeDefinition, error) {
136121
if cei.BuiltinSCCs.IsSysCC(chaincodeName) {
137122
return &LegacyDefinition{
138-
Name: chaincodeName,
139123
Version: scc.SysCCVersion,
140124
EndorsementPlugin: "escc",
141125
RequiresInitField: false,
@@ -154,7 +138,6 @@ func (cei *ChaincodeEndorsementInfo) ChaincodeDefinition(channelID, chaincodeNam
154138
chaincodeDefinition := chaincodeInfo.Definition
155139

156140
return &LegacyDefinition{
157-
Name: chaincodeName,
158141
Version: chaincodeDefinition.EndorsementInfo.Version,
159142
EndorsementPlugin: chaincodeDefinition.EndorsementInfo.EndorsementPlugin,
160143
RequiresInitField: chaincodeDefinition.EndorsementInfo.InitRequired,

core/chaincode/lifecycle/legacy_lifecycle_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package lifecycle_test
99
import (
1010
"fmt"
1111

12-
"github.com/hyperledger/fabric/common/util"
1312
"github.com/hyperledger/fabric/core/chaincode/lifecycle"
1413
"github.com/hyperledger/fabric/core/chaincode/lifecycle/mock"
1514
"github.com/hyperledger/fabric/core/common/ccprovider"
@@ -186,7 +185,6 @@ var _ = Describe("ChaincodeEndorsementInfo", func() {
186185
def, err := cei.ChaincodeDefinition("channel-id", "name", fakeQueryExecutor)
187186
Expect(err).NotTo(HaveOccurred())
188187
Expect(def).To(Equal(&lifecycle.LegacyDefinition{
189-
Name: "name",
190188
Version: "version",
191189
EndorsementPlugin: "endorsement-plugin",
192190
CCIDField: "hash",
@@ -202,7 +200,6 @@ var _ = Describe("ChaincodeEndorsementInfo", func() {
202200
res, err := cei.ChaincodeDefinition("channel-id", "test-syscc-name", fakeQueryExecutor)
203201
Expect(err).NotTo(HaveOccurred())
204202
Expect(res).To(Equal(&lifecycle.LegacyDefinition{
205-
Name: "test-syscc-name",
206203
Version: "syscc",
207204
EndorsementPlugin: "escc",
208205
CCIDField: "test-syscc-name.syscc",
@@ -229,7 +226,6 @@ var _ = Describe("ChaincodeEndorsementInfo", func() {
229226
BeforeEach(func() {
230227
delete(fakePublicState, "namespaces/fields/name/Sequence")
231228
legacyChaincodeDefinition = &ccprovider.ChaincodeData{
232-
Name: "definition-name",
233229
Version: "definition-version",
234230
}
235231

@@ -257,31 +253,18 @@ var _ = Describe("LegacyDefinition", func() {
257253

258254
BeforeEach(func() {
259255
ld = &lifecycle.LegacyDefinition{
260-
Name: "name",
261256
Version: "version",
262257
EndorsementPlugin: "endorsement-plugin",
263258
RequiresInitField: true,
264259
}
265260
})
266261

267-
Describe("CCName", func() {
268-
It("returns the name", func() {
269-
Expect(ld.CCName()).To(Equal("name"))
270-
})
271-
})
272-
273262
Describe("CCVersion", func() {
274263
It("returns the version", func() {
275264
Expect(ld.CCVersion()).To(Equal("version"))
276265
})
277266
})
278267

279-
Describe("Hash", func() {
280-
It("returns the sha256 hash of name and version", func() {
281-
Expect(ld.Hash()).To(Equal(util.ComputeSHA256([]byte("name:version"))))
282-
})
283-
})
284-
285268
Describe("Endorsement", func() {
286269
It("returns the endorsment plugin name", func() {
287270
Expect(ld.Endorsement()).To(Equal("endorsement-plugin"))

core/common/ccprovider/ccprovider.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,6 @@ func GetInstalledChaincodes() (*pb.ChaincodeQueryResponse, error) {
360360
// ChaincodeDefinition describes all of the necessary information for a peer to decide whether to endorse
361361
// a proposal and whether to validate a transaction, for a particular chaincode.
362362
type ChaincodeDefinition interface {
363-
// CCName returns the name of this chaincode (the name it was put in the ChaincodeRegistry with).
364-
CCName() string
365-
366-
// Hash returns the hash of the chaincode.
367-
Hash() []byte
368-
369363
// CCVersion returns the version of the chaincode.
370364
CCVersion() string
371365

core/common/ccprovider/ccprovider_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,8 @@ func TestChaincodeData(t *testing.T) {
118118
Vscc: "Vscc",
119119
}
120120

121-
assert.Equal(t, cd.CCName(), "Name")
122121
assert.Equal(t, cd.CCVersion(), "Version")
123122
assert.Equal(t, cd.Endorsement(), "Escc")
124-
assert.Equal(t, cd.Hash(), []byte("Id"))
125123
assert.Equal(t, cd.RequiresInit(), false)
126124
}
127125

0 commit comments

Comments
 (0)