Documentation ¶
Index ¶
Constants ¶
View Source
const Difficulty = 18
static in a real blockchain, it has to increase overtime due to increase in number of miners growing and also computation power
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct { // block's hash = Data + prevHash Hash []byte //any type of data Data []byte // previous block's hash PrevHash []byte // the nonce value that meets the target for the block Nonce int }
a struct (a data structure to represent to represent our block)
func CreateBlock ¶
outputs a pointer to a block
func Deserialize ¶
type BlockChain ¶
type BlockChain struct { Blocks []*Block Database *badger.DB // contains filtered or unexported fields }
func (*BlockChain) AddBlock ¶
func (chain *BlockChain) AddBlock(data string)
any blockchain struct instance can use this function
type ProofOfWork ¶
func (*ProofOfWork) InitData ¶
func (pow *ProofOfWork) InitData(nonce int) []byte
create a method on a struct
func (*ProofOfWork) Run ¶
func (pow *ProofOfWork) Run() (int, []byte)
func (*ProofOfWork) Validate ¶
func (pow *ProofOfWork) Validate() bool
to validate a block relatively simpler than getting the nonce
Click to show internal directories.
Click to hide internal directories.