Merge pull request #1150 from LeoHChen/add_ver_in_ping

Add version string in ping message
pull/1152/head
Leo Chen 6 years ago committed by GitHub
commit e100edbf06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      api/proto/discovery/pingpong.go
  2. 7
      cmd/harmony/main.go
  3. 12
      internal/configs/node/config.go
  4. 2
      node/node_handler.go
  5. 18
      test/deploy.sh

@ -18,6 +18,7 @@ import (
"github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/api/proto"
"github.com/harmony-one/harmony/api/proto/node"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/p2p"
)
@ -25,6 +26,7 @@ import (
// PingMessageType defines the data structure of the Ping message
type PingMessageType struct {
Version uint16 // version of the protocol
NodeVer string // version of the node binary
Node node.Info
}
@ -51,6 +53,7 @@ func NewPingMessage(peer p2p.Peer, isClient bool) *PingMessageType {
ping := new(PingMessageType)
ping.Version = proto.ProtocolVersion
ping.NodeVer = nodeconfig.GetVersion()
ping.Node.IP = peer.IP
ping.Node.Port = peer.Port
ping.Node.PeerID = peer.PeerID

@ -55,8 +55,8 @@ func InitLDBDatabase(ip string, port string, freshDB bool, isBeacon bool) (*ethd
return ethdb.NewLDBDatabase(dbFileName, 0, 0)
}
func printVersion(me string) {
fmt.Fprintf(os.Stderr, "Harmony (C) 2018. %v, version %v-%v (%v %v)\n", path.Base(me), version, commit, builtBy, builtAt)
func printVersion() {
fmt.Fprintln(os.Stderr, nodeconfig.GetVersion())
os.Exit(0)
}
@ -432,8 +432,9 @@ func main() {
flag.Var(&utils.BootNodes, "bootnodes", "a list of bootnode multiaddress (delimited by ,)")
flag.Parse()
nodeconfig.SetVersion(fmt.Sprintf("Harmony (C) 2018. %v, version %v-%v (%v %v)", path.Base(os.Args[0]), version, commit, builtBy, builtAt))
if *versionFlag {
printVersion(os.Args[0])
printVersion()
}
// If FN node running, they should either specify blsPrivateKey or the file with passphrase

@ -74,6 +74,8 @@ const (
MaxShards = 32 // maximum number of shards. It is also the maxium number of configs.
)
var version string
// ConfigType is the structure of all node related configuration variables
type ConfigType struct {
// The three groupID design, please refer to https://github.com/harmony-one/harmony/blob/master/node/node.md#libp2p-integration
@ -230,3 +232,13 @@ func (conf *ConfigType) SetNetworkType(networkType NetworkType) {
func (conf *ConfigType) GetNetworkType() NetworkType {
return conf.networkType
}
// SetVersion set the version of the node binary
func SetVersion(ver string) {
version = ver
}
// GetVersion return the version of the node binary
func GetVersion() string {
return version
}

@ -550,7 +550,7 @@ func (node *Node) pingMessageHandler(msgPayload []byte, sender libp2p_peer.ID) i
peer.Port = ping.Node.Port
peer.PeerID = ping.Node.PeerID
peer.ConsensusPubKey = nil
logger = logger.New("ip", peer.IP, "port", peer.Port, "peerID", peer.PeerID)
logger = logger.New("ip", peer.IP, "port", peer.Port, "peerID", peer.PeerID, "peerVer", ping.NodeVer)
if ping.Node.PubKey != nil {
peer.ConsensusPubKey = &bls.PublicKey{}

@ -65,6 +65,7 @@ USAGE: $ME [OPTIONS] config_file_name [extra args to node]
-s shards number of shards (default: $SHARDS)
-n dryrun mode (default: $DRYRUN)
-S disable sync test (default: $SYNC)
-B don't build the binary
This script will build all the binaries and start harmony and txgen based on the configuration file.
@ -88,7 +89,7 @@ SHARDS=2
SYNC=true
DRYRUN=
while getopts "hdtD:m:s:nS" option; do
while getopts "hdtD:m:s:nSB" option; do
case $option in
h) usage ;;
d) DB=true ;;
@ -98,6 +99,7 @@ while getopts "hdtD:m:s:nS" option; do
s) SHARDS=$OPTARG ;;
n) DRYRUN=echo ;;
S) SYNC=false ;;
B) NOBUILD=true ;;
esac
done
@ -126,12 +128,14 @@ cleanup
# and you won't be able to turn it off. With `go build` generating one
# exe, the dialog will only pop up once at the very first time.
# Also it's recommended to use `go build` for testing the whole exe.
pushd $ROOT
echo "compiling ..."
go build -o bin/harmony cmd/harmony/main.go
go build -o bin/txgen cmd/client/txgen/main.go
go build -o bin/bootnode cmd/bootnode/main.go
popd
if [ "${NOBUILD}" != "true" ]; then
pushd $ROOT
echo "compiling ..."
go build -o bin/harmony cmd/harmony/main.go
go build -o bin/txgen cmd/client/txgen/main.go
go build -o bin/bootnode cmd/bootnode/main.go
popd
fi
# Create a tmp folder for logs
t=`date +"%Y%m%d-%H%M%S"`

Loading…
Cancel
Save