pos

package
v0.0.0-...-5d652c1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProofOfStake

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

ProofOfStake represents the Proof of Stake consensus mechanism

func NewProofOfStake

func NewProofOfStake(bc *blockchain.Blockchain) *ProofOfStake

NewProofOfStake creates a new ProofOfStake instance

func (*ProofOfStake) CreateNewBlock

func (pos *ProofOfStake) CreateNewBlock() (*blockchain.Block, error)

CreateNewBlock creates a new block to be added to the blockchain

func (*ProofOfStake) SelectBlockCreator

func (pos *ProofOfStake) SelectBlockCreator() string

SelectBlockCreator selects a node as the block creator based on their stake

func (*ProofOfStake) UpdateStakeholder

func (pos *ProofOfStake) UpdateStakeholder(nodeID string, stake int)

UpdateStakeholder updates the stake for a given node

func (*ProofOfStake) ValidateBlock

func (pos *ProofOfStake) ValidateBlock(block *blockchain.Block) bool

ValidateBlock validates a block based on the Proof of Stake mechanism

type Stakeholder

type Stakeholder struct {
	NodeID string
	Stake  int
}

Stakeholder represents a node in the network with its stake value

Jump to

Keyboard shortcuts

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