|
Algorithm 2 Data management contracts |
-
1:
Data Structure:
-
2:
State Variables:
-
3:
▹ Contract constructor
-
4:
function uploadData(d, h)
-
5:
Require: onlyAuthorized
-
6:
-
7:
-
8:
Emit EventUpload
-
9:
end function
-
10:
function verifyData(r, d)
-
11:
if then
-
12:
Revert: “Record invalid”
-
13:
end if
-
14:
-
15:
if then
-
16:
Emit EventHashMismatch
-
17:
end if
-
18:
end function
-
19:
function checkAnomaly(r, p)
-
20:
if then
-
21:
Emit EventAnomaly
-
22:
end if
-
23:
end function
-
24:
function manageDeviceAccess(a, mode)
-
25:
if mode = admin then
-
26:
if then
-
27:
Revert: “Access denied”
-
28:
end if
-
29:
else if mode = authorize then
-
30:
Require:
-
31:
-
32:
else if mode = revoke then
-
33:
Require:
-
34:
-
35:
else if mode = check then
-
36:
if then
-
37:
Revert: “Device unauthorized”
-
38:
end if
-
39:
end if
-
40:
end function
|