# Functions
No description provided by the author
No description provided by the author
// old version done by proof of work now
func (b *Block) DeriveHash() { // method to create hash based on data and previous
info := bytes.Join([][]byte{b.Data, b.PrevHash}, []byte{}) // 2d of data and prev, and empty bytpes
hash := sha256.Sum256(info) // change data changes hash otherwise same
b.Hash = hash[:]
}
*/.
No description provided by the author
No description provided by the author
// moved to blockchain.go
// add block to chain
func (chain *BlockChain) AddBlock(data string) { // add block
prevBlock := chain.Blocks[len(chain.Blocks)-1]
new := CreateBlockk(data, prevBlock.Hash)
chain.Blocks = append(chain.Blocks, new)
}
*/ Genesis block creations.
No description provided by the author
setup Genesis block.
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
// moved to blockchain.go
type BlockChain struct { // simple strucutre for chian
Blocks []*Block // B in blocks capital makes it public
}
*/.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author