Skip to main content
. 2022 Oct 26;22(21):8186. doi: 10.3390/s22218186
Algorithm 4 Responding to a service request using the service broker.
Require:
B:   Global state of the blockchain.
P:   Service broker smart contract caller.
Ireq:    UUID of the request to which the response answers.
Tres: Date and time when the response is created.
Ures:   The request processing status.
Rres:   Optional value to be returned to the service request sender.
Ensure:
 Service request information is saved in the blockchain.
 1: if WRITE GetCallerPermissions (P) then
 2:  return error      ▹ Abort if caller is not allowed to update the blockchain
 3: end if
 4: if GetService (Iorg,Idev,Nsrv)= then
 5:  return error             ▹ Abort if requested service is not registered
 6: end if
 7: Sreq= GetServiceRequest (Ireq)
 8: if Sreq= then
 9:  return error               ▹ Abort if service request does not exist
 10: end if
 11: if GetDeviceId (Sreq) GetContractCallerId (P) then
 12:  return error            ▹ Abort if caller impersonates another device
 13: end if
 14: if GetOrganizationId (Sreq) GetContractCallerOrgId (P) then
 15:  return error      ▹ Abort if caller impersonates another organization
 16: end if
 17: Sres Serialize (Ireq,Tres,Ures,Rres)
 18: B[Ireq]{Sreq,Sres}
 19: NotifyEvent (Sres)
 20: return Sres