lotus/build/version.go

45 lines
994 B
Go
Raw Normal View History

package build
import "fmt"
var CurrentCommit string
// BuildVersion is the local build version, set by build system
2020-01-08 17:42:19 +00:00
const BuildVersion = "0.1.6"
var UserVersion = BuildVersion + CurrentCommit
type Version uint32
func newVer(major, minor, patch uint8) Version {
return Version(uint32(major)<<16 | uint32(minor)<<8 | uint32(patch))
}
2019-12-11 00:22:58 +00:00
// Ints returns (major, minor, patch) versions
func (ve Version) Ints() (uint32, uint32, uint32) {
v := uint32(ve)
return (v & majorOnlyMask) >> 16, (v & minorOnlyMask) >> 8, v & patchOnlyMask
}
func (ve Version) String() string {
vmj, vmi, vp := ve.Ints()
return fmt.Sprintf("%d.%d.%d", vmj, vmi, vp)
}
2019-12-17 15:16:57 +00:00
func (ve Version) EqMajorMinor(v2 Version) bool {
return ve&minorMask == v2&minorMask
2019-12-17 15:16:57 +00:00
}
// APIVersion is a semver version of the rpc api exposed
2020-01-07 16:44:55 +00:00
var APIVersion Version = newVer(0, 1, 6)
const (
majorMask = 0xff0000
minorMask = 0xffff00
patchMask = 0xffffff
majorOnlyMask = 0xff0000
minorOnlyMask = 0x00ff00
patchOnlyMask = 0x0000ff
)