Skip to content

Commit

Permalink
more versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuchman committed Sep 16, 2015
1 parent 7876808 commit b54522c
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 26 deletions.
2 changes: 1 addition & 1 deletion cmd/tendermint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Commands:
case "unsafe_reset_priv_validator":
reset_priv_validator()
case "version":
fmt.Println(config.GetString("version"))
fmt.Println(node.Version)
default:
fmt.Printf("Unknown command %v\n", args[0])
}
Expand Down
7 changes: 0 additions & 7 deletions config/tendermint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ func GetConfig(rootDir string) cfg.Config {
if mapConfig.IsSet("chain_id") {
Exit("Cannot set 'chain_id' via config.toml")
}
if mapConfig.IsSet("version") {
Exit("Cannot set 'version' via config.toml")
}
mapConfig.SetDefault("chain_id", "tendermint_testnet_10")
// Major: alpha
// Minor: encrypted p2p!
// Revision: ripemd for NewContractAddress
mapConfig.SetDefault("version", "0.5.1")
mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json")
mapConfig.SetDefault("moniker", "anonymous")
mapConfig.SetDefault("node_laddr", "0.0.0.0:46656")
Expand Down
4 changes: 0 additions & 4 deletions config/tendermint_test/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ func GetConfig(rootDir string) cfg.Config {
if mapConfig.IsSet("chain_id") {
Exit("Cannot set 'chain_id' via config.toml")
}
if mapConfig.IsSet("version") {
Exit("Cannot set 'version' via config.toml")
}
mapConfig.SetDefault("chain_id", "tendermint_test")
mapConfig.SetDefault("version", "0.5.0")
mapConfig.SetDefault("genesis_file", rootDir+"/genesis.json")
mapConfig.SetDefault("moniker", "anonymous")
mapConfig.SetDefault("node_laddr", "0.0.0.0:36656")
Expand Down
10 changes: 8 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/tendermint/tendermint/events"
mempl "github.com/tendermint/tendermint/mempool"
"github.com/tendermint/tendermint/p2p"
"github.com/tendermint/tendermint/rpc"
"github.com/tendermint/tendermint/rpc/core"
"github.com/tendermint/tendermint/rpc/server"
sm "github.com/tendermint/tendermint/state"
Expand Down Expand Up @@ -246,12 +247,17 @@ func makeNodeInfo(sw *p2p.Switch, privKey acm.PrivKeyEd25519) *types.NodeInfo {
PubKey: privKey.PubKey().(acm.PubKeyEd25519),
Moniker: config.GetString("moniker"),
ChainID: config.GetString("chain_id"),
Version: config.GetString("version"),
Version: types.Versions{
Tendermint: Version,
P2P: p2p.Version,
RPC: rpc.Version,
Wire: wire.Version,
},
}

// include git hash in the nodeInfo if available
if rev, err := ReadFile(config.GetString("revisions_file")); err == nil {
nodeInfo.Revision = string(rev)
nodeInfo.Version.Revision = string(rev)
}

if !sw.IsListening() {
Expand Down
6 changes: 6 additions & 0 deletions node/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package node

// Major: alpha
// Minor: encrypted p2p!
// Patch: New block pool logic
const Version = "0.5.2"
4 changes: 2 additions & 2 deletions p2p/switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ func makeSwitchPair(t testing.TB, initSwitch func(*Switch) *Switch) (*Switch, *S
PubKey: s1PrivKey.PubKey().(acm.PubKeyEd25519),
Moniker: "switch1",
ChainID: "testing",
Version: "123.123.123",
Version: types.Versions{Tendermint: "123.123.123"},
})
s1.SetNodePrivKey(s1PrivKey)
s2 := initSwitch(NewSwitch())
s2.SetNodeInfo(&types.NodeInfo{
PubKey: s2PrivKey.PubKey().(acm.PubKeyEd25519),
Moniker: "switch2",
ChainID: "testing",
Version: "123.123.123",
Version: types.Versions{Tendermint: "123.123.123"},
})
s2.SetNodePrivKey(s2PrivKey)

Expand Down
3 changes: 3 additions & 0 deletions p2p/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package p2p

const Version = "0.3.0"
3 changes: 3 additions & 0 deletions rpc/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package rpc

const Version = "0.4.0"
29 changes: 19 additions & 10 deletions types/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ import (
)

type NodeInfo struct {
PubKey acm.PubKeyEd25519 `json:"pub_key"`
Moniker string `json:"moniker"`
ChainID string `json:"chain_id"`
Version string `json:"version"`
Revision string `json:"revision"`
Host string `json:"host"`
P2PPort uint16 `json:"p2p_port"`
RPCPort uint16 `json:"rpc_port"`
PubKey acm.PubKeyEd25519 `json:"pub_key"`
Moniker string `json:"moniker"`
ChainID string `json:"chain_id"`
Host string `json:"host"`
P2PPort uint16 `json:"p2p_port"`
RPCPort uint16 `json:"rpc_port"`

Version Versions `json:"versions"`
}

type Versions struct {
Revision string `json:"revision"`
Tendermint string `json:"tendermint"`
P2P string `json:"p2p"`
RPC string `json:"rpc"`
Wire string `json:"wire"`
}

// CONTRACT: two nodes with the same Tendermint major and minor version and with the same ChainID are compatible
func (ni *NodeInfo) CompatibleWith(no *NodeInfo) error {
iM, im, _, ie := splitVersion(ni.Version)
oM, om, _, oe := splitVersion(no.Version)
iM, im, _, ie := splitVersion(ni.Version.Tendermint)
oM, om, _, oe := splitVersion(no.Version.Tendermint)

// if our own version number is not formatted right, we messed up
if ie != nil {
Expand Down
3 changes: 3 additions & 0 deletions wire/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package wire

const Version = "0.5.0"

0 comments on commit b54522c

Please sign in to comment.