version

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Flare versioning constants.
	Current                      = NewDefaultVersion(0, 6, 2)
	CurrentApp                   = NewDefaultApplication(constants.PlatformName, Current.Major(), Current.Minor(), Current.Patch())
	MinimumCompatibleVersion     = NewDefaultApplication(constants.PlatformName, 0, 6, 0)
	PrevMinimumCompatibleVersion = NewDefaultApplication(constants.PlatformName, 0, 5, 1)
	MinimumUnmaskedVersion       = NewDefaultApplication(constants.PlatformName, 0, 5, 1)
	PrevMinimumUnmaskedVersion   = NewDefaultApplication(constants.PlatformName, 0, 5, 1)

	VersionParser = NewDefaultApplicationParser()

	CurrentDatabase = DatabaseVersion1_4_5
	PrevDatabase    = DatabaseVersion1_0_0

	DatabaseVersion1_4_5 = NewDefaultVersion(1, 4, 5)
	DatabaseVersion1_0_0 = NewDefaultVersion(1, 0, 0)

	ApricotPhase0Times       = map[uint32]time.Time{}
	ApricotPhase0DefaultTime = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)

	ApricotPhase1Times       = map[uint32]time.Time{}
	ApricotPhase1DefaultTime = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)

	ApricotPhase2Times       = map[uint32]time.Time{}
	ApricotPhase2DefaultTime = time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)

	ApricotPhase3Times = map[uint32]time.Time{
		constants.CostonID:   time.Date(2022, time.February, 25, 14, 0, 0, 0, time.UTC),
		constants.SongbirdID: time.Date(2022, time.March, 7, 14, 0, 0, 0, time.UTC),
	}
	ApricotPhase3DefaultTime = time.Date(2022, time.February, 9, 15, 0, 0, 0, time.UTC)

	ApricotPhase4Times = map[uint32]time.Time{
		constants.CostonID:   time.Date(2022, time.February, 25, 15, 0, 0, 0, time.UTC),
		constants.SongbirdID: time.Date(2022, time.March, 7, 15, 0, 0, 0, time.UTC),
	}
	ApricotPhase4DefaultTime = time.Date(2022, time.February, 10, 15, 0, 0, 0, time.UTC)

	ApricotPhase5Times = map[uint32]time.Time{
		constants.CostonID:   time.Date(2022, time.February, 25, 16, 0, 0, 0, time.UTC),
		constants.SongbirdID: time.Date(2022, time.March, 7, 16, 0, 0, 0, time.UTC),
	}
	ApricotPhase5DefaultTime = time.Date(2022, time.February, 11, 15, 0, 0, 0, time.UTC)

	StateConnectorTimes = map[uint32]time.Time{
		constants.CostonID:   time.Date(2022, time.March, 28, 14, 0, 0, 0, time.UTC),
		constants.SongbirdID: time.Date(2022, time.March, 28, 14, 0, 0, 0, time.UTC),
	}
	StateConnectorDefaultTime = time.Date(2022, time.February, 12, 15, 0, 0, 0, time.UTC)

	ApricotPhase4MinPChainHeight        = map[uint32]uint64{}
	ApricotPhase4DefaultMinPChainHeight = uint64(0)
)

These are globals that describe network upgrades and node versions

View Source
var (
	// String is displayed when CLI arg --version is used
	String string

	// GitCommit is set in the build script at compile time
	GitCommit string
)
View Source
var (
	// DefaultVersion1_0_0 is a useful version to use in tests
	DefaultVersion1_0_0 = NewDefaultVersion(1, 0, 0)
)

Functions

func Before added in v0.5.0

func Before(compatibilities []Compatibility, version Application) bool

func Compatible added in v0.5.0

func Compatible(compatibilities []Compatibility, version Application) error

func GetApricotPhase0Time

func GetApricotPhase0Time(networkID uint32) time.Time

func GetApricotPhase1Time

func GetApricotPhase1Time(networkID uint32) time.Time

func GetApricotPhase2Time

func GetApricotPhase2Time(networkID uint32) time.Time

func GetApricotPhase3Time

func GetApricotPhase3Time(networkID uint32) time.Time

func GetApricotPhase4MinPChainHeight added in v0.2.3

func GetApricotPhase4MinPChainHeight(networkID uint32) uint64

func GetApricotPhase4Time added in v0.2.3

func GetApricotPhase4Time(networkID uint32) time.Time

func GetApricotPhase5Time added in v0.4.0

func GetApricotPhase5Time(networkID uint32) time.Time

func GetStateConnectorTime added in v0.6.1

func GetStateConnectorTime(networkID uint32) time.Time

func Unmaskable added in v0.5.0

func Unmaskable(compatibilities []Compatibility, version Application) error

func WontMask added in v0.5.0

func WontMask(compatibilities []Compatibility, version Application) error

Types

type Application

type Application interface {
	Version
	App() string
	Compatible(Application) error
	Before(Application) bool
}

Application defines what is needed to describe a versioned Application.

func NewApplication

func NewApplication(
	app string,
	appSeparator string,
	versionSeparator string,
	major int,
	minor int,
	patch int,
) Application

NewApplication returns a new version

func NewDefaultApplication

func NewDefaultApplication(
	app string,
	major int,
	minor int,
	patch int,
) Application

NewDefaultApplication returns a new version with default separators

type ApplicationParser

type ApplicationParser interface {
	Parse(string) (Application, error)
}

ApplicationParser defines the interface of an ApplicationVersion parser

func NewApplicationParser

func NewApplicationParser(appSeparator string, versionSeparator string) ApplicationParser

NewApplicationParser returns a new parser

func NewDefaultApplicationParser

func NewDefaultApplicationParser() ApplicationParser

NewDefaultApplicationParser returns a new parser with the default separators

type Compatibility

type Compatibility interface {
	// Returns the local version
	Version() Application

	// Returns nil if the provided version is compatible with the local version.
	// This means that the version is connectable and that consensus messages
	// can be made to them.
	Compatible(Application) error

	// Returns nil if the provided version shouldn't be masked. This means that
	// the version is connectable but not compatible. The version is so old that
	// it should just be masked.
	Unmaskable(Application) error

	// Returns nil if the provided version will not be masked by this version.
	WontMask(Application) error

	// Returns when additional masking will occur.
	MaskTime() time.Time
}

Compatibility a utility for checking the compatibility of peer versions

func GetCompatibility

func GetCompatibility(networkID uint32) Compatibility

func NewCompatibility

func NewCompatibility(
	version Application,
	minCompatable Application,
	minCompatableTime time.Time,
	prevMinCompatable Application,
	minUnmaskable Application,
	minUnmaskableTime time.Time,
	prevMinUnmaskable Application,
) Compatibility

NewCompatibility returns a compatibility checker with the provided options

type Parser

type Parser interface {
	Parse(string) (Version, error)
}

Parser defines the interface of a Version parser

func NewDefaultParser

func NewDefaultParser() Parser

func NewParser

func NewParser(prefix, separator string) Parser

type Version

type Version interface {
	fmt.Stringer

	Major() int
	Minor() int
	Patch() int
	// Compare returns a positive number if v > o, 0 if v == o, or a negative number if v < 0.
	Compare(o Version) int
}

func NewDefaultVersion

func NewDefaultVersion(major, minor, patch int) Version

func NewVersion

func NewVersion(major, minor, patch int, prefix, versionSeparator string) Version

Jump to

Keyboard shortcuts

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