blockchain

package
v0.0.0-...-a96da0a Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Difficulty   = 2
	MiningReward = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Timestamp    time.Time
	Hash         string
	LastHash     string
	Transactions []TransactionNFO
	Nonce        int
}

func (*Block) CalculateHash

func (block *Block) CalculateHash() string

func (*Block) MineBlock

func (block *Block) MineBlock(difficulty int)

type BlockChain

type BlockChain struct {
	Chain               []Block
	PendingTransactions []TransactionNFO
}

func CreateGenesisBlock

func CreateGenesisBlock() BlockChain

func New

func New() BlockChain

func (*BlockChain) CreateTransaction

func (BlockChain *BlockChain) CreateTransaction(transaction TransactionNFO)

func (*BlockChain) GetBalance

func (chain *BlockChain) GetBalance(address string) int

func (*BlockChain) GetLastBlock

func (chain *BlockChain) GetLastBlock() Block

func (*BlockChain) IsValid

func (chain *BlockChain) IsValid() bool

func (*BlockChain) MinePendingTransactions

func (chain *BlockChain) MinePendingTransactions(address string)

type TransactionNFO

type TransactionNFO struct {
	SentFrom string
	SentTo   string
	Amount   int
}

TransactionNFO will be implemented later on

Jump to

Keyboard shortcuts

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