Set protocol versions in NodeInfo from state (#2686)

* use types.NewValidator

* node: set p2p.ProtocolVersion from state, not globals
This commit is contained in:
Ethan Buchman
2018-10-22 17:55:49 -04:00
committed by GitHub
parent f94eb42ebe
commit fe1d59ab7b
7 changed files with 24 additions and 37 deletions

View File

@@ -49,16 +49,20 @@ type ProtocolVersion struct {
App version.Protocol `json:"app"`
}
// InitProtocolVersion populates the Block and P2P versions, but not the App.
var InitProtocolVersion = ProtocolVersionWithApp(0)
// defaultProtocolVersion populates the Block and P2P versions using
// the global values, but not the App.
var defaultProtocolVersion = NewProtocolVersion(
version.P2PProtocol,
version.BlockProtocol,
0,
)
// ProtocolVersionWithApp returns a fully populated ProtocolVersion
// using the provided App version and the Block and P2P versions defined in the `version` package.
func ProtocolVersionWithApp(appVersion version.Protocol) ProtocolVersion {
// NewProtocolVersion returns a fully populated ProtocolVersion.
func NewProtocolVersion(p2p, block, app version.Protocol) ProtocolVersion {
return ProtocolVersion{
P2P: version.P2PProtocol,
Block: version.BlockProtocol,
App: appVersion,
P2P: p2p,
Block: block,
App: app,
}
}