Skip to content

Commit

Permalink
Add version of chaincode to config params
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Guo <[email protected]>
  • Loading branch information
guoger committed Nov 6, 2020
1 parent 4ebb0ad commit 82d72f6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Modify `config.json` according to your network. This is a sample:
"orderer_addr": "orderer.example.com:7050",
"channel": "mychannel",
"chaincode": "mycc",
"version": "",
"args": ["put", "key", "value"],
"mspid": "Org1MSP",
"private_key": "wallet/priv.key",
Expand Down Expand Up @@ -79,6 +80,8 @@ crypto-config/peerOrganizations/org1.example.com/users/[email protected]/ms

`chaincode`: chaincode to invoke. There is an example chaincode in `chaincodes/sample.go`, which simply puts `key:value`. This is closely related to `args` parameter.

`version`: the version of chaincode. This is left to empty by default.

`args`: arguments to send with invocation, depending on your chaincode implementation. The chaincode used by this sample can be found in `chaincodes/sample.go`

`num_of_conn`: number of gRPC connection established between client/peer, client/orderer. If you think client has not put enough pressure on Fabric, increase this.
Expand Down
1 change: 1 addition & 0 deletions infra/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Config struct {
OrdererAddr string `json:"orderer_addr"`
Channel string `json:"channel"`
Chaincode string `json:"chaincode"`
Version string `json:"version"`
Args []string `json:"args"`
MSPID string `json:"mspid"`
PrivateKey string `json:"private_key"`
Expand Down
4 changes: 2 additions & 2 deletions infra/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import (
"github.com/pkg/errors"
)

func CreateProposal(signer *Crypto, channel, ccname string, args ...string) *peer.Proposal {
func CreateProposal(signer *Crypto, channel, ccname, version string, args ...string) *peer.Proposal {
var argsInByte [][]byte
for _, arg := range args {
argsInByte = append(argsInByte, []byte(arg))
}

spec := &peer.ChaincodeSpec{
Type: peer.ChaincodeSpec_GOLANG,
ChaincodeId: &peer.ChaincodeID{Name: ccname},
ChaincodeId: &peer.ChaincodeID{Name: ccname, Version: version},
Input: &peer.ChaincodeInput{Args: argsInByte},
}

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func main() {
crypto,
config.Channel,
config.Chaincode,
config.Version,
config.Args...,
)
raw <- &infra.Elecments{Proposal: prop}
Expand Down

0 comments on commit 82d72f6

Please sign in to comment.