summaryrefslogtreecommitdiffstats
path: root/contracts/Recovery.sol
blob: 4b28b7a4d4be57f1a1dd395527e64a74953d6bb6 (plain) (blame)
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
pragma solidity ^0.5.0;

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";

contract Recovery is Ownable {
    uint256 public depositValue;

    mapping(uint256 => address[]) public votes;
    mapping(uint256 => mapping(address => bool)) public voted;

    event VotedForRecovery(uint256 indexed height, address voter);

    function setDeposit(uint256 DepositValue) public onlyOwner {
        depositValue = DepositValue;
    }

    function withdraw() public onlyOwner {
        msg.sender.transfer(address(this).balance);
    }

    function voteForSkipBlock(uint256 height) public payable {
        require(msg.value >= depositValue);
        require(!voted[height][msg.sender]);

        votes[height].push(msg.sender);
        voted[height][msg.sender] = true;

        emit VotedForRecovery(height, msg.sender);
    }

    function numVotes(uint256 height) public returns (uint256) {
        return votes[height].length;
    }
}