permission

package
v0.0.0-...-69f1810 Latest Latest
Warning

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

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

Documentation

Overview

Permissions implement a permission interface to determine if a node is allowed to participate in consensus and punish nodes that violate the consensus rules.

The ProofOfStake permission implementation requires a minimum amount of tokens staged on a deposit contract to be allowed to participate in consensus. The balance deposited is checked against the state of the chain at the time of checksum window creation. The ProofOfStake implementation punishes nodes that violate the consensus rules by slashing their deposit.

The ProofOfAuthority permission implementation requires a list of authorized tokens to be allowed to participate in consensus. The ProofOfAuthority does not contemplate punishment other than be automatically removed from the list of authorized tokens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Violations

func Violations(duplicates *bft.Duplicate) map[crypto.Token]struct{}

Violations returns a map of tokens that have violated the consensus rules according to duplicates evidence.

Types

type Permissionless

type Permissionless struct{}

func (Permissionless) DeterminePool

func (p Permissionless) DeterminePool(chain *chain.Blockchain, candidates []crypto.Token) map[crypto.Token]int

func (Permissionless) Punish

func (p Permissionless) Punish(duplicates *bft.Duplicate, weights map[crypto.Token]int) map[crypto.Token]uint64

type ProofOfAuthority

type ProofOfAuthority struct {
	Authorized []crypto.Token
}

Proof of authority implements a PoA permission interface.

func NewProofOfAuthority

func NewProofOfAuthority(tokens ...crypto.Token) *ProofOfAuthority

NewProofOfStake returns a new empty ProofOfStake.

func (*ProofOfAuthority) Authorize

func (poa *ProofOfAuthority) Authorize(token crypto.Token)

func (*ProofOfAuthority) Cancel

func (poa *ProofOfAuthority) Cancel(token crypto.Token)

Cancel removes a token from the list of authorized tokens.

func (*ProofOfAuthority) DeterminePool

func (poa *ProofOfAuthority) DeterminePool(chain *chain.Blockchain, candidates []crypto.Token) map[crypto.Token]int

DeterminePool returns a map of authorized tokens and their equal weight of 1.

func (*ProofOfAuthority) Punish

func (poa *ProofOfAuthority) Punish(duplicates *bft.Duplicate, weights map[crypto.Token]int) map[crypto.Token]uint64

Punish returns an empty map of punishments and cancel the autorization of the violators to participate in consensus.

type ProofOfStake

type ProofOfStake struct {
	MinimumStage uint64
}

Proof of statke implements a PoS permission interface.

func (*ProofOfStake) DeterminePool

func (pos *ProofOfStake) DeterminePool(chain *chain.Blockchain, candidates []crypto.Token) map[crypto.Token]int

DeterminePool returns the autorized candidates with their respective deposits.

func (*ProofOfStake) Punish

func (pos *ProofOfStake) Punish(duplicates *bft.Duplicate, weights map[crypto.Token]int) map[crypto.Token]uint64

Punish returns a map of punishments for the violators with their respective stakes for stashing.

Jump to

Keyboard shortcuts

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