NMethodsField refactoring.
MODIFY
WalletWasabi/Tor/Socks5/Models/Fields/OctetFields/NMethodsField.cs
WalletWasabi/Tor/Socks5/Models/Fields/OctetFields/NMethodsField.cs
@@ -6,17 +6,16 @@ namespace WalletWasabi.Tor.Socks5.Models.Fields.OctetFields
{
public class NMethodsField : OctetSerializableBase
{
- public NMethodsField()
+ public NMethodsField(byte value)
{
+ ByteValue = value;
}
- public int Value => ByteValue;
-
- public void FromMethodsField(MethodsField methods)
+ public NMethodsField(MethodsField methods)
{
- Guard.NotNull(nameof(methods), methods);
-
ByteValue = (byte)methods.ToBytes().Length;
}
+
+ public int Value => ByteValue;
}
}

MODIFY
WalletWasabi/Tor/Socks5/Models/Messages/VersionMethodRequest.cs
WalletWasabi/Tor/Socks5/Models/Messages/VersionMethodRequest.cs
@@ -22,9 +22,7 @@ namespace WalletWasabi.Tor.Socks5.Models.Messages
Ver = VerField.Socks5;
// The NMETHODS field contains the number of method identifier octets that appear in the METHODS field.
- var nMethods = new NMethodsField();
- nMethods.FromMethodsField(methods);
- NMethods = nMethods;
+ NMethods = new NMethodsField(methods);
}
#endregion Constructors
@@ -47,9 +45,7 @@ namespace WalletWasabi.Tor.Socks5.Models.Messages
Guard.InRangeAndNotNull($"{nameof(bytes)}.{nameof(bytes.Length)}", bytes.Length, 3, 257);
Ver = new VerField(bytes[0]);
-
- NMethods = new NMethodsField();
- NMethods.FromByte(bytes[1]);
+ NMethods = new NMethodsField(bytes[1]);
if (NMethods.Value != bytes.Length - 2)
{

NMethodsField refactoring.