add git commit hash to nodeInfo

This commit is contained in:
Ethan Buchman
2015-07-10 15:50:58 +00:00
parent 751b892cba
commit 3f7f3dd37f
10 changed files with 38 additions and 20 deletions

View File

@ -7,6 +7,7 @@ import (
"net"
"net/http"
"os"
"path"
"strconv"
"strings"
"time"
@ -242,9 +243,16 @@ func makeNodeInfo(sw *p2p.Switch) *types.NodeInfo {
Moniker: config.GetString("moniker"),
Version: config.GetString("version"),
}
// include git hash in the nodeInfo if available
if rev, err := ReadFile(path.Join(TendermintRepo, ".revision")); err == nil {
nodeInfo.Revision = string(rev)
}
if !sw.IsListening() {
return nodeInfo
}
p2pListener := sw.Listeners()[0]
p2pHost := p2pListener.ExternalAddress().IP.String()
p2pPort := p2pListener.ExternalAddress().Port