result: drop deprecated Magic and StateRootInHeader from Version
It's more than a year now we have them deprecated.
This commit is contained in:
parent
4c9473872e
commit
7f8a79ffaa
5 changed files with 18 additions and 40 deletions
|
@ -15,17 +15,11 @@ type (
|
||||||
// Version model used for reporting server version
|
// Version model used for reporting server version
|
||||||
// info.
|
// info.
|
||||||
Version struct {
|
Version struct {
|
||||||
// Magic contains network magic.
|
|
||||||
// Deprecated: use Protocol.Network instead
|
|
||||||
Magic netmode.Magic
|
|
||||||
TCPPort uint16
|
TCPPort uint16
|
||||||
WSPort uint16
|
WSPort uint16
|
||||||
Nonce uint32
|
Nonce uint32
|
||||||
UserAgent string
|
UserAgent string
|
||||||
Protocol Protocol
|
Protocol Protocol
|
||||||
// StateRootInHeader is true if state root is contained in the block header.
|
|
||||||
// Deprecated: use Protocol.StateRootInHeader instead
|
|
||||||
StateRootInHeader bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protocol represents network-dependent parameters.
|
// Protocol represents network-dependent parameters.
|
||||||
|
@ -57,13 +51,11 @@ type (
|
||||||
type (
|
type (
|
||||||
// versionMarshallerAux is an auxiliary struct used for Version JSON marshalling.
|
// versionMarshallerAux is an auxiliary struct used for Version JSON marshalling.
|
||||||
versionMarshallerAux struct {
|
versionMarshallerAux struct {
|
||||||
Magic netmode.Magic `json:"network"`
|
TCPPort uint16 `json:"tcpport"`
|
||||||
TCPPort uint16 `json:"tcpport"`
|
WSPort uint16 `json:"wsport,omitempty"`
|
||||||
WSPort uint16 `json:"wsport,omitempty"`
|
Nonce uint32 `json:"nonce"`
|
||||||
Nonce uint32 `json:"nonce"`
|
UserAgent string `json:"useragent"`
|
||||||
UserAgent string `json:"useragent"`
|
Protocol protocolMarshallerAux `json:"protocol"`
|
||||||
Protocol protocolMarshallerAux `json:"protocol"`
|
|
||||||
StateRootInHeader bool `json:"staterootinheader,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// protocolMarshallerAux is an auxiliary struct used for Protocol JSON marshalling.
|
// protocolMarshallerAux is an auxiliary struct used for Protocol JSON marshalling.
|
||||||
|
@ -86,13 +78,11 @@ type (
|
||||||
|
|
||||||
// versionUnmarshallerAux is an auxiliary struct used for Version JSON unmarshalling.
|
// versionUnmarshallerAux is an auxiliary struct used for Version JSON unmarshalling.
|
||||||
versionUnmarshallerAux struct {
|
versionUnmarshallerAux struct {
|
||||||
Magic netmode.Magic `json:"network"`
|
TCPPort uint16 `json:"tcpport"`
|
||||||
TCPPort uint16 `json:"tcpport"`
|
WSPort uint16 `json:"wsport,omitempty"`
|
||||||
WSPort uint16 `json:"wsport,omitempty"`
|
Nonce uint32 `json:"nonce"`
|
||||||
Nonce uint32 `json:"nonce"`
|
UserAgent string `json:"useragent"`
|
||||||
UserAgent string `json:"useragent"`
|
Protocol protocolUnmarshallerAux `json:"protocol"`
|
||||||
Protocol protocolUnmarshallerAux `json:"protocol"`
|
|
||||||
StateRootInHeader bool `json:"staterootinheader,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// protocolUnmarshallerAux is an auxiliary struct used for Protocol JSON unmarshalling.
|
// protocolUnmarshallerAux is an auxiliary struct used for Protocol JSON unmarshalling.
|
||||||
|
@ -121,7 +111,6 @@ var latestNonBreakingVersion = *semver.New("0.98.5")
|
||||||
// MarshalJSON implements the json marshaller interface.
|
// MarshalJSON implements the json marshaller interface.
|
||||||
func (v *Version) MarshalJSON() ([]byte, error) {
|
func (v *Version) MarshalJSON() ([]byte, error) {
|
||||||
aux := versionMarshallerAux{
|
aux := versionMarshallerAux{
|
||||||
Magic: v.Magic,
|
|
||||||
TCPPort: v.TCPPort,
|
TCPPort: v.TCPPort,
|
||||||
WSPort: v.WSPort,
|
WSPort: v.WSPort,
|
||||||
Nonce: v.Nonce,
|
Nonce: v.Nonce,
|
||||||
|
@ -142,7 +131,6 @@ func (v *Version) MarshalJSON() ([]byte, error) {
|
||||||
StateRootInHeader: v.Protocol.StateRootInHeader,
|
StateRootInHeader: v.Protocol.StateRootInHeader,
|
||||||
ValidatorsHistory: v.Protocol.ValidatorsHistory,
|
ValidatorsHistory: v.Protocol.ValidatorsHistory,
|
||||||
},
|
},
|
||||||
StateRootInHeader: v.StateRootInHeader,
|
|
||||||
}
|
}
|
||||||
return json.Marshal(aux)
|
return json.Marshal(aux)
|
||||||
}
|
}
|
||||||
|
@ -154,7 +142,6 @@ func (v *Version) UnmarshalJSON(data []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
v.Magic = aux.Magic
|
|
||||||
v.TCPPort = aux.TCPPort
|
v.TCPPort = aux.TCPPort
|
||||||
v.WSPort = aux.WSPort
|
v.WSPort = aux.WSPort
|
||||||
v.Nonce = aux.Nonce
|
v.Nonce = aux.Nonce
|
||||||
|
@ -171,7 +158,6 @@ func (v *Version) UnmarshalJSON(data []byte) error {
|
||||||
v.Protocol.P2PSigExtensions = aux.Protocol.P2PSigExtensions
|
v.Protocol.P2PSigExtensions = aux.Protocol.P2PSigExtensions
|
||||||
v.Protocol.StateRootInHeader = aux.Protocol.StateRootInHeader
|
v.Protocol.StateRootInHeader = aux.Protocol.StateRootInHeader
|
||||||
v.Protocol.ValidatorsHistory = aux.Protocol.ValidatorsHistory
|
v.Protocol.ValidatorsHistory = aux.Protocol.ValidatorsHistory
|
||||||
v.StateRootInHeader = aux.StateRootInHeader
|
|
||||||
if len(aux.Protocol.InitialGasDistribution) == 0 {
|
if len(aux.Protocol.InitialGasDistribution) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
||||||
"wsport": 10334
|
"wsport": 10334
|
||||||
}`
|
}`
|
||||||
responseFromGoNew := `{
|
responseFromGoNew := `{
|
||||||
"network": 860833102,
|
|
||||||
"nonce": 1677922561,
|
"nonce": 1677922561,
|
||||||
"protocol": {
|
"protocol": {
|
||||||
"addressversion": 53,
|
"addressversion": 53,
|
||||||
|
@ -63,7 +62,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
||||||
"wsport": 10334
|
"wsport": 10334
|
||||||
}`
|
}`
|
||||||
v := &Version{
|
v := &Version{
|
||||||
Magic: 860833102,
|
|
||||||
TCPPort: 10333,
|
TCPPort: 10333,
|
||||||
WSPort: 10334,
|
WSPort: 10334,
|
||||||
Nonce: 1677922561,
|
Nonce: 1677922561,
|
||||||
|
@ -81,7 +79,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
||||||
InitialGasDistribution: fixedn.Fixed8FromInt64(52000000),
|
InitialGasDistribution: fixedn.Fixed8FromInt64(52000000),
|
||||||
StateRootInHeader: false,
|
StateRootInHeader: false,
|
||||||
},
|
},
|
||||||
StateRootInHeader: false,
|
|
||||||
}
|
}
|
||||||
t.Run("MarshalJSON", func(t *testing.T) {
|
t.Run("MarshalJSON", func(t *testing.T) {
|
||||||
actual, err := json.Marshal(v)
|
actual, err := json.Marshal(v)
|
||||||
|
@ -110,7 +107,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
||||||
expected := new(Version)
|
expected := new(Version)
|
||||||
*expected = *v
|
*expected = *v
|
||||||
expected.UserAgent = "/Neo:3.1.0/"
|
expected.UserAgent = "/Neo:3.1.0/"
|
||||||
expected.Magic = 0 // No magic in C#.
|
|
||||||
require.Equal(t, expected, actual)
|
require.Equal(t, expected, actual)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -167,10 +167,6 @@ func (c *Client) Init() error {
|
||||||
|
|
||||||
c.cache.network = version.Protocol.Network
|
c.cache.network = version.Protocol.Network
|
||||||
c.cache.stateRootInHeader = version.Protocol.StateRootInHeader
|
c.cache.stateRootInHeader = version.Protocol.StateRootInHeader
|
||||||
if version.Protocol.MillisecondsPerBlock == 0 {
|
|
||||||
c.cache.network = version.Magic
|
|
||||||
c.cache.stateRootInHeader = version.StateRootInHeader
|
|
||||||
}
|
|
||||||
for _, ctr := range natives {
|
for _, ctr := range natives {
|
||||||
c.cache.nativeHashes[ctr.Manifest.Name] = ctr.Hash
|
c.cache.nativeHashes[ctr.Manifest.Name] = ctr.Hash
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -692,11 +692,9 @@ func (s *Server) getVersion(_ params.Params) (interface{}, *neorpc.Error) {
|
||||||
|
|
||||||
cfg := s.chain.GetConfig()
|
cfg := s.chain.GetConfig()
|
||||||
return &result.Version{
|
return &result.Version{
|
||||||
Magic: s.network,
|
TCPPort: port,
|
||||||
TCPPort: port,
|
Nonce: s.coreServer.ID(),
|
||||||
Nonce: s.coreServer.ID(),
|
UserAgent: s.coreServer.UserAgent,
|
||||||
UserAgent: s.coreServer.UserAgent,
|
|
||||||
StateRootInHeader: cfg.StateRootInHeader,
|
|
||||||
Protocol: result.Protocol{
|
Protocol: result.Protocol{
|
||||||
AddressVersion: address.NEO3Prefix,
|
AddressVersion: address.NEO3Prefix,
|
||||||
Network: cfg.Magic,
|
Network: cfg.Magic,
|
||||||
|
|
Loading…
Reference in a new issue