-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtc.go
More file actions
46 lines (40 loc) · 1.23 KB
/
htc.go
File metadata and controls
46 lines (40 loc) · 1.23 KB
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
package main
import (
"fmt"
. "github.com/Akachain/akc-go-sdk/common"
"github.com/Akachain/akc-htc-sdk/pkg/htc"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
// Chaincode implementation
type Chaincode struct {
}
func (s *Chaincode) Init(stub shim.ChaincodeStubInterface) pb.Response {
return shim.Success(nil)
}
func createData(stub shim.ChaincodeStubInterface, args []string) pb.Response {
err := htc.NewHighThroughput(stub, "test", "test", "+", "abc", 100)
if err != nil {
resErr := ResponseError{ResCode: "500", Msg: ""}
return RespondError(resErr)
}
resSuc := ResponseSuccess{ResCode: SUCCESS, Msg: ResCodeDict[SUCCESS], Payload: ""}
return RespondSuccess(resSuc)
}
func (s *Chaincode) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
// Retrieve the requested Smart Contract function and arguments
function, args := stub.GetFunctionAndParameters()
switch function {
//CreateAdmin
case "CreateNew":
return createData(stub, args)
}
return shim.Error(fmt.Sprintf("Invoke cannot find function " + function))
}
func main() {
// Create a new Chain code
err := shim.Start(new(Chaincode))
if err != nil {
fmt.Printf("Error creating new Chain code: %s", err)
}
}