diff --git a/contracts/standard/rng/BlockhashRNG.sol b/contracts/standard/rng/BlockhashRNG.sol index dad0bc88..f15fd0e1 100644 --- a/contracts/standard/rng/BlockhashRNG.sol +++ b/contracts/standard/rng/BlockhashRNG.sol @@ -1,15 +1,22 @@ + /** + * @authors: [@clesaege] + * @reviewers: [@remedcu] + * @auditors: [] + * @bounties: [] + * @deployments: [] + */ + +pragma solidity ^0.4.15; + +import "./RNG.sol"; + /** * @title Random Number Generator usign blockhash * @author Clément Lesaege - * * This contract implements the RNG standard and gives parties incentives to save the blockhash to avoid it to become unreachable after 256 blocks. * - */ -pragma solidity ^0.4.15; - -import "./RNG.sol"; - -/** Simple Random Number Generator returning the blockhash. + * Simple Random Number Generator returning the blockhash. * Allows saving the random number for use in the future. * It allows the contract to still access the blockhash even after 256 blocks. * The first party to call the save function gets the reward. @@ -19,8 +26,6 @@ contract BlockHashRNG is RNG { mapping (uint => uint) public randomNumber; // randomNumber[block] is the random number for this block, 0 otherwise. mapping (uint => uint) public reward; // reward[block] is the amount to be paid to the party w. - - /** @dev Contribute to the reward of a random number. * @param _block Block the random number is linked to. */ @@ -47,8 +52,6 @@ contract BlockHashRNG is RNG { function saveRN(uint _block) public { if (blockhash(_block) != 0x0) randomNumber[_block] = uint(blockhash(_block)); - else - randomNumber[_block] = getFallbackRN(_block); if (randomNumber[_block] != 0) { // If the number is set. uint rewardToSend = reward[_block]; @@ -57,10 +60,4 @@ contract BlockHashRNG is RNG { } } - /** @dev Fallback strategy. This class has no fallback. Subclass provides fallback strategy by overriding this method. - * @param _block Block the random number is linked to. - */ - function getFallbackRN(uint _block) internal view returns (uint) { - return 0x0; - } } diff --git a/contracts/standard/rng/BlockhashRNGFallback.sol b/contracts/standard/rng/BlockhashRNGFallback.sol index 691080af..0ecce1c5 100644 --- a/contracts/standard/rng/BlockhashRNGFallback.sol +++ b/contracts/standard/rng/BlockhashRNGFallback.sol @@ -1,31 +1,48 @@ + /** + * @authors: [@clesaege] + * @reviewers: [@remedcu] + * @auditors: [] + * @bounties: [] + * @deployments: [ https://etherscan.io/address/0x1738b62e403090666687243e758b1c29edffc90e ] + */ + +pragma solidity ^0.4.15; + +import "./BlockhashRNG.sol"; + /** * @title Random Number Generator using blockhash with fallback. * @author Clément Lesaege - - * + * * This contract implements the RNG standard and gives parties incentives to save the blockhash to avoid it to become unreachable after 256 blocks. * In case no one called it within the 256 blocks, it returns the previous blockhash. * This contract must be used when returning 0 is a worse failure mode than returning another blockhash. * Note that if someone calls it within the timeframe, this contracts acts exactly as BlockHashRNG. - */ -pragma solidity ^0.4.15; - -import "./BlockhashRNG.sol"; - -/** Random Number Generator returning the blockhash with a backup behaviour. - * Allows saving the random number for use in the future. + * + * Random Number Generator returning the blockhash with a backup behaviour. + * Allows saving the random number for use in the future. * It allows the contract to still access the blockhash even after 256 blocks. * The first party to call the save function gets the reward. - * If no one calls the contract within 256 blocks, the contract fallback in returning the blockhash of a block in range. + * If no one calls the contract within 256 blocks, the contract fallback in returning the blockhash of the previous block. */ contract BlockHashRNGFallback is BlockHashRNG { - - /** @dev Fallback by returning a blockhash in range. + + /** @dev Save the random number for this blockhash and give the reward to the caller. * @param _block Block the random number is linked to. */ - function getFallbackRN(uint _block) internal view returns (uint) { - if (_block >= block.number) { - return 0x0; + function saveRN(uint _block) public { + if (_block -* +* @dev This is an abstract contract */ - -pragma solidity ^0.4.15; - contract RNG{ /** @dev Contribute to the reward of a random number.