| Algorithm 2: Trust Management Based on Smart Contract. |
|
Input: Fusion trust Output: Ledger begin 1: % InitTrust: Initialize the ledger and assign initial values to the trust values. 2: define a structure Trust containing N,,,t,, 3: Assign an initial value to each structure element 4: % CreateTrust: Set a new trust record. 5: Define a newly written trust value 6: Check if the trust value is repeated 7: if not repeated then 8: return ctx.GetStub().PutState(N,,,t,,) 9: end if 10: % ReadTrust: Read a trust record. 11: ctx.GetStub().GetState(N,,,t,,) 12: % UpdateTrust: Update the trust value. 13: Change the value of trust 14: Check if the trust value is repeated 15: if not repeated then 16: return ctx.GetStub().PutState(N,,,t,,) 17: end if 18: % DeleteTrust: Delete a trust record. 19: return ctx.GetStub().DelState(N,,,t,,) end |