loop: add the commit_hash to GetInfoResponse, change version semantics

With this commit we extend GetinfoResponse with the strict commit hash
(which also includes whether the build tree was clean or dirty).
This commit is contained in:
Andras Banki-Horvath 2025-04-04 12:32:33 +02:00
parent f72cdde58f
commit 9a6266f9f7
No known key found for this signature in database
GPG key ID: 80E5375C094198D8
7 changed files with 725 additions and 692 deletions

View file

@ -162,7 +162,7 @@ func fatal(err error) {
func main() {
app := cli.NewApp()
app.Version = loop.Version()
app.Version = loop.RichVersion()
app.Name = "loop"
app.Usage = "control plane for your loopd"
app.Flags = []cli.Flag{

View file

@ -176,7 +176,7 @@ func Run(rpcCfg RPCConfig) error {
appName := filepath.Base(os.Args[0])
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
if config.ShowVersion {
fmt.Println(appName, "version", loop.Version())
fmt.Println(appName, "version", loop.RichVersion())
os.Exit(0)
}
@ -222,7 +222,7 @@ func Run(rpcCfg RPCConfig) error {
}
// Print the version before executing either primary directive.
infof("Version: %v", loop.Version())
infof("Version: %v", loop.RichVersion())
lisCfg := NewListenerConfig(&config, rpcCfg)

View file

@ -1210,6 +1210,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
return &looprpc.GetInfoResponse{
Version: loop.Version(),
CommitHash: loop.CommitHash(),
Network: s.config.Network,
RpcListen: s.config.RPCListen,
RestListen: s.config.RESTListen,

File diff suppressed because it is too large Load diff

View file

@ -1045,6 +1045,11 @@ message GetInfoResponse {
Statistics about loop ins.
*/
LoopStats loop_in_stats = 8;
/*
The git commit hash of the loopd binary.
*/
string commit_hash = 9;
}
message GetLiquidityParamsRequest {

View file

@ -967,6 +967,10 @@
"loop_in_stats": {
"$ref": "#/definitions/looprpcLoopStats",
"description": "Statistics about loop ins."
},
"commit_hash": {
"type": "string",
"description": "The git commit hash of the loopd binary."
}
}
},

View file

@ -45,13 +45,25 @@ const (
var AgentName = defaultAgentName
// Version returns the application version as a properly formed string per the
// semantic versioning 2.0.0 spec (http://semver.org/) and the commit it was
// built on.
// semantic versioning 2.0.0 spec (http://semver.org/).
func Version() string {
// Append commit hash of current build to version.
return semanticVersion()
}
// RichVersion returns the application version as a properly formed string
// per the semantic versioning 2.0.0 spec (http://semver.org/) and the commit
// it was built on.
func RichVersion() string {
// Append commit hash of current build to version.
return fmt.Sprintf("%s commit=%s", semanticVersion(), Commit)
}
// CommitHash returns the commit hash of the current build.
func CommitHash() string {
return Commit
}
// UserAgent returns the full user agent string that identifies the software
// that is submitting swaps to the loop server.
func UserAgent(initiator string) string {