Skip to content

Commit c9af3ef

Browse files
committed
Refactor the car platform driver
Various cleanups of the CAR platform driver 1) Consolidate functions in one place 2) Remove the unused hash.go code. Future hashing will be done outside of the platform drivers based on the cds.CodePackage 3) Remove the HTTP transport support. This makes little sense for .car deployment and was a carryover from the golang driver. Change-Id: I18166525f93c7e52967ec2e31f232649c688aede Signed-off-by: Greg Haskins <[email protected]>
1 parent bdba196 commit c9af3ef

File tree

4 files changed

+34
-158
lines changed

4 files changed

+34
-158
lines changed

core/chaincode/platforms/car/hash.go

-60
This file was deleted.

core/chaincode/platforms/car/package.go

-98
This file was deleted.

core/chaincode/platforms/car/platform.go

+34
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ limitations under the License.
1717
package car
1818

1919
import (
20+
"archive/tar"
21+
"fmt"
22+
"io/ioutil"
23+
"strings"
24+
25+
cutil "github.com/hyperledger/fabric/core/container/util"
2026
pb "github.com/hyperledger/fabric/protos/peer"
2127
)
2228

@@ -30,3 +36,31 @@ type Platform struct {
3036
func (carPlatform *Platform) ValidateSpec(spec *pb.ChaincodeSpec) error {
3137
return nil
3238
}
39+
40+
func (carPlatform *Platform) GetDeploymentPayload(spec *pb.ChaincodeSpec) ([]byte, error) {
41+
42+
return ioutil.ReadFile(spec.ChaincodeID.Path)
43+
}
44+
45+
func (carPlatform *Platform) GenerateDockerBuild(cds *pb.ChaincodeDeploymentSpec, tw *tar.Writer) (string, error) {
46+
47+
var buf []string
48+
var err error
49+
50+
spec := cds.ChaincodeSpec
51+
52+
//let the executable's name be chaincode ID's name
53+
buf = append(buf, cutil.GetDockerfileFromConfig("chaincode.car.Dockerfile"))
54+
buf = append(buf, "COPY codepackage.car /tmp/codepackage.car")
55+
// invoking directly for maximum JRE compatiblity
56+
buf = append(buf, fmt.Sprintf("RUN java -jar /usr/local/bin/chaintool buildcar /tmp/codepackage.car -o $GOPATH/bin/%s && rm /tmp/codepackage.car", spec.ChaincodeID.Name))
57+
58+
dockerFileContents := strings.Join(buf, "\n")
59+
60+
err = cutil.WriteBytesToPackage("codepackage.car", cds.CodePackage, tw)
61+
if err != nil {
62+
return "", err
63+
}
64+
65+
return dockerFileContents, nil
66+
}

0 commit comments

Comments
 (0)