blockchain

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MINING_DIFFICULTY = 3
	MINING_SENDER     = "BLOCKCHAIN REWARD SYSTEM (e.g. minting & fees)"
	MINING_REWARD     = 1.0
)

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, previousHash [32]byte, transactions []*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(blockchainAddress string, port uint16) *Blockchain

func (*Blockchain) AddTransaction

func (bc *Blockchain) AddTransaction(sender string, recipient string, value float32, senderPublicKey *ecdsa.PublicKey, s *utils.Signature) bool

func (*Blockchain) CalculateTotalAmount

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

func (*Blockchain) CopyTransactionPool

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

func (*Blockchain) CreateBlock

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

func (*Blockchain) LastBlock

func (bc *Blockchain) LastBlock() *Block

func (*Blockchain) MarshalJSON added in v1.29.0

func (bc *Blockchain) MarshalJSON() ([]byte, error)

func (*Blockchain) Mining

func (bc *Blockchain) Mining() bool

func (*Blockchain) Print

func (bc *Blockchain) Print()

func (*Blockchain) ProofOfWork

func (bc *Blockchain) ProofOfWork() int

func (*Blockchain) ValidProof

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

func (*Blockchain) VerifyTransactionSignature added in v1.27.0

func (bc *Blockchain) VerifyTransactionSignature(senderPublicKey *ecdsa.PublicKey, s *utils.Signature, t *Transaction) bool

type Transaction

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

func NewTransaction

func NewTransaction(sender string, recipient 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