Guest User

Untitled

a guest
Dec 14th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. type Vote struct {
  2. RID string `json:"RID"`
  3. CID string `json:"CID"`
  4. Votes []Total `json:"Votes"`
  5. }
  6.  
  7. type Total struct {
  8. RID string
  9. CID string
  10. Votes string
  11. }
  12.  
  13. func vote_total(stub shim.ChaincodeStubInterface, args []string) pb.Response {
  14. var jsonResp string
  15. var err error
  16. if len(args) != 1 {
  17. return shim.Error("Incorrrect number of arguments")
  18. }
  19. rid := args[0]
  20. voteAsBytes, err := stub.GetState(rid)
  21. if err != nil {
  22. jsonResp = "{"Error":"failed to get state for" + rid + ""}"
  23. return shim.Error(jsonResp)
  24. }
  25. var vote Vote
  26. json.Unmarshal(voteAsBytes, &vote)
  27. fmt.Println(vote)
  28. return shim.Success(voteAsBytes)
  29. }
Add Comment
Please, Sign In to add comment