This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
contract PoL { | |
// Declare variables, structures, mapping functions, events | |
struct pol { | |
address receiver; | |
uint initialBlockNumber; | |
uint deposit; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recoverBalance(address _owner) | |
public | |
payable | |
{ | |
require(msg.value > 0); | |
require(!existedPoL(_owner)); | |
address _receiver = msg.sender; | |
getPoL[_owner].receiver = _receiver; | |
getPoL[_owner].initialBlockNumber = block.number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rejectPoL() | |
public | |
{ | |
address _owner = msg.sender; | |
require(existedPoL(_owner)); | |
uint _value = getPoL[_owner].deposit; | |
bool _success = _owner.send(_value); | |
if (_success) { | |
getPoL[_owner].receiver = address(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() payable { | |
address _owner = msg.sender; | |
uint _value = msg.value; | |
require(_value > 0); | |
require(isValidPoL(_owner)); | |
bool _success = approvePoL(_owner, _value); | |
if (_success) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function approvePoL(address _owner, uint _value) | |
private | |
returns (bool) | |
{ | |
address _receiver = getPoL[_owner].receiver; | |
bool _success = _receiver.send(_value); | |
return _success; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hash algorithm is Keccak256 | |
// The raw values are 'rock', 'scissors' and 'paper' | |
var hashOfRock = '10977e4d68108d418408bc9310b60fc6d0a750c63ccef42cfb0ead23ab73d102'; | |
var hashOfScissors = '389a2d4e358d901bfdf22245f32b4b0a401cc16a4b92155a2ee5da98273dad9a'; | |
var hashOfPaper = 'ea923ca2cdda6b54f4fb2bf6a063e5a59a6369ca4c4ae2c4ce02a147b3036a21'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hash algorithm is Keccak256 | |
var s = Math.floor((Math.random() * 1000000000) + 1); // s = 830178382 | |
var selection = ‘rock’; | |
var combination = selection + s; // combination = ‘rock830178382’ | |
var hashOfCombination = keccak256(combination); | |
// hashOfCombination = 4d49bb261ecb887e152051da601d028e070635d24da07da2828fca8fecedee50 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Root: {1: 'Dog', 2: B, 3: A} | |
A: {1: C, 2: D, 3: 'Cat'} | |
B: {1: 'Goat', 2: 'Bear', 3: 'Rat'} | |
C: {1: 'Eagle', 2: 'Parrot', 3: E} | |
D: {1: 'Shark', 2: 'Dolphin', 3: 'Whale'} | |
E: {1: 'Duck', 2: 'Chinken', 3: 'Pig'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node type path length | prefix hexchar | |
-------------------------------------------------- | |
extension even | 0000 0x0 | |
extension odd | 0001 0x1 | |
leaf even | 0010 0x2 | |
leaf odd | 0011 0x3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> [ 1, 2, 3, 4, 5] | |
'11 23 45' | |
> [ 0, 1, 2, 3, 4, 5] | |
'00 01 23 45' | |
> [ 0, f, 1, c, b, 8, 16] | |
'20 0f 1c b8' | |
> [ f, 1, c, b, 8, 16] | |
'3f 1c b8' |
OlderNewer