func createNewBlock(oldBlock BlockStruct, data string) BlockStruct {
	var newBlock BlockStruct
	t := time.Now()
	newBlock.Index = oldBlock.Index + 1
	newBlock.Timestamp = t.String()
	newBlock.Data = data
	newBlock.PrevHash = oldBlock.Hash
	newBlock.Hash = calculateBlockHash(newBlock)
	return newBlock
}
CREATE NEW BLOCK
package main
import (
	"crypto/sha256"
	"encoding/hex"
	"strconv"
	"time"
)
func calculateBlockHash(block BlockStruct) string {
	record := strconv.Itoa(block.Index) + block.Timestamp + block.Data + block.PrevHash
	h := sha256.New()
	h.Write([]byte(record))
	hashed := h.Sum(nil)
	return hex.EncodeToString(hashed)
}
func isBlockValid(checkBlock, oldBlock BlockStruct) bool {
	if oldBlock.Index+1 != checkBlock.Index {
		return false
	}
	if oldBlock.Hash != checkBlock.PrevHash {
		return false
	}
	if calculateBlockHash(checkBlock) != checkBlock.Hash {
		return false
	}
	return true
}