raft

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: GPL-3.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MinterRole     = 1
	TickerMS       = 100 // Raft's ticker interval
	SnapshotPeriod = 250 // Snapshot after this many raft messages
)

Variables

View Source
var (
	BlockReward      *big.Int = new(big.Int).Mul(big.NewInt(1e+18), big.NewInt(20))
	BlockAttenuation *big.Int = big.NewInt(2500000)
)
View Source
var (
	AppliedDbKey = []byte("applied")
)
View Source
var ExtraVanity = 32 // Fixed number of extra-data prefix bytes reserved for arbitrary signer vanity

Functions

func Fatalf

func Fatalf(format string, args ...interface{})

TODO: this is just copied over from cmd/utils/cmd.go. dedupe Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.

func NewStoppableListener

func NewStoppableListener(addr string, stopc <-chan struct{}) (*stoppableListener, error)

Types

type AddressTxes

type AddressTxes map[common.Address]types.Transactions

type ExtraSeal

type ExtraSeal struct {
	RaftId    []byte // RaftID of the block RaftMinter
	Signature []byte // Signature of the block RaftMinter
}

type InvalidRaftOrdering

type InvalidRaftOrdering struct {
	// Current head of the chain
	HeadBlock *types.Block

	// New block that should point to the head, but doesn't
	InvalidBlock *types.Block
}

type Raft

type Raft struct {
	*ethash.Ethash
	// contains filtered or unexported fields
}

func New

func New(nodeKey *ecdsa.PrivateKey) *Raft

func (*Raft) BuildExtraSeal added in v1.0.6

func (r *Raft) BuildExtraSeal(headerHash common.Hash) []byte

func (*Raft) Finalize

func (r *Raft) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, _ []*types.Receipt) error

func (*Raft) FinalizeAndAssemble

func (r *Raft) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction,
	uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

func (*Raft) SetId

func (r *Raft) SetId(raftId uint16)

type SpeculativeChain

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

The speculative chain represents blocks that we have minted which haven't been accepted into the chain yet, building on each other in a chain. It has three basic operations: * add new block to end * accept / remove oldest block * unwind / remove invalid blocks to the end

Additionally: * clear state when we stop minting * set the parent when we're not minting (so it's always current)

func NewSpeculativeChain

func NewSpeculativeChain() *SpeculativeChain

func (*SpeculativeChain) Accept

func (chain *SpeculativeChain) Accept(acceptedBlock *types.Block)

Accept this block, removing it from the speculative chain

func (*SpeculativeChain) Clear

func (chain *SpeculativeChain) Clear(block *types.Block)

func (*SpeculativeChain) Extend

func (chain *SpeculativeChain) Extend(block *types.Block)

Append a new speculative block

func (*SpeculativeChain) Head

func (chain *SpeculativeChain) Head() *types.Block

func (*SpeculativeChain) SetHead

func (chain *SpeculativeChain) SetHead(block *types.Block)

Set the parent of the speculative chain

Note: This is only called when not minter

func (*SpeculativeChain) UnwindFrom

func (chain *SpeculativeChain) UnwindFrom(invalidHash common.Hash, headBlock *types.Block)

Remove all blocks in the chain from the specified one until the end

func (*SpeculativeChain) WithoutProposedTxes

func (chain *SpeculativeChain) WithoutProposedTxes(addrTxes AddressTxes) AddressTxes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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