-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from aquarius-kuchain/features/get-version
Add version cmd to get build and version info for Kuchain
- Loading branch information
Showing
4 changed files
with
118 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,40 @@ | ||
package constants | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/KuChainNetwork/kuchain/chain/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// some fix height | ||
|
||
var ( | ||
// FixAssetHeight fix asset bugs height | ||
FixAssetHeight string = "" | ||
FixAssetHeightVal, _ = strconv.ParseInt(FixAssetHeight, 10, 64) | ||
KuchainBuildVersion = "" | ||
KuchainBuildBranch = "" | ||
KuchainBuildTime = "" | ||
KuchainBuildSDKVersion = "" | ||
) | ||
|
||
// LogVersion log version info | ||
func LogVersion(logger log.Logger) { | ||
logger.Info("FixAsset", "height", GetFixAssetHeight()) | ||
} | ||
// VersionInfo get Version Info | ||
func VersionInfo() []byte { | ||
ver := struct { | ||
Version string `json:"version" yaml:"version"` | ||
Branch string `json:"branch" yaml:"branch"` | ||
BuildTime string `json:"build_time" yaml:"build_time"` | ||
SDKVersion string `json:"sdk_version" yaml:"sdk_version"` | ||
}{ | ||
Version: KuchainBuildVersion, | ||
Branch: KuchainBuildBranch, | ||
BuildTime: KuchainBuildTime, | ||
SDKVersion: KuchainBuildSDKVersion, | ||
} | ||
|
||
func GetFixAssetHeight() int64 { | ||
return FixAssetHeightVal | ||
res, _ := yaml.Marshal(ver) | ||
return res | ||
} | ||
|
||
// IsFixAssetHeight is fix asset | ||
func IsFixAssetHeight(ctx types.Context) bool { | ||
return ctx.BlockHeight() > FixAssetHeightVal | ||
// LogVersion log version info | ||
func LogVersion(logger log.Logger) { | ||
logger.Info("Kuchain Version", | ||
"version", KuchainBuildVersion, | ||
"branch", KuchainBuildBranch, | ||
"time", KuchainBuildTime, | ||
"sdkVersion", KuchainBuildSDKVersion) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters