Skip to content

Commit

Permalink
FAB-845 integrate next version of protos
Browse files Browse the repository at this point in the history
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 <muralisr@us.ibm.com>
  • Loading branch information
Srinivasan Muralidharan committed Oct 28, 2016
1 parent bb413ce commit 157429c
Show file tree
Hide file tree
Showing 49 changed files with 2,102 additions and 1,765 deletions.
8 changes: 2 additions & 6 deletions bddtests/chaincode.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/util"
pb "github.com/hyperledger/fabric/protos"
putils "github.com/hyperledger/fabric/protos/utils"
)

func createChaincodeSpec(ccType string, path string, args [][]byte) *pb.ChaincodeSpec {
Expand All @@ -47,11 +48,6 @@ func createProposalForChaincode(ccChaincodeDeploymentSpec *pb.ChaincodeDeploymen
ChaincodeID: &pb.ChaincodeID{Name: "lccc"},
CtorMsg: &pb.ChaincodeInput{Args: [][]byte{[]byte("deploy"), []byte("default"), ccDeploymentSpecBytes}}}
lcChaincodeInvocationSpec := &pb.ChaincodeInvocationSpec{ChaincodeSpec: lcChaincodeSpec}
var ccLifecycleChaincodeInvocationSpecBytes []byte
if ccLifecycleChaincodeInvocationSpecBytes, err = proto.Marshal(lcChaincodeInvocationSpec); err != nil {
return nil, fmt.Errorf("Error creating proposal from ChaincodeDeploymentSpec: %s", err)
}
// make proposal
proposal = &pb.Proposal{Type: pb.Proposal_CHAINCODE, Id: createPropsalID(), Payload: ccLifecycleChaincodeInvocationSpecBytes}
return proposal, nil
return putils.CreateChaincodeProposal(lcChaincodeInvocationSpec)
}
94 changes: 47 additions & 47 deletions consensus/simplebft/simplebft.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions core/chaincode/chaincodeexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,21 @@ func createTx(typ pb.Transaction_Type, ccname string, args [][]byte) (*pb.Transa
}

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

// ExecuteChaincode executes a given chaincode given chaincode name and arguments
func ExecuteChaincode(ctxt context.Context, typ pb.Transaction_Type, chainname string, ccname string, args [][]byte) ([]byte, error) {
func ExecuteChaincode(ctxt context.Context, typ pb.Transaction_Type, chainname string, ccname string, args [][]byte) ([]byte, *pb.ChaincodeEvent, error) {
var tx *pb.Transaction
var err error
var b []byte
var ccevent *pb.ChaincodeEvent

tx, err = createTx(typ, ccname, args)
b, _, err = Execute(ctxt, GetChain(ChainName(chainname)), tx)
b, ccevent, err = Execute(ctxt, GetChain(ChainName(chainname)), tx)
if err != nil {
return nil, fmt.Errorf("Error deploying chaincode: %s", err)
return nil, nil, fmt.Errorf("Error deploying chaincode: %s", err)
}
return b, err
return b, ccevent, err
}
10 changes: 2 additions & 8 deletions core/chaincode/exectransaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/hyperledger/fabric/core/util"
"github.com/hyperledger/fabric/membersrvc/ca"
pb "github.com/hyperledger/fabric/protos"
putils "github.com/hyperledger/fabric/protos/utils"

"github.com/golang/protobuf/proto"
"github.com/spf13/viper"
Expand Down Expand Up @@ -178,17 +179,10 @@ func endTxSimulation(txsim ledger.TxSimulator, payload []byte, commit bool) erro
if txSimulationResults, err = txsim.GetTxSimulationResults(); err != nil {
return err
}
//create action bytes
action := &pb.Action{ProposalHash: util.ComputeCryptoHash([]byte("dummyProposal")), SimulationResult: txSimulationResults}
actionBytes, err := proto.Marshal(action)
tx, err := putils.CreateTx(pb.Header_CHAINCODE, util.ComputeCryptoHash([]byte("dummyProposal")), []byte("dummyCCEvents"), txSimulationResults, []*pb.Endorsement{&pb.Endorsement{}})
if err != nil {
return err
}
//create transaction with endorsed actions
tx := &pb.Transaction2{}
tx.EndorsedActions = []*pb.EndorsedAction{
&pb.EndorsedAction{ActionBytes: actionBytes, Endorsements: []*pb.Endorsement{&pb.Endorsement{Signature: []byte("--Endorsement signature--")}}, ProposalBytes: []byte{}}}

txBytes, err := proto.Marshal(tx)
if err != nil {
return err
Expand Down
47 changes: 24 additions & 23 deletions core/chaincode/shim/chaincode.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 157429c

Please sign in to comment.