Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
/**
* @title FixedPointSafeMath
* @dev Math operations on fixed point represented using ether units
*/
library FixedPointSafeMath {
contract BurnableStakeBank2 is Staking {
// pseudo code for burnable stake bank 2 which the client gives the block number they want to stake
// add this to keep track of total stake at a given block
mapping (uint => uint) public totalStakedAt;
// ...
function stakeFor(address user, uint256 amount, bytes __data) public onlyWhenUnlocked {
// Cargo.toml
// [dependencies]
// bit-vec = "0.5.0"
/// Block Hash
type BlockHash = u64;
/// Block number (monotonically increasing)
type BlockNumber = u32;
@tavakyan
tavakyan / staking_optimized.py
Created June 5, 2018 05:52
Optimized staking
from collections import namedtuple
from random import randint
import bisect
# An epoch is a sequence of blocks to be proposed by a non-changing (static) list of stakers.
# A staker should be assigned a block fairly based on the amount of coins they have staked.
# Assume there exists 30 blocks per epoch and we want to select a staker to be a proposer for that block.
blocks_per_epoch = 30
@tavakyan
tavakyan / staking_solution_not_optimized.py
Last active June 5, 2018 05:30
staking_solution_not_optimized
from collections import namedtuple
from random import randint
# An epoch is a sequence of blocks to be proposed by a non-changing (static) list of stakers.
# A staker should be assigned a block fairly based on the amount of coins they have staked.
# Assume there exists 30 blocks per epoch and we want to select a staker to be a proposer for that block.
blocks_per_epoch = 30
# Each staker has a public key address and an associated balance.
@tavakyan
tavakyan / staking.py
Last active June 1, 2018 13:42
Staking Script
from collections import namedtuple
from random import randint
# An epoch is a sequence of blocks to be proposed by a non-changing (static) list of stakers.
# A staker should be assigned a block fairly based on the amount of coins they have staked.
# Assume there exists 30 blocks per epoch and we want to select a staker to be a proposer for each block.
blocks_per_epoch = 30
# Each staker has a public key address and an associated balance.

Keybase proof

I hereby claim:

  • I am tavakyan on github.
  • I am tavakyan (https://keybase.io/tavakyan) on keybase.
  • I have a public key ASAoYde0M9LFFEJL4A3zoofbweyqPrhrEJC4lgABdxR-dQo

To claim this, I am signing this object:

Verifying that "tetriseffect.id" is my Blockstack ID. https://onename.com/tetriseffect
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
image: python:2.7
before_script:
- echo "deb http://packages.cloud.google.com/apt cloud-sdk-jessie main" | tee /etc/apt/sources.list.d/google-cloud-sdk.list
- curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
- apt-get update && apt-get install google-cloud-sdk
after_script:
- rm /tmp/$CI_PIPELINE_ID.json