Skip to content

Commit 2620eb8

Browse files
rpcsrv: add SessionEnabled, MaxIteratorResultItems to getversion
Extend getversion RPC response with RPC server settings (SessionEnabled, MaxIteratorResultItems).Port neo-project/neo-modules#878. Close #3276 Signed-off-by: Ekaterina Pavlova <[email protected]>
1 parent be1b97d commit 2620eb8

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

pkg/neorpc/result/version.go

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ type (
1919
Nonce uint32 `json:"nonce"`
2020
UserAgent string `json:"useragent"`
2121
Protocol Protocol `json:"protocol"`
22+
RPC RPC `json:"rpc"`
23+
}
24+
25+
// RPC represents the RPC server configuration.
26+
RPC struct {
27+
MaxIteratorResultItems int `json:"maxiteratorresultitems"`
28+
SessionEnabled bool `json:"sessionenabled"`
2229
}
2330

2431
// Protocol represents network-dependent parameters.

pkg/neorpc/result/version_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
4242
"validatorscount": 7,
4343
"hardforks": [{"name": "Aspidochelone", "blockheight": 123}, {"name": "Basilisk", "blockheight": 1234}]
4444
},
45+
"rpc": {
46+
"maxiteratorresultitems": 100,
47+
"sessionenabled": false
48+
},
4549
"tcpport": 10333,
4650
"useragent": "/NEO-GO:0.98.6/",
4751
"wsport": 10334
@@ -60,6 +64,10 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
6064
"validatorscount": 7,
6165
"hardforks": [{"name": "HF_Aspidochelone", "blockheight": 123}, {"name": "HF_Basilisk", "blockheight": 1234}]
6266
},
67+
"rpc": {
68+
"maxiteratorresultitems": 100,
69+
"sessionenabled": false
70+
},
6371
"tcpport": 10333,
6472
"useragent": "/Neo:3.1.0/",
6573
"wsport": 10334
@@ -69,6 +77,10 @@ func TestVersion_MarshalUnmarshalJSON(t *testing.T) {
6977
WSPort: 10334,
7078
Nonce: 1677922561,
7179
UserAgent: "/NEO-GO:0.98.6/",
80+
RPC: RPC{
81+
MaxIteratorResultItems: 100,
82+
SessionEnabled: false,
83+
},
7284
Protocol: Protocol{
7385
AddressVersion: 53,
7486
Network: 860833102,

pkg/rpcclient/rpc_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
10241024
invoke: func(c *Client) (any, error) {
10251025
return c.GetVersion()
10261026
},
1027-
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/"}}`,
1027+
serverResponse: `{"id":1,"jsonrpc":"2.0","result":{"tcpport":20332,"wsport":20342,"nonce":2153672787,"useragent":"/NEO-GO:0.73.1-pre-273-ge381358/", "protocol": {"network": 2, "hardforks": {}}, "rpc": {"maxiteratorresultitems": 100, "sessionenabled": false}}`,
10281028
result: func(c *Client) any {
10291029
return &result.Version{
10301030
TCPPort: uint16(20332),
@@ -1035,6 +1035,10 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
10351035
Network: netmode.UnitTestNet,
10361036
Hardforks: map[config.Hardfork]uint32{},
10371037
},
1038+
RPC: result.RPC{
1039+
MaxIteratorResultItems: 0,
1040+
SessionEnabled: false,
1041+
},
10381042
}
10391043
},
10401044
},

pkg/services/rpcsrv/server.go

+4
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ func (s *Server) getVersion(_ params.Params) (any, *neorpc.Error) {
868868
TCPPort: port,
869869
Nonce: s.coreServer.ID(),
870870
UserAgent: s.coreServer.UserAgent,
871+
RPC: result.RPC{
872+
MaxIteratorResultItems: s.config.MaxIteratorResultItems,
873+
SessionEnabled: s.config.SessionEnabled,
874+
},
871875
Protocol: result.Protocol{
872876
AddressVersion: address.NEO3Prefix,
873877
Network: cfg.Magic,

0 commit comments

Comments
 (0)