01: pragma solidity 0.4.23; |
02: contract ConsentPerDataSubjectDevice |
03: mapping (bytes32 => ConsentVersion) controller; |
//the address of the ADVOCATE platform |
04: address private ADVOCATE = 0x583031d1113ad414f02576bd6afabfb302140225; |
05: bytes32 subjectHash = 0xd35f61ad141d7b92f4c17e609ef394292ca0e9341942c55...; |
06: bytes32 deviceHash = 0xa018a0957ed590aeb053fa0561ea90453e260eca1846f...; |
07: struct ConsentVersion |
08: bytes32 consentHash; |
09: mapping (bytes32 => uint256) timeStamp; |
10: |
//Function 1: add new consent for a data controller |
11: function addConsent(bytes32 _ctlhash, bytes32 _csthash) public |
12: require(msg.sender == ADVOCATE); //only the owner can add new values |
13: controller[_ctlhash].consentHash.push(_csthash); |
14: controller[_ctlhash].timeStamp[_csthash] = now; |
15: |
//Function 2: return the hash of the last consent for a data controller |
16: function getLastConsent(bytes32 _ctlhash) view public returns (bytes32) |
17: if (controller[_ctlhash].consentHash.length == 0) return 0; |
18: else return controller[_ctlhash].consentHash[controller[_ctlhash].consentHash.length - 1]; |
19: |
//Function 3: return the time of consent for a data controller |
20: function getTime(bytes32 _ctlhash, bytes32 _csthash) view public returns (uint256) |
21: return controller[_ctlhash].timeStamp[_csthash]; |
22: |
//Function 4: return all the consents for a data controller |
23: function getAll(bytes32 _ctlhash) view public returns (bytes32) |
24: return controller[_ctlhash].consentHash; |
25: |
26: |