Skip to content
Verified contractPartial

Ranking

Address0xd9d3c812c9b508da606ff5b0945d9af5385d47e5
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.1.3

 

Same code

Only this contract

 

Details

Compiler
solc 0.1.3+commit.028f561d
Language
solidity
Optimization
No
License
Not stated
Match
Partialcreation code: no, runtime code: yes
Verified on Sourcify
Created in block
155,161
Creation transaction
0x325b1b5121…3eb9aa6fb1

Ranking.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
contract owned {
    address owner;

    function owned() {
        owner = msg.sender;
    }

    function transfer(address newOwner) returns (bool) {
        if (isOwner()) {
            owner = newOwner;
            return true;
        } else
            return false;
    }

    function isOwner() returns (bool) {
        return msg.sender == owner;
    }

    function isOwner(address a) returns (bool) {
        return a == owner;
    }

    function kill() {
        if (msg.sender == owner) suicide(owner);
    }
}

contract Ranking is owned {
    struct Item {
        bool exists;
        address next;
        address prev;
        int votes;
    }

    address public head;
    address public tail;
    uint public length;
    mapping (address => Item) public items;

    function Ranking() {
        tail = 0;
        tail = 0;
        length = 0;
    }

    function up(address a) returns (int) {
        if (msg.sender == owner) {
            if (items[a].exists) items[a].votes++;
            else insert(a, 1);
            return items[a].votes;
        }
    }

    function down(address a) returns (int) {
        if (msg.sender == owner) {
            if (items[a].exists) items[a].votes--;
            else insert(a, -1);
            return items[a].votes;
        }
    }

    function set(address a, int v) returns (int) {
        if (msg.sender == owner) {
            if (items[a].exists) items[a].votes = v;
            else insert(a, v);
            return items[a].votes;
        }
    }

    modifier listed(address x, bool exists) {
        if ((items[x].votes != 0) == exists) _
    }

    function insert(address a, int v) internal listed(a, false) {
        address oldHead = head;
        items[oldHead].prev = a;
        items[a] = Item(true, oldHead, 0, v);
        head = a;
        length++;
        if (tail == address(0)) tail = a;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": false
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.