Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Block = Block {}
- data BlockHeader = BlockHeader {}
- data BlockchainConfig = BlockchainConfig {}
- defaultConfig :: BlockchainConfig
- targetReward :: BlockchainConfig -> Word -> Word
- targetDifficulty :: BlockchainConfig -> [Block] -> Difficulty
- newtype Difficulty = Difficulty {}
- newtype Hex256 = Hex256 {}
- hex256 :: String -> Maybe Hex256
- hex256LeadingZeros :: Word -> Hex256
- data Transaction = Transaction {}
- newtype CoinbaseTransaction = CoinbaseTransaction {}
- data TransactionIn = TransactionIn {}
- data TransactionOutRef = TransactionOutRef {}
- data TransactionOut = TransactionOut {}
- signTransaction :: PrivateKey -> TransactionOut -> IO Signature
- verifyTransactionSignature :: Signature -> TransactionOut -> Bool
Documentation
defaultConfig :: BlockchainConfig Source #
A reasonable default config to use for testing. Mines blocks quickly and changes difficulty and rewards frequently. Note: reward will go to zero after 1100 blocks, which will take about 180 minutes of mining.
defaultConfig :: BlockchainConfig defaultConfig = BlockchainConfig { initialDifficulty = Difficulty 1 , difficulty1Target = hex256LeadingZeros 4 , targetSecondsPerBlock = 10 , difficultyRecalculationHeight = 50 , initialMiningReward = 1024 , miningRewardHalvingHeight = 100 }
targetReward :: BlockchainConfig -> Word -> Word Source #
Calculates the target reward for a blockchain. Uses the longest chain.
targetDifficulty :: BlockchainConfig -> [Block] -> Difficulty Source #
Calculates the target difficulty for a blockchain. Uses the longest chain.
newtype Difficulty Source #
hex256LeadingZeros :: Word -> Hex256 Source #
Create a Hex256 value with the specificed amount of leading zeros.
Useful for creating a difficulty1Target
when creating a blockchain.
>>>
hex256LeadingZeros 4
0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
data Transaction Source #
newtype CoinbaseTransaction Source #
data TransactionIn Source #
TransactionIn | |
|
data TransactionOut Source #
TransactionOut | |
|
signTransaction :: PrivateKey -> TransactionOut -> IO Signature Source #