blockchain

package
v0.0.0-...-c5ec0f1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapBlockchain

func BootstrapBlockchain() models.Block

BootstrapBlockchain bootstraps a blockchain with the genesis block. It's typically empty values. Returns the genesis block

func CalculateHash

func CalculateHash(block models.Block) string

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 CalculateStringHash(s string) string

func GenerateBlock

func GenerateBlock(oldBlock models.Block, data []byte, address string) (models.Block, error)

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

func IsBlockValid(newBlock models.Block, oldBlock models.Block) bool

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

func ReplaceChains(newBlocks []models.Block)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL