lotus/build/version.go
Jakub Sztandera 867cba610b
Refactor versions
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2019-12-17 00:43:43 +01:00

60 lines
1.4 KiB
Go

package build
import "fmt"
var CurrentCommit string
// BuildVersion is the local build version, set by build system
const BuildVersion = "0.1.2"
var UserVersion = BuildVersion + CurrentCommit
type Version uint32
func newVer(major, minor, patch uint8) Version {
return Version(uint32(major)<<16 | uint32(minor)<<8 | uint32(patch))
}
// 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)
}
>>>>>>> 4041819c... Refactor versions
func (ve Version) EqMajorMinor(v2 Version) bool {
return ve&minorMask == v2&minorMask
}
// APIVersion is a hex semver version of the rpc api exposed
//
// M M P
// A I A
// J N T
// O O C
// R R H
// |\vv/|
// vv vv
<<<<<<< HEAD
const APIVersion = 0x000102
||||||| parent of 4041819c... Refactor versions
const APIVersion = 0x000101
=======
var APIVersion Version = newVer(0, 1, 1)
>>>>>>> 4041819c... Refactor versions
const (
majorMask = 0xff0000
minorMask = 0xffff00
patchMask = 0xffffff
majorOnlyMask = 0xff0000
minorOnlyMask = 0x00ff00
patchOnlyMask = 0x0000ff
)