forked from TrueCloudLab/neoneo-go
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
|
||||
// info.
|
||||
Version struct {
|
||||
// Magic contains network magic.
|
||||
// Deprecated: use Protocol.Network instead
|
||||
Magic netmode.Magic
|
||||
TCPPort uint16
|
||||
WSPort uint16
|
||||
Nonce uint32
|
||||
UserAgent string
|
||||
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.
|
||||
|
@ -57,13 +51,11 @@ type (
|
|||
type (
|
||||
// versionMarshallerAux is an auxiliary struct used for Version JSON marshalling.
|
||||
versionMarshallerAux struct {
|
||||
Magic netmode.Magic `json:"network"`
|
||||
TCPPort uint16 `json:"tcpport"`
|
||||
WSPort uint16 `json:"wsport,omitempty"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
UserAgent string `json:"useragent"`
|
||||
Protocol protocolMarshallerAux `json:"protocol"`
|
||||
StateRootInHeader bool `json:"staterootinheader,omitempty"`
|
||||
TCPPort uint16 `json:"tcpport"`
|
||||
WSPort uint16 `json:"wsport,omitempty"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
UserAgent string `json:"useragent"`
|
||||
Protocol protocolMarshallerAux `json:"protocol"`
|
||||
}
|
||||
|
||||
// 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 struct {
|
||||
Magic netmode.Magic `json:"network"`
|
||||
TCPPort uint16 `json:"tcpport"`
|
||||
WSPort uint16 `json:"wsport,omitempty"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
UserAgent string `json:"useragent"`
|
||||
Protocol protocolUnmarshallerAux `json:"protocol"`
|
||||
StateRootInHeader bool `json:"staterootinheader,omitempty"`
|
||||
TCPPort uint16 `json:"tcpport"`
|
||||
WSPort uint16 `json:"wsport,omitempty"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
UserAgent string `json:"useragent"`
|
||||
Protocol protocolUnmarshallerAux `json:"protocol"`
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (v *Version) MarshalJSON() ([]byte, error) {
|
||||
aux := versionMarshallerAux{
|
||||
Magic: v.Magic,
|
||||
TCPPort: v.TCPPort,
|
||||
WSPort: v.WSPort,
|
||||
Nonce: v.Nonce,
|
||||
|
@ -142,7 +131,6 @@ func (v *Version) MarshalJSON() ([]byte, error) {
|
|||
StateRootInHeader: v.Protocol.StateRootInHeader,
|
||||
ValidatorsHistory: v.Protocol.ValidatorsHistory,
|
||||
},
|
||||
StateRootInHeader: v.StateRootInHeader,
|
||||
}
|
||||
return json.Marshal(aux)
|
||||
}
|
||||
|
@ -154,7 +142,6 @@ func (v *Version) UnmarshalJSON(data []byte) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
v.Magic = aux.Magic
|
||||
v.TCPPort = aux.TCPPort
|
||||
v.WSPort = aux.WSPort
|
||||
v.Nonce = aux.Nonce
|
||||
|
@ -171,7 +158,6 @@ func (v *Version) UnmarshalJSON(data []byte) error {
|
|||
v.Protocol.P2PSigExtensions = aux.Protocol.P2PSigExtensions
|
||||
v.Protocol.StateRootInHeader = aux.Protocol.StateRootInHeader
|
||||
v.Protocol.ValidatorsHistory = aux.Protocol.ValidatorsHistory
|
||||
v.StateRootInHeader = aux.StateRootInHeader
|
||||
if len(aux.Protocol.InitialGasDistribution) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
|||
"wsport": 10334
|
||||
}`
|
||||
responseFromGoNew := `{
|
||||
"network": 860833102,
|
||||
"nonce": 1677922561,
|
||||
"protocol": {
|
||||
"addressversion": 53,
|
||||
|
@ -63,7 +62,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
|||
"wsport": 10334
|
||||
}`
|
||||
v := &Version{
|
||||
Magic: 860833102,
|
||||
TCPPort: 10333,
|
||||
WSPort: 10334,
|
||||
Nonce: 1677922561,
|
||||
|
@ -81,7 +79,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
|||
InitialGasDistribution: fixedn.Fixed8FromInt64(52000000),
|
||||
StateRootInHeader: false,
|
||||
},
|
||||
StateRootInHeader: false,
|
||||
}
|
||||
t.Run("MarshalJSON", func(t *testing.T) {
|
||||
actual, err := json.Marshal(v)
|
||||
|
@ -110,7 +107,6 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
|
|||
expected := new(Version)
|
||||
*expected = *v
|
||||
expected.UserAgent = "/Neo:3.1.0/"
|
||||
expected.Magic = 0 // No magic in C#.
|
||||
require.Equal(t, expected, actual)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -167,10 +167,6 @@ func (c *Client) Init() error {
|
|||
|
||||
c.cache.network = version.Protocol.Network
|
||||
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 {
|
||||
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()
|
||||
return &result.Version{
|
||||
Magic: s.network,
|
||||
TCPPort: port,
|
||||
Nonce: s.coreServer.ID(),
|
||||
UserAgent: s.coreServer.UserAgent,
|
||||
StateRootInHeader: cfg.StateRootInHeader,
|
||||
TCPPort: port,
|
||||
Nonce: s.coreServer.ID(),
|
||||
UserAgent: s.coreServer.UserAgent,
|
||||
Protocol: result.Protocol{
|
||||
AddressVersion: address.NEO3Prefix,
|
||||
Network: cfg.Magic,
|
||||
|
|
Loading…
Reference in a new issue