Skip to content

Commit 157429c

Browse files
author
Srinivasan Muralidharan
committed
FAB-845 integrate next version of protos
FAB-845 1. Next generation of protos have been brought from protos/next/*proto into protos/. 2. previous fabric_next.proto has been removed 3. protos/utils contails accessor functions used by ledger, chaincode, endorser packages. In particular all marshaling/unmarshaling is done in utils 4. the util functions DO NOT do signature generation or validation NOTE - we need to add tests for the new protos. Prev fabric-next_test.go has been deleted. Change-Id: Ide43d4c8afb4e62578cdac3c0011c6bd2f6c5b88 Signed-off-by: Srinivasan Muralidharan <[email protected]>
1 parent bb413ce commit 157429c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2102
-1765
lines changed

bddtests/chaincode.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/golang/protobuf/proto"
2323
"github.com/hyperledger/fabric/core/util"
2424
pb "github.com/hyperledger/fabric/protos"
25+
putils "github.com/hyperledger/fabric/protos/utils"
2526
)
2627

2728
func createChaincodeSpec(ccType string, path string, args [][]byte) *pb.ChaincodeSpec {
@@ -47,11 +48,6 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
4748
ChaincodeID: &pb.ChaincodeID{Name: "lccc"},
4849
CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
4950
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
50-
var ccLifecycleChaincodeInvocationSpecBytes []byte
51-
if ccLifecycleChaincodeInvocationSpecBytes, err = proto.Marshal(lcChaincodeInvocationSpec); err != nil {
52-
return nil, fmt.Errorf("Error creating proposal from ChaincodeDeploymentSpec: %s", err)
53-
}
5451
// make proposal
55-
proposal = &pb.Proposal{Type: pb.Proposal_CHAINCODE, Id: createPropsalID(), Payload: ccLifecycleChaincodeInvocationSpecBytes}
56-
return proposal, nil
52+
return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec)
5753
}

consensus/simplebft/simplebft.pb.go

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

core/chaincode/chaincodeexec.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,21 @@ func createTx(typ pb.Transaction_Type, ccname string, args [][]byte) (*pb.Transa
3939
}
4040

4141
func getCDSFromLCCC(ctxt context.Context, chainID string, chaincodeID string) ([]byte, error) {
42-
return ExecuteChaincode(ctxt, pb.Transaction_CHAINCODE_INVOKE, string(DefaultChain), "lccc", [][]byte{[]byte("getdepspec"), []byte(chainID), []byte(chaincodeID)})
42+
payload, _, err := ExecuteChaincode(ctxt, pb.Transaction_CHAINCODE_INVOKE, string(DefaultChain), "lccc", [][]byte{[]byte("getdepspec"), []byte(chainID), []byte(chaincodeID)})
43+
return payload, err
4344
}
4445

4546
// ExecuteChaincode executes a given chaincode given chaincode name and arguments
46-
func ExecuteChaincode(ctxt context.Context, typ pb.Transaction_Type, chainname string, ccname string, args [][]byte) ([]byte, error) {
47+
func ExecuteChaincode(ctxt context.Context, typ pb.Transaction_Type, chainname string, ccname string, args [][]byte) ([]byte, *pb.ChaincodeEvent, error) {
4748
var tx *pb.Transaction
4849
var err error
4950
var b []byte
51+
var ccevent *pb.ChaincodeEvent
5052

5153
tx, err = createTx(typ, ccname, args)
52-
b, _, err = Execute(ctxt, GetChain(ChainName(chainname)), tx)
54+
b, ccevent, err = Execute(ctxt, GetChain(ChainName(chainname)), tx)
5355
if err != nil {
54-
return nil, fmt.Errorf("Error deploying chaincode: %s", err)
56+
return nil, nil, fmt.Errorf("Error deploying chaincode: %s", err)
5557
}
56-
return b, err
58+
return b, ccevent, err
5759
}

core/chaincode/exectransaction_test.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/hyperledger/fabric/core/util"
3737
"github.com/hyperledger/fabric/membersrvc/ca"
3838
pb "github.com/hyperledger/fabric/protos"
39+
putils "github.com/hyperledger/fabric/protos/utils"
3940

4041
"github.com/golang/protobuf/proto"
4142
"github.com/spf13/viper"
@@ -178,17 +179,10 @@ func endTxSimulation(txsim ledger.TxSimulator, payload []byte, commit bool) erro
178179
if txSimulationResults, err = txsim.GetTxSimulationResults(); err != nil {
179180
return err
180181
}
181-
//create action bytes
182-
action := &pb.Action{ProposalHash: util.ComputeCryptoHash([]byte("dummyProposal")), SimulationResult: txSimulationResults}
183-
actionBytes, err := proto.Marshal(action)
182+
tx, err := putils.CreateTx(pb.Header_CHAINCODE, util.ComputeCryptoHash([]byte("dummyProposal")), []byte("dummyCCEvents"), txSimulationResults, []*pb.Endorsement{&pb.Endorsement{}})
184183
if err != nil {
185184
return err
186185
}
187-
//create transaction with endorsed actions
188-
tx := &pb.Transaction2{}
189-
tx.EndorsedActions = []*pb.EndorsedAction{
190-
&pb.EndorsedAction{ActionBytes: actionBytes, Endorsements: []*pb.Endorsement{&pb.Endorsement{Signature: []byte("--Endorsement signature--")}}, ProposalBytes: []byte{}}}
191-
192186
txBytes, err := proto.Marshal(tx)
193187
if err != nil {
194188
return err

core/chaincode/shim/chaincode.pb.go

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

0 commit comments

Comments
 (0)