Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implementation for PIP-22 #1067

Merged
merged 3 commits into from Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/daemon/main.go
Expand Up @@ -2,9 +2,14 @@ package main

import (
"github.com/pactus-project/pactus/cmd"
"github.com/pactus-project/pactus/version"
"github.com/spf13/cobra"
)

func init() {
version.AppType = "daemon"
}

func main() {
rootCmd := &cobra.Command{
Use: "pactus-daemon",
Expand Down
3 changes: 2 additions & 1 deletion cmd/gtk/main.go
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/pactus-project/pactus/cmd"
"github.com/pactus-project/pactus/genesis"
"github.com/pactus-project/pactus/util"
"github.com/pactus-project/pactus/version"
"github.com/pactus-project/pactus/wallet"
)

Expand All @@ -31,7 +32,7 @@ func init() {
workingDirOpt = flag.String("working-dir", cmd.PactusDefaultHomeDir(), "working directory path")
passwordOpt = flag.String("password", "", "wallet password")
testnetOpt = flag.Bool("testnet", false, "initializing for the testnet")

version.AppType = "gui"
gtk.Init(nil)
}

Expand Down
12 changes: 3 additions & 9 deletions version/version.go
Expand Up @@ -2,11 +2,11 @@ package version

import (
"fmt"
"os"
"path/filepath"
"runtime"
)

var AppType string

// These constants follow the semantic versioning 2.0.0 spec (http://semver.org/)
const (
major uint = 1
Expand All @@ -18,7 +18,7 @@ const (

func Agent() string {
return fmt.Sprintf("node=%s/node-version=v%s/protocol-version=%d/os=%s/arch=%s",
ExecutorName(), Version(), protocolVersion, runtime.GOOS, runtime.GOARCH)
AppType, Version(), protocolVersion, runtime.GOOS, runtime.GOARCH)
}

func Version() string {
Expand All @@ -29,9 +29,3 @@ func Version() string {

return version
}

func ExecutorName() string {
executorName, _ := os.Executable()

return filepath.Base(executorName)
}