| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Blockchain.Core.Types
- 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
Constructors
| Block | |
Fields | |
data BlockchainConfig Source #
Constructors
| BlockchainConfig | |
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 #
Constructors
| Difficulty | |
Fields | |
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 40000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
newtype CoinbaseTransaction Source #
Constructors
| CoinbaseTransaction | |
Fields | |
data TransactionIn Source #
Constructors
| TransactionIn | |
Fields
| |
data TransactionOutRef Source #
Pointer to a specific TransactionOut
Constructors
| TransactionOutRef | |
Fields | |
data TransactionOut Source #
Constructors
| TransactionOut | |
Fields
| |
signTransaction :: PrivateKey -> TransactionOut -> IO Signature Source #