-
Notifications
You must be signed in to change notification settings - Fork 508
/
cscc.go
48 lines (38 loc) · 1.08 KB
/
cscc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package resource
import (
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-protos-go/common"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"github.com/pkg/errors"
)
const (
cscc = "cscc"
csccJoinChannel = "JoinChain"
csccChannels = "GetChannels"
)
func createJoinChannelInvokeRequest(genesisBlock *common.Block) (fab.ChaincodeInvokeRequest, error) { //nolint
genesisBlockBytes, err := proto.Marshal(genesisBlock)
if err != nil {
return fab.ChaincodeInvokeRequest{}, errors.Wrap(err, "marshal genesis block failed")
}
// Create join channel transaction proposal for target peers
var args [][]byte
args = append(args, genesisBlockBytes)
cir := fab.ChaincodeInvokeRequest{
ChaincodeID: cscc,
Fcn: csccJoinChannel,
Args: args,
}
return cir, nil
}
func createChannelsInvokeRequest() fab.ChaincodeInvokeRequest {
cir := fab.ChaincodeInvokeRequest{
ChaincodeID: cscc,
Fcn: csccChannels,
}
return cir
}