mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
Add AllowConnectionToDifferentVersions flag to kaspactl (#1940)
This commit is contained in:
parent
1cd712a63e
commit
c85b5d70fd
@ -12,11 +12,12 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type configFlags struct {
|
type configFlags struct {
|
||||||
RPCServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
|
RPCServer string `short:"s" long:"rpcserver" description:"RPC server to connect to"`
|
||||||
Timeout uint64 `short:"t" long:"timeout" description:"Timeout for the request (in seconds)"`
|
Timeout uint64 `short:"t" long:"timeout" description:"Timeout for the request (in seconds)"`
|
||||||
RequestJSON string `short:"j" long:"json" description:"The request in JSON format"`
|
RequestJSON string `short:"j" long:"json" description:"The request in JSON format"`
|
||||||
ListCommands bool `short:"l" long:"list-commands" description:"List all commands and exit"`
|
ListCommands bool `short:"l" long:"list-commands" description:"List all commands and exit"`
|
||||||
CommandAndParameters []string
|
AllowConnectionToDifferentVersions bool `short:"a" long:"allow-connection-to-different-versions" description:"Allow connections to versions different than kaspactl's version'"`
|
||||||
|
CommandAndParameters []string
|
||||||
config.NetworkFlags
|
config.NetworkFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,16 +34,18 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer client.Disconnect()
|
defer client.Disconnect()
|
||||||
|
|
||||||
kaspadMessage, err := client.Post(&protowire.KaspadMessage{Payload: &protowire.KaspadMessage_GetInfoRequest{GetInfoRequest: &protowire.GetInfoRequestMessage{}}})
|
if !cfg.AllowConnectionToDifferentVersions {
|
||||||
if err != nil {
|
kaspadMessage, err := client.Post(&protowire.KaspadMessage{Payload: &protowire.KaspadMessage_GetInfoRequest{GetInfoRequest: &protowire.GetInfoRequestMessage{}}})
|
||||||
printErrorAndExit(fmt.Sprintf("Cannot post GetInfo message: %s", err))
|
if err != nil {
|
||||||
}
|
printErrorAndExit(fmt.Sprintf("Cannot post GetInfo message: %s", err))
|
||||||
|
}
|
||||||
|
|
||||||
localVersion := version.Version()
|
localVersion := version.Version()
|
||||||
remoteVersion := kaspadMessage.GetGetInfoResponse().ServerVersion
|
remoteVersion := kaspadMessage.GetGetInfoResponse().ServerVersion
|
||||||
|
|
||||||
if localVersion != remoteVersion {
|
if localVersion != remoteVersion {
|
||||||
printErrorAndExit(fmt.Sprintf("Server version mismatch, expect: %s, got: %s", localVersion, remoteVersion))
|
printErrorAndExit(fmt.Sprintf("Server version mismatch, expect: %s, got: %s", localVersion, remoteVersion))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
responseChan := make(chan string)
|
responseChan := make(chan string)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user