aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgluk256 <gluk256@users.noreply.github.com>2019-01-24 19:35:10 +0800
committerRafael Matias <rafael@skyle.net>2019-02-19 19:56:31 +0800
commite247dcc141a5d1c9129b987a5f164e9df29be951 (patch)
tree04d2f9a4afe367a3a2c1a6bf5644a102c24230c7
parentb774d0a507017b2ba7a0d02f6aa23a0a83d1a768 (diff)
downloaddexon-e247dcc141a5d1c9129b987a5f164e9df29be951.tar
dexon-e247dcc141a5d1c9129b987a5f164e9df29be951.tar.gz
dexon-e247dcc141a5d1c9129b987a5f164e9df29be951.tar.bz2
dexon-e247dcc141a5d1c9129b987a5f164e9df29be951.tar.lz
dexon-e247dcc141a5d1c9129b987a5f164e9df29be951.tar.xz
dexon-e247dcc141a5d1c9129b987a5f164e9df29be951.tar.zst
dexon-e247dcc141a5d1c9129b987a5f164e9df29be951.zip
swarm/version: commit version added (#18510)
(cherry picked from commit ad13d2d407d2f614c39af92430fda0a926da2a8a)
-rw-r--r--cmd/swarm/main.go8
-rw-r--r--swarm/network/kademlia.go4
-rw-r--r--swarm/version/version.go3
3 files changed, 12 insertions, 3 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index 722dc4ff5..53888b615 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -66,9 +66,10 @@ OPTIONS:
{{end}}{{end}}
`
-var (
- gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
-)
+// Git SHA1 commit hash of the release (set via linker flags)
+// this variable will be assigned if corresponding parameter is passed with install, but not with test
+// e.g.: go install -ldflags "-X main.gitCommit=ed1312d01b19e04ef578946226e5d8069d5dfd5a" ./cmd/swarm
+var gitCommit string
//declare a few constant error messages, useful for later error check comparisons in test
var (
@@ -89,6 +90,7 @@ var defaultNodeConfig = node.DefaultConfig
// This init function sets defaults so cmd/swarm can run alongside geth.
func init() {
+ sv.GitCommit = gitCommit
defaultNodeConfig.Name = clientIdentifier
defaultNodeConfig.Version = sv.VersionWithCommit(gitCommit)
defaultNodeConfig.P2P.ListenAddr = ":30399"
diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go
index 2c2276251..9f4245603 100644
--- a/swarm/network/kademlia.go
+++ b/swarm/network/kademlia.go
@@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/pot"
+ sv "github.com/ethereum/go-ethereum/swarm/version"
)
/*
@@ -552,6 +553,9 @@ func (k *Kademlia) string() string {
var rows []string
rows = append(rows, "=========================================================================")
+ if len(sv.GitCommit) > 0 {
+ rows = append(rows, fmt.Sprintf("commit hash: %s", sv.GitCommit))
+ }
rows = append(rows, fmt.Sprintf("%v KΛÐΞMLIΛ hive: queen's address: %x", time.Now().UTC().Format(time.UnixDate), k.BaseAddr()[:3]))
rows = append(rows, fmt.Sprintf("population: %d (%d), NeighbourhoodSize: %d, MinBinSize: %d, MaxBinSize: %d", k.conns.Size(), k.addrs.Size(), k.NeighbourhoodSize, k.MinBinSize, k.MaxBinSize))
diff --git a/swarm/version/version.go b/swarm/version/version.go
index d5ec31f9f..f3184627b 100644
--- a/swarm/version/version.go
+++ b/swarm/version/version.go
@@ -41,6 +41,9 @@ var VersionWithMeta = func() string {
return v
}()
+// Git SHA1 commit hash of the release, will be set by main.init() function
+var GitCommit string
+
// ArchiveVersion holds the textual version string used for Swarm archives.
// e.g. "0.3.0-dea1ce05" for stable releases, or
// "0.3.1-unstable-21c059b6" for unstable releases