-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.go
36 lines (32 loc) · 952 Bytes
/
start.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
package main
import (
"fmt"
"github.com/YasiruR/fabriK/chaincode/asset"
"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-contract-api-go/contractapi"
"github.com/tryfix/log"
"os"
)
func main() {
/* invoke chaincode as an external service */
log.Info(`starting chaincode as an external service`)
assetCC, err := contractapi.NewChaincode(&asset.SmartContract{})
if err != nil {
log.Fatal(fmt.Sprintf(`creating chaincode failed - %v`, err))
}
log.Info(`chaincode is created for asset use-case`)
ccID := os.Getenv(`CC_ID`)
ccAddr := os.Getenv(`CC_SERVER_ADDRESS`)
server := &shim.ChaincodeServer{
CCID: ccID,
Address: ccAddr,
CC: assetCC,
TLSProps: shim.TLSProperties{
Disabled: true,
},
}
log.Info(fmt.Sprintf("chaincode is up and running at %s with ID: %s", ccAddr, ccID))
if err = server.Start(); err != nil {
log.Fatal(fmt.Sprintf("starting server failed - %s", err))
}
}