forks

package
v0.9.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ForkHalt is kiss-of-death fork, after which no transactions are included
	// in blocks, and all transactions are evicted from mempool. There are no
	// other changes that are sensible for a traditional consensus update. The
	// only conceivable use for this is a network migration where there should
	// be no transactions after the genesis data snapshot is collected for the
	// new network, which is accomplished via the globally available IsHalt and
	// BeginsHalt methods.
	ForkHalt = "halt"
)

Variables

This section is empty.

Functions

func ForkSortFunc

func ForkSortFunc(a, b *Fork) int

ForkSortFunc is used with slices.SortFunc or slices.SortStableFunc to sort a []*Fork in ascending order by height.

Types

type Fork

type Fork struct {
	Name   string
	Height uint64
}

Fork identifies a hardfork and its activation height. The semantics and details of the changes associated with the fork are determined by code that is affected by the change, which should check if it is activated by height.

func (Fork) String

func (f Fork) String() string

String describes the fork in the format "name:height".

type Forks

type Forks struct {

	// HaltHeight is the height at which "halt" activates. This stops new transactions.
	HaltHeight *uint64

	// Extended contains any forks that may be defined by extensions.
	// Potentially we could embed a struct with extension forks. To do that the
	// extension package would not be able to import common.
	Extended map[string]*uint64
}

Forks lists the recognized hardforks and their activation heights or times, depending on the fork. A zero value means always active for the chain. A nil pointer (unset in JSON) indicates it is never activated.

func NewForks

func NewForks(forks map[string]*uint64) *Forks

NewForks creates a new Forks instance from a fork heights map.

func (*Forks) ActivatedBy

func (fs *Forks) ActivatedBy(height uint64) []*Fork

ActivatedBy returns a list of Forks names that are active by a certain block height.

func (*Forks) ActivatesAt

func (fs *Forks) ActivatesAt(height uint64) []string

ActivatesAt returns a list of the fork names that activate at a certain height. Use ActivatesBy to return forks that activated at or before. The order of the slices is not defined and should not be relied upon.

func (*Forks) BeginsHalt

func (fs *Forks) BeginsHalt(height uint64) bool

BeginsHalt returns true if the "halt" rule changes go into effect *at* the given height.

func (*Forks) ForkHeight

func (fs *Forks) ForkHeight(fork string) *uint64

ForkHeight returns the activation height of a fork by name, or nil if it never activates.

func (*Forks) FromMap

func (fs *Forks) FromMap(forks map[string]*uint64)

FromMap populates the Forks fields from a fork heights map. Use if a pre-allocated Forks instance or to merge multiple definitions.

func (*Forks) IsHalt

func (fs *Forks) IsHalt(height uint64) bool

IsHalt returns true if the "halt" rule changes are in effect *as of* the given height.

func (Forks) String

func (fs Forks) String() string

String displays a human readable summary of all defined forks and their activation heights. For example:

- halt: <nil> (disabled) - atGenesis: 0 (genesis) - alpha: 1 - extended: 6

Jump to

Keyboard shortcuts

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