Skip to content

Commit 450cb61

Browse files
shargonNGDAdmin
andauthored
[rpc] Extend getversion RPC response with additional protocol settings (#3443)
* getversion * Extend client --------- Co-authored-by: NGD Admin <154295625+NGDAdmin@users.noreply.github.com>
1 parent 3c7d249 commit 450cb61

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/Plugins/RpcClient/Models/RpcVersion.cs

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// Redistribution and use in source and binary forms with or without
1010
// modifications are permitted.
1111

12+
using Neo.Cryptography.ECC;
1213
using Neo.Json;
1314
using System;
1415
using System.Collections.Generic;
@@ -30,6 +31,8 @@ public class RpcProtocol
3031
public int MemoryPoolMaxTransactions { get; set; }
3132
public ulong InitialGasDistribution { get; set; }
3233
public IReadOnlyDictionary<Hardfork, uint> Hardforks { get; set; }
34+
public IReadOnlyList<string> SeedList { get; set; }
35+
public IReadOnlyList<ECPoint> StandbyCommittee { get; set; }
3336

3437
public JObject ToJson()
3538
{
@@ -49,6 +52,8 @@ public JObject ToJson()
4952
["name"] = StripPrefix(s.Key.ToString(), "HF_"),
5053
["blockheight"] = s.Value,
5154
}));
55+
json["standbycommittee"] = new JArray(StandbyCommittee.Select(u => new JString(u.ToString())));
56+
json["seedlist"] = new JArray(SeedList.Select(u => new JString(u)));
5257
return json;
5358
}
5459

@@ -71,6 +76,14 @@ public static RpcProtocol FromJson(JObject json)
7176
// Add HF_ prefix to the hardfork response for proper Hardfork enum parsing.
7277
return new KeyValuePair<Hardfork, uint>(Enum.Parse<Hardfork>(name.StartsWith("HF_") ? name : $"HF_{name}"), (uint)s["blockheight"].AsNumber());
7378
})),
79+
SeedList = new List<string>(((JArray)json["seedlist"]).Select(s =>
80+
{
81+
return s.AsString();
82+
})),
83+
StandbyCommittee = new List<ECPoint>(((JArray)json["standbycommittee"]).Select(s =>
84+
{
85+
return ECPoint.Parse(s.AsString(), ECCurve.Secp256r1);
86+
}))
7487
};
7588
}
7689

src/Plugins/RpcServer/RpcServer.Node.cs

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ protected internal virtual JToken GetVersion(JArray _params)
139139
forkJson["blockheight"] = hf.Value;
140140
return forkJson;
141141
}));
142+
protocol["standbycommittee"] = new JArray(system.Settings.StandbyCommittee.Select(u => new JString(u.ToString())));
143+
protocol["seedlist"] = new JArray(system.Settings.SeedList.Select(u => new JString(u)));
142144
json["rpc"] = rpc;
143145
json["protocol"] = protocol;
144146
return json;

tests/Neo.Network.RPC.Tests/RpcTestCases.json

+30
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,36 @@
24962496
"name": "Aspidochelone",
24972497
"blockheight": 0
24982498
}
2499+
],
2500+
"standbycommittee": [
2501+
"03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c",
2502+
"02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093",
2503+
"03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a",
2504+
"02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554",
2505+
"024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d",
2506+
"02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e",
2507+
"02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70",
2508+
"023a36c72844610b4d34d1968662424011bf783ca9d984efa19a20babf5582f3fe",
2509+
"03708b860c1de5d87f5b151a12c2a99feebd2e8b315ee8e7cf8aa19692a9e18379",
2510+
"03c6aa6e12638b36e88adc1ccdceac4db9929575c3e03576c617c49cce7114a050",
2511+
"03204223f8c86b8cd5c89ef12e4f0dbb314172e9241e30c9ef2293790793537cf0",
2512+
"02a62c915cf19c7f19a50ec217e79fac2439bbaad658493de0c7d8ffa92ab0aa62",
2513+
"03409f31f0d66bdc2f70a9730b66fe186658f84a8018204db01c106edc36553cd0",
2514+
"0288342b141c30dc8ffcde0204929bb46aed5756b41ef4a56778d15ada8f0c6654",
2515+
"020f2887f41474cfeb11fd262e982051c1541418137c02a0f4961af911045de639",
2516+
"0222038884bbd1d8ff109ed3bdef3542e768eef76c1247aea8bc8171f532928c30",
2517+
"03d281b42002647f0113f36c7b8efb30db66078dfaaa9ab3ff76d043a98d512fde",
2518+
"02504acbc1f4b3bdad1d86d6e1a08603771db135a73e61c9d565ae06a1938cd2ad",
2519+
"0226933336f1b75baa42d42b71d9091508b638046d19abd67f4e119bf64a7cfb4d",
2520+
"03cdcea66032b82f5c30450e381e5295cae85c5e6943af716cc6b646352a6067dc",
2521+
"02cd5a5547119e24feaa7c2a0f37b8c9366216bab7054de0065c9be42084003c8a"
2522+
],
2523+
"seedlist": [
2524+
"seed1.neo.org:10333",
2525+
"seed2.neo.org:10333",
2526+
"seed3.neo.org:10333",
2527+
"seed4.neo.org:10333",
2528+
"seed5.neo.org:10333"
24992529
]
25002530
}
25012531
}

tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.Node.cs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public void TestGetVersion()
4242
Assert.IsTrue(protocol.ContainsProperty("maxvaliduntilblockincrement"));
4343
Assert.IsTrue(protocol.ContainsProperty("maxtransactionsperblock"));
4444
Assert.IsTrue(protocol.ContainsProperty("memorypoolmaxtransactions"));
45+
Assert.IsTrue(protocol.ContainsProperty("standbycommittee"));
46+
Assert.IsTrue(protocol.ContainsProperty("seedlist"));
4547
}
4648

4749
#region SendRawTransaction Tests

0 commit comments

Comments
 (0)