forked from TrueCloudLab/neoneo-go
rpc: add Magic to Version
This commit is contained in:
parent
c50f3db6ad
commit
474d2dfb65
3 changed files with 10 additions and 5 deletions
|
@ -631,9 +631,10 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
invoke: func(c *Client) (interface{}, error) {
|
||||
return c.GetVersion()
|
||||
},
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/"}}`,
|
||||
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"magic":42,"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/"}}`,
|
||||
result: func(c *Client) interface{} {
|
||||
return &result.Version{
|
||||
Magic: netmode.UnitTestNet,
|
||||
TCPPort: uint16(20332),
|
||||
WSPort: uint16(20342),
|
||||
Nonce: 2153672787,
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package result
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
|
||||
type (
|
||||
// Version model used for reporting server version
|
||||
// info.
|
||||
Version struct {
|
||||
TCPPort uint16 `json:"tcpport"`
|
||||
WSPort uint16 `json:"wsport,omitempty"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
UserAgent string `json:"useragent"`
|
||||
Magic netmode.Magic `json:"magic"`
|
||||
TCPPort uint16 `json:"tcpport"`
|
||||
WSPort uint16 `json:"wsport,omitempty"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
UserAgent string `json:"useragent"`
|
||||
}
|
||||
)
|
||||
|
|
|
@ -466,6 +466,7 @@ func (s *Server) getVersion(_ request.Params) (interface{}, *response.Error) {
|
|||
return nil, response.NewInternalServerError("Cannot fetch tcp port", err)
|
||||
}
|
||||
return result.Version{
|
||||
Magic: s.network,
|
||||
TCPPort: port,
|
||||
Nonce: s.coreServer.ID(),
|
||||
UserAgent: s.coreServer.UserAgent,
|
||||
|
|
Loading…
Reference in a new issue