Research Article
Based on Consortium Blockchain to Design a Credit Verifiable Cross University Course Learning System
Algorithm 4
Chaincode for the student to upload the hash value of his homework and examination.
| (1) | func (t ∗Chaincode) WorkUpload(APIstub shim.ChaincodeStubInterface, args []string) peer.Response { | | (2) | if len(args) ! = 2 { | | (3) | return shim.Error(“Incorrect number of arguments. Expecting 2″) | | (4) | } | | (5) | studentAsBytes, _: = APIstub.GetState(args[0]) | | (6) | student:= Student{} | | (7) | json.Unmarshal(studentAsBytes, &student) | | (8) | student.Hash = args[3]. | | (9) | studentAsBytes, _ = json.Marshal(student) | | (10) | APIstub.PutState(args[0], studentAsBytes) | | (11) | return shim.Success(nil) | | (12) | } |
|