Skip to main content
. 2023 Jul 28;23(15):6751. doi: 10.3390/s23156751
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,id1,id2,t,trust1,trust2
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,id1,id2,t,trust1,trust2)
9:         end if
10:       % ReadTrust: Read a trust record.
11:       ctx.GetStub().GetState(N,id1,id2,t,trust1,trust2)
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,id1,id2,t,trust1,trust2)
17:       end if
18:    % DeleteTrust: Delete a trust record.
19:    return ctx.GetStub().DelState(N,id1,id2,t,trust1,trust2)
end