Merge pull request #3386 from nspcc-dev/getversion

rpcsrv: add SessionEnabled, MaxIteratorResultItems to `getversion`
This commit is contained in:
Anna Shaleva 2024-04-04 10:38:09 +03:00 committed by GitHub
commit b1a986fba8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 2 deletions

View file

@ -19,6 +19,13 @@ type (
Nonce uint32 `json:"nonce"`
UserAgent string `json:"useragent"`
Protocol Protocol `json:"protocol"`
RPC RPC `json:"rpc"`
}
// RPC represents the RPC server configuration.
RPC struct {
MaxIteratorResultItems int `json:"maxiteratorresultitems"`
SessionEnabled bool `json:"sessionenabled"`
}
// Protocol represents network-dependent parameters.

View file

@ -42,6 +42,10 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
"validatorscount": 7,
"hardforks": [{"name": "Aspidochelone", "blockheight": 123}, {"name": "Basilisk", "blockheight": 1234}]
},
"rpc": {
"maxiteratorresultitems": 100,
"sessionenabled": true
},
"tcpport": 10333,
"useragent": "/NEO-GO:0.98.6/",
"wsport": 10334
@ -60,6 +64,10 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
"validatorscount": 7,
"hardforks": [{"name": "HF_Aspidochelone", "blockheight": 123}, {"name": "HF_Basilisk", "blockheight": 1234}]
},
"rpc": {
"maxiteratorresultitems": 100,
"sessionenabled": true
},
"tcpport": 10333,
"useragent": "/Neo:3.1.0/",
"wsport": 10334
@ -69,6 +77,10 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
WSPort: 10334,
Nonce: 1677922561,
UserAgent: "/NEO-GO:0.98.6/",
RPC: RPC{
MaxIteratorResultItems: 100,
SessionEnabled: true,
},
Protocol: Protocol{
AddressVersion: 53,
Network: 860833102,

File diff suppressed because one or more lines are too long

View file

@ -868,6 +868,10 @@ func (s *Server) getVersion(_ params.Params) (any, *neorpc.Error) {
TCPPort: port,
Nonce: s.coreServer.ID(),
UserAgent: s.coreServer.UserAgent,
RPC: result.RPC{
MaxIteratorResultItems: s.config.MaxIteratorResultItems,
SessionEnabled: s.config.SessionEnabled,
},
Protocol: result.Protocol{
AddressVersion: address.NEO3Prefix,
Network: cfg.Magic,