-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMortgage.sol
44 lines (35 loc) · 1.01 KB
/
Mortgage.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pragma solidity ^0.5.0;
contract Mortgage {
address public owner;
mapping (bytes32=>address[]) public ownerMap;
mapping (address=>bytes32[]) public mortgageMap;
constructor() public {
owner = msg.sender;
}
function addData(bytes32 document) public {
address[] storage owners = ownerMap[document];
uint i;
for(i=0;i<owners.length; i++)
{
if(owners[i] == msg.sender)
return;
}
ownerMap[document].push(msg.sender);
uint count = mortgageMap[msg.sender].length;
for(i=0;i<count; i++)
{
if(mortgageMap[msg.sender][i] == document)
return;
}
mortgageMap[msg.sender].push(document);
}
function getMortgageCount(address person) public view returns(uint) {
return mortgageMap[person].length;
}
function getOwnerCount(bytes32 hash) public view returns(uint) {
return ownerMap[hash].length;
}
function getOwnerByPosition(bytes32 hash,uint index) public view returns(address) {
return ownerMap[hash][index];
}
}