-
Notifications
You must be signed in to change notification settings - Fork 2
Consensus
Consensus contains functions used to verify transactions, CloudBase transactions, Blocks, and Genesis Blocks are valid. If these structures do not conform to the consensus rules of cumulus, the functions return false and an error code describing the error associated with the invalid structure. If they do conform to the consensus rules of Cumulus, the functions return true and the error code is equal to 0.
func VerifyTransaction(bc *blockchain.BlockChain, t *blockchain.Transaction) (bool, TransactionCode) {...}
func VerifyCloudBase(bc *blockchain.BlockChain, t *blockchain.Transaction) (bool, CloudBaseTransactionCode) {...}
func VerifyGenesisBlock(bc *blockchain.BlockChain, gb *blockchain.Block) (bool, GenesisBlockCode) {...}
func VerifyBlock(bc *blockchain.BlockChain, b *blockchain.Block) (bool, BlockCode) {...}
In order to find the current target that the next block header must incorporate, the following function is used:
func CurrentTarget() blockchain.Hash {..}
CurrentTarget() uses the current difficulty and the maximum target in order to find the current target, as the current target is the product of max target / current difficulty.
The current block reward of the blockchain is found using the following function:
func CurrentBlockReward(bc *blockchain.BlockChain) uint64 {...}
CurrentBlockReward() uses the length of the blockchain and the block reward halving rate to find the block reward to be incorporated into the next block header.
The following uint32 types represent the error codes returned from VerifyTransaction(), VerifyCloudBase(), VerifyGenesisBlock(), and VerifyBlock() respectively.
type TransactionCode uint32
type CloudBaseTransactionCode uint32
type GenesisBlockCode uint32
type BlockCode uint32