Documentation ¶
Index ¶
- func BootstrapBlockchain() models.Block
- func CalculateHash(block models.Block) string
- func CalculateStringHash(s string) string
- func GenerateBlock(oldBlock models.Block, data []byte, address string) (models.Block, error)
- func HandleCandidateBlocks()
- func IsBlockValid(newBlock models.Block, oldBlock models.Block) bool
- func PickPOSWinner()
- func ReplaceChains(newBlocks []models.Block)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BootstrapBlockchain ¶
BootstrapBlockchain bootstraps a blockchain with the genesis block. It's typically empty values. Returns the genesis block
func CalculateHash ¶
CalculateHash simply calculates the hash for a block and stores it in that block. Used to check if the data is valid and the block hasn't been tampered with.
func CalculateStringHash ¶
func GenerateBlock ¶
GenerateBlock creates a new block based on the arbitrary data and the address of the client node that proposed it
func HandleCandidateBlocks ¶
func HandleCandidateBlocks()
HandleCandidateBlocks simply receives the candidate blocks via a Go channel and adds them to an internal temp array
func IsBlockValid ¶
IsBlockValid checks if the new block is valid as compared to the last old block
func PickPOSWinner ¶
func PickPOSWinner()
PickPOSWinner picks the winner node for the new block based on the number of tokens that have been staked by individual clients. It does this every 30 seconds.
func ReplaceChains ¶
ReplaceChains is used to overwrite the local copy of the blockchain if a longer chain is found in the network.
Types ¶
This section is empty.