block

package
v0.0.0-...-4d08dca Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

func NewBlock

func NewBlock(nonce int, prevHash [32]byte, txns []*Transaction) *Block

func (Block) Hash

func (b Block) Hash() [32]byte

func (Block) MarshalJSON

func (b Block) MarshalJSON() ([]byte, error)

func (Block) Print

func (b Block) Print()

type Blockchain

type Blockchain struct {
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(addr string) *Blockchain

func (*Blockchain) AddTransaction

func (bc *Blockchain) AddTransaction(sender, recepient string, value float32)

func (*Blockchain) CalculateTotalAmount

func (bc *Blockchain) CalculateTotalAmount(addr string) float32

func (Blockchain) CopyTransactionPool

func (bc Blockchain) CopyTransactionPool() []*Transaction

func (*Blockchain) CreateBlock

func (bc *Blockchain) CreateBlock(nonce int, prevHash [32]byte) *Block

func (Blockchain) LastBlock

func (bc Blockchain) LastBlock() *Block

func (*Blockchain) Mining

func (bc *Blockchain) Mining() bool

Mining accepts a receiver pointer even though there is no mutation done in this method. However, it calls other mutating methods like Add Transaction to which reference needs to be passed so that the mutation is successful

func (Blockchain) Print

func (bc Blockchain) Print()

func (Blockchain) ProofOfWork

func (bc Blockchain) ProofOfWork() int

func (Blockchain) ValidProof

func (bc Blockchain) ValidProof(nonce int, prevHash [32]byte, txns []*Transaction, difficulty int) bool

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(sender, recepient string, value float32) *Transaction

func (Transaction) MarshalJSON

func (t Transaction) MarshalJSON() ([]byte, error)

func (Transaction) Print

func (t Transaction) Print()

Jump to

Keyboard shortcuts

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