Algorithm 1 Function |
-
Input:
userName, userAddress, role, department
-
Output:
userID
-
1:
Generate userID by hashing userName, userAddress, role, and department using
-
2:
Create a new user struct newUser with fields:
-
3:
userName: userName
-
4:
userAddress: userAddress
-
5:
role: role
-
6:
department: department
-
7:
Add newUser to the UserList mapping with key userID
-
8:
Update lastUserID to userID
-
9:
Emit event (userID, userName, userAddress, role, department)
-
10:
if users[userID].userAddress not equal to userAddress then
-
11:
Throw error “User not added correctly.”
-
12:
end if
-
13:
return
userID
|