Skip to content

Commit f5182d4

Browse files
author
Jason Yellick
committed
FAB-11024 ChaincodeContainerInfo to ccprovider
Prior to changing the ChaincodeProvider interface to use ChaincodeContainerInfo instead of DeploymentSpecs, the ChaincodeContainerInfo must be removed from the chaincode/lifecycle package to avoid import cycles. Change-Id: I9928726d4fcb04dc31841ba392fd20130448d8ae Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent 5f9de08 commit f5182d4

File tree

10 files changed

+60
-60
lines changed

10 files changed

+60
-60
lines changed

core/chaincode/chaincode_support.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626

2727
// Runtime is used to manage chaincode runtime instances.
2828
type Runtime interface {
29-
Start(ccci *lifecycle.ChaincodeContainerInfo, codePackage []byte) error
30-
Stop(ccci *lifecycle.ChaincodeContainerInfo) error
29+
Start(ccci *ccprovider.ChaincodeContainerInfo, codePackage []byte) error
30+
Stop(ccci *ccprovider.ChaincodeContainerInfo) error
3131
}
3232

3333
// Launcher is used to launch chaincode runtimes.
3434
type Launcher interface {
35-
Launch(ccci *lifecycle.ChaincodeContainerInfo) error
35+
Launch(ccci *ccprovider.ChaincodeContainerInfo) error
3636
}
3737

3838
// Lifecycle provides a way to retrieve chaincode definitions and the packages necessary to run them
@@ -41,7 +41,7 @@ type Lifecycle interface {
4141
GetChaincodeDefinition(chaincodeName string, txSim ledger.QueryExecutor) (ccprovider.ChaincodeDefinition, error)
4242

4343
// ChaincodeContainerInfo returns the package necessary to launch a chaincode
44-
ChaincodeContainerInfo(chainID string, chaincodeID string) (*lifecycle.ChaincodeContainerInfo, error)
44+
ChaincodeContainerInfo(chainID string, chaincodeID string) (*ccprovider.ChaincodeContainerInfo, error)
4545
}
4646

4747
// ChaincodeSupport responsible for providing interfacing with chaincodes from the Peer.

core/chaincode/chaincode_support_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ func getLaunchConfigs(t *testing.T, cr *ContainerRuntime) {
10261026
func TestStartAndWaitSuccess(t *testing.T) {
10271027
handlerRegistry := NewHandlerRegistry(false)
10281028
fakeRuntime := &mock.Runtime{}
1029-
fakeRuntime.StartStub = func(_ *lifecycle.ChaincodeContainerInfo, _ []byte) error {
1029+
fakeRuntime.StartStub = func(_ *ccprovider.ChaincodeContainerInfo, _ []byte) error {
10301030
handlerRegistry.Ready("testcc:0")
10311031
return nil
10321032
}
@@ -1042,7 +1042,7 @@ func TestStartAndWaitSuccess(t *testing.T) {
10421042
PackageProvider: fakePackageProvider,
10431043
}
10441044

1045-
ccci := &lifecycle.ChaincodeContainerInfo{
1045+
ccci := &ccprovider.ChaincodeContainerInfo{
10461046
Type: "GOLANG",
10471047
Name: "testcc",
10481048
Version: "0",
@@ -1059,7 +1059,7 @@ func TestStartAndWaitSuccess(t *testing.T) {
10591059
//test timeout error
10601060
func TestStartAndWaitTimeout(t *testing.T) {
10611061
fakeRuntime := &mock.Runtime{}
1062-
fakeRuntime.StartStub = func(_ *lifecycle.ChaincodeContainerInfo, _ []byte) error {
1062+
fakeRuntime.StartStub = func(_ *ccprovider.ChaincodeContainerInfo, _ []byte) error {
10631063
time.Sleep(time.Second)
10641064
return nil
10651065
}
@@ -1075,7 +1075,7 @@ func TestStartAndWaitTimeout(t *testing.T) {
10751075
PackageProvider: fakePackageProvider,
10761076
}
10771077

1078-
ccci := &lifecycle.ChaincodeContainerInfo{
1078+
ccci := &ccprovider.ChaincodeContainerInfo{
10791079
Type: "GOLANG",
10801080
Name: "testcc",
10811081
Version: "0",
@@ -1092,7 +1092,7 @@ func TestStartAndWaitTimeout(t *testing.T) {
10921092
//test container return error
10931093
func TestStartAndWaitLaunchError(t *testing.T) {
10941094
fakeRuntime := &mock.Runtime{}
1095-
fakeRuntime.StartStub = func(_ *lifecycle.ChaincodeContainerInfo, _ []byte) error {
1095+
fakeRuntime.StartStub = func(_ *ccprovider.ChaincodeContainerInfo, _ []byte) error {
10961096
return errors.New("Bad lunch; upset stomach")
10971097
}
10981098

@@ -1107,7 +1107,7 @@ func TestStartAndWaitLaunchError(t *testing.T) {
11071107
PackageProvider: fakePackageProvider,
11081108
}
11091109

1110-
ccci := &lifecycle.ChaincodeContainerInfo{
1110+
ccci := &ccprovider.ChaincodeContainerInfo{
11111111
Type: "GOLANG",
11121112
Name: "testcc",
11131113
Version: "0",

core/chaincode/container_runtime.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"strings"
1414

1515
"github.com/hyperledger/fabric/core/chaincode/accesscontrol"
16-
"github.com/hyperledger/fabric/core/chaincode/lifecycle"
1716
"github.com/hyperledger/fabric/core/chaincode/platforms"
17+
"github.com/hyperledger/fabric/core/common/ccprovider"
1818
"github.com/hyperledger/fabric/core/container"
1919
"github.com/hyperledger/fabric/core/container/ccintf"
2020
pb "github.com/hyperledger/fabric/protos/peer"
@@ -44,7 +44,7 @@ type ContainerRuntime struct {
4444
}
4545

4646
// Start launches chaincode in a runtime environment.
47-
func (c *ContainerRuntime) Start(ccci *lifecycle.ChaincodeContainerInfo, codePackage []byte) error {
47+
func (c *ContainerRuntime) Start(ccci *ccprovider.ChaincodeContainerInfo, codePackage []byte) error {
4848
cname := ccci.Name + ":" + ccci.Version
4949

5050
lc, err := c.LaunchConfig(cname, ccci.Type)
@@ -82,7 +82,7 @@ func (c *ContainerRuntime) Start(ccci *lifecycle.ChaincodeContainerInfo, codePac
8282
}
8383

8484
// Stop terminates chaincode and its container runtime environment.
85-
func (c *ContainerRuntime) Stop(ccci *lifecycle.ChaincodeContainerInfo) error {
85+
func (c *ContainerRuntime) Stop(ccci *ccprovider.ChaincodeContainerInfo) error {
8686
scr := container.StopContainerReq{
8787
CCID: ccintf.CCID{
8888
Name: ccci.Name,

core/chaincode/container_runtime_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111

1212
"github.com/hyperledger/fabric/core/chaincode"
1313
"github.com/hyperledger/fabric/core/chaincode/accesscontrol"
14-
"github.com/hyperledger/fabric/core/chaincode/lifecycle"
1514
"github.com/hyperledger/fabric/core/chaincode/mock"
15+
"github.com/hyperledger/fabric/core/common/ccprovider"
1616
"github.com/hyperledger/fabric/core/container"
1717
"github.com/hyperledger/fabric/core/container/ccintf"
1818
pb "github.com/hyperledger/fabric/protos/peer"
@@ -163,7 +163,7 @@ func TestContainerRuntimeStart(t *testing.T) {
163163
PeerAddress: "peer.example.com",
164164
}
165165

166-
ccci := &lifecycle.ChaincodeContainerInfo{
166+
ccci := &ccprovider.ChaincodeContainerInfo{
167167
Type: pb.ChaincodeSpec_GOLANG.String(),
168168
Name: "chaincode-name",
169169
Version: "chaincode-version",
@@ -208,7 +208,7 @@ func TestContainerRuntimeStartErrors(t *testing.T) {
208208
PeerAddress: "peer.example.com",
209209
}
210210

211-
ccci := &lifecycle.ChaincodeContainerInfo{
211+
ccci := &ccprovider.ChaincodeContainerInfo{
212212
Type: tc.chaincodeType,
213213
Name: "chaincode-id-name",
214214
Version: "chaincode-version",
@@ -225,7 +225,7 @@ func TestContainerRuntimeStop(t *testing.T) {
225225
Processor: fakeProcessor,
226226
}
227227

228-
ccci := &lifecycle.ChaincodeContainerInfo{
228+
ccci := &ccprovider.ChaincodeContainerInfo{
229229
Type: pb.ChaincodeSpec_GOLANG.String(),
230230
Name: "chaincode-id-name",
231231
Version: "chaincode-version",
@@ -265,7 +265,7 @@ func TestContainerRuntimeStopErrors(t *testing.T) {
265265
Processor: fakeProcessor,
266266
}
267267

268-
ccci := &lifecycle.ChaincodeContainerInfo{
268+
ccci := &ccprovider.ChaincodeContainerInfo{
269269
Type: pb.ChaincodeSpec_GOLANG.String(),
270270
Name: "chaincode-id-name",
271271
Version: "chaincode-version",

core/chaincode/lifecycle/lifecycle.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,8 @@ type Lifecycle struct {
2424
InstantiatedChaincodeStore InstantiatedChaincodeStore
2525
}
2626

27-
// ChaincodeContainerInfo is yet another synonym for the data required to start/stop a chaincode.
28-
type ChaincodeContainerInfo struct {
29-
Name string
30-
Version string
31-
Path string
32-
Type string
33-
34-
// ContainerType is not a great name, but 'DOCKER' and 'SYSTEM' are the valid types
35-
ContainerType string
36-
}
37-
3827
// GetChaincodeDeploymentSpec retrieves a chaincode deployment spec for the specified chaincode.
39-
func (l *Lifecycle) ChaincodeContainerInfo(channelID, chaincodeName string) (*ChaincodeContainerInfo, error) {
28+
func (l *Lifecycle) ChaincodeContainerInfo(channelID, chaincodeName string) (*ccprovider.ChaincodeContainerInfo, error) {
4029
cds, err := l.InstantiatedChaincodeStore.ChaincodeDeploymentSpec(channelID, chaincodeName)
4130
if err != nil {
4231
return nil, errors.Wrapf(err, "could not retrieve deployment spec for %s/%s", channelID, chaincodeName)
@@ -51,8 +40,8 @@ func (l *Lifecycle) GetChaincodeDefinition(chaincodeName string, txSim ledger.Qu
5140
return l.InstantiatedChaincodeStore.ChaincodeDefinition(chaincodeName, txSim)
5241
}
5342

54-
func DeploymentSpecToChaincodeContainerInfo(cds *pb.ChaincodeDeploymentSpec) *ChaincodeContainerInfo {
55-
return &ChaincodeContainerInfo{
43+
func DeploymentSpecToChaincodeContainerInfo(cds *pb.ChaincodeDeploymentSpec) *ccprovider.ChaincodeContainerInfo {
44+
return &ccprovider.ChaincodeContainerInfo{
5645
Name: cds.Name(),
5746
Version: cds.Version(),
5847
Path: cds.Path(),

core/chaincode/mock/lifecycle.go

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

core/chaincode/mock/runtime.go

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

core/chaincode/runtime_launcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package chaincode
99
import (
1010
"time"
1111

12-
"github.com/hyperledger/fabric/core/chaincode/lifecycle"
12+
"github.com/hyperledger/fabric/core/common/ccprovider"
1313
"github.com/hyperledger/fabric/core/container/inproccontroller"
1414
"github.com/pkg/errors"
1515
)
@@ -33,7 +33,7 @@ type RuntimeLauncher struct {
3333
StartupTimeout time.Duration
3434
}
3535

36-
func (r *RuntimeLauncher) Launch(ccci *lifecycle.ChaincodeContainerInfo) error {
36+
func (r *RuntimeLauncher) Launch(ccci *ccprovider.ChaincodeContainerInfo) error {
3737
var codePackage []byte
3838
if ccci.ContainerType != inproccontroller.ContainerType {
3939
var err error

core/chaincode/runtime_launcher_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111

1212
"github.com/hyperledger/fabric/core/chaincode"
1313
"github.com/hyperledger/fabric/core/chaincode/fake"
14-
lc "github.com/hyperledger/fabric/core/chaincode/lifecycle"
1514
"github.com/hyperledger/fabric/core/chaincode/mock"
15+
"github.com/hyperledger/fabric/core/common/ccprovider"
1616
. "github.com/onsi/ginkgo"
1717
. "github.com/onsi/gomega"
1818
"github.com/pkg/errors"
@@ -25,7 +25,7 @@ var _ = Describe("RuntimeLauncher", func() {
2525
fakeRegistry *fake.LaunchRegistry
2626
launchState *chaincode.LaunchState
2727

28-
ccci *lc.ChaincodeContainerInfo
28+
ccci *ccprovider.ChaincodeContainerInfo
2929

3030
runtimeLauncher *chaincode.RuntimeLauncher
3131
)
@@ -36,15 +36,15 @@ var _ = Describe("RuntimeLauncher", func() {
3636
fakeRegistry.LaunchingReturns(launchState, nil)
3737

3838
fakeRuntime = &mock.Runtime{}
39-
fakeRuntime.StartStub = func(*lc.ChaincodeContainerInfo, []byte) error {
39+
fakeRuntime.StartStub = func(*ccprovider.ChaincodeContainerInfo, []byte) error {
4040
launchState.Notify(nil)
4141
return nil
4242
}
4343

4444
fakePackageProvider = &mock.PackageProvider{}
4545
fakePackageProvider.GetChaincodeCodePackageReturns([]byte("code-package"), nil)
4646

47-
ccci = &lc.ChaincodeContainerInfo{
47+
ccci = &ccprovider.ChaincodeContainerInfo{
4848
Name: "chaincode-name",
4949
Path: "chaincode-path",
5050
Version: "chaincode-version",
@@ -137,7 +137,7 @@ var _ = Describe("RuntimeLauncher", func() {
137137

138138
Context("when handler registration fails", func() {
139139
BeforeEach(func() {
140-
fakeRuntime.StartStub = func(*lc.ChaincodeContainerInfo, []byte) error {
140+
fakeRuntime.StartStub = func(*ccprovider.ChaincodeContainerInfo, []byte) error {
141141
launchState.Notify(errors.New("papaya"))
142142
return nil
143143
}

0 commit comments

Comments
 (0)