assignment01bca

package module
v0.0.0-...-f6cac4c Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 2 Imported by: 0

README

assignment01bca

This is the first assignment of Blockchain. The purpose is to create a package that helps in creating and monitoring of blocks in blockchain.

When verifying the blockchain, if the latest block is changed, the blockchain will still remain valid. Only if there is a block next to the block you change, will the blockchain become invalid. This is because the block's hash will need be compared to the previous hash in the next block. For latest block, this will not work.

Thank you.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateHash

func CalculateHash(block *Block) string

Function to calculate the hash of a block

func ChangeBlock

func ChangeBlock(block *Block, newTransaction string)

Function to change an already added block of the blockchain

func DisplayBlocks

func DisplayBlocks(blocks []*Block)

Function to display all blocks of the blockchain

func VerifyChain

func VerifyChain(blocks []*Block) bool

Function to verify the blockchain for any changes

Types

type Block

type Block struct {
	Transaction  string
	Nonce        int
	PreviousHash string
	CurrentHash  string
}

Defining the block structure for the blockchain

func NewBlock

func NewBlock(transaction string, nonce int, previousHash string) *Block

Function to add a new block to the blockchain

Jump to

Keyboard shortcuts

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