Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Vote struct {
- RID string `json:"RID"`
- CID string `json:"CID"`
- Votes []Total `json:"Votes"`
- }
- type Total struct {
- RID string
- CID string
- Votes string
- }
- func vote_total(stub shim.ChaincodeStubInterface, args []string) pb.Response {
- var jsonResp string
- var err error
- if len(args) != 1 {
- return shim.Error("Incorrrect number of arguments")
- }
- rid := args[0]
- voteAsBytes, err := stub.GetState(rid)
- if err != nil {
- jsonResp = "{"Error":"failed to get state for" + rid + ""}"
- return shim.Error(jsonResp)
- }
- var vote Vote
- json.Unmarshal(voteAsBytes, &vote)
- fmt.Println(vote)
- return shim.Success(voteAsBytes)
- }
Add Comment
Please, Sign In to add comment