From 75947638e7db0fb0117eba869833677443f0c8ff Mon Sep 17 00:00:00 2001 From: Yahia Chiheb Date: Fri, 23 Aug 2019 03:46:37 +0100 Subject: [PATCH] Edit consts names --- WalletWasabi/Crypto/StringCipher.cs | 10 +++++----- .../Encoding/DataEncodation/EightBitByteEncoder.cs | 6 +++--- .../InputRecognition/ModeEncodeCheck.cs | 6 +++--- .../QrCodeNet/Encoding/Versions/VersionControl.cs | 12 ++++++------ WalletWasabi/Helpers/Constants.cs | 8 ++++---- WalletWasabi/Services/MempoolBehavior.cs | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/WalletWasabi/Crypto/StringCipher.cs b/WalletWasabi/Crypto/StringCipher.cs index 47f357b37e3..87e8b3de9b5 100644 --- a/WalletWasabi/Crypto/StringCipher.cs +++ b/WalletWasabi/Crypto/StringCipher.cs @@ -11,7 +11,7 @@ public static class StringCipher { // This constant is used to determine the keysize of the encryption algorithm in bits. // We divide this by 8 within the code below to get the equivalent number of bytes. - private const int Keysize = 128; + private const int KeySize = 128; // This constant determines the number of iterations for the password bytes generation function. private const int DerivationIterations = 1000; @@ -28,7 +28,7 @@ public static string Encrypt(string plainText, string passPhrase) using (var password = new Rfc2898DeriveBytes(passPhrase, salt, DerivationIterations)) { - key = password.GetBytes(Keysize / 8); + key = password.GetBytes(KeySize / 8); using (var aes = CreateAES()) { aes.GenerateIV(); @@ -81,15 +81,15 @@ public static string Decrypt(string cipherText, string passPhrase) var cipherLength = 0; using (var reader = new BinaryReader(memoryStream, Encoding.UTF8, true)) { - var salt = reader.ReadBytes(Keysize / 8); - iv = reader.ReadBytes(Keysize / 8); + var salt = reader.ReadBytes(KeySize / 8); + iv = reader.ReadBytes(KeySize / 8); var authenticationCode = reader.ReadBytes(32); cipherLength = (int)(memoryStream.Length - memoryStream.Position); var cipher = reader.ReadBytes(cipherLength); using (var password = new Rfc2898DeriveBytes(passPhrase, salt, DerivationIterations)) { - key = password.GetBytes(Keysize / 8); + key = password.GetBytes(KeySize / 8); } using (var hmac = new HMACSHA256(key)) diff --git a/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/EightBitByteEncoder.cs b/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/EightBitByteEncoder.cs index 02aa7a2ef01..bb5e04871a0 100644 --- a/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/EightBitByteEncoder.cs +++ b/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/EightBitByteEncoder.cs @@ -37,7 +37,7 @@ internal EightBitByteEncoder() : base() /// /// Bitcount, Chapter 8.4.4, P.24 /// - private const int EIGHT_BIT_BYTE_BITCOUNT = 8; + private const int EightBitByteBitcount = 8; internal override BitList GetDataBits(string content) { @@ -64,13 +64,13 @@ internal BitList GetDataBitsByByteArray(byte[] encodeContent, string encodingNam byte[] utf8BOM = QRCodeConstantVariable.UTF8ByteOrderMark; for (int index = 0; index < utf8BOM.Length; index++) { - dataBits.Add(utf8BOM[index], EIGHT_BIT_BYTE_BITCOUNT); + dataBits.Add(utf8BOM[index], EightBitByteBitcount); } } for (int index = 0; index < encodeContent.Length; index++) { - dataBits.Add(encodeContent[index], EIGHT_BIT_BYTE_BITCOUNT); + dataBits.Add(encodeContent[index], EightBitByteBitcount); } return dataBits; } diff --git a/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/InputRecognition/ModeEncodeCheck.cs b/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/InputRecognition/ModeEncodeCheck.cs index bbdf8b3c9e9..de35ff5b16e 100644 --- a/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/InputRecognition/ModeEncodeCheck.cs +++ b/WalletWasabi/Gma/QrCodeNet/Encoding/DataEncodation/InputRecognition/ModeEncodeCheck.cs @@ -13,7 +13,7 @@ public static bool IsModeEncodeValid(string encoding, string content) /// Encoding.GetEncoding.GetBytes will transform char to 0x3F if that char not belong to current encoding table. /// 0x3F is '?' /// - private const int QUESTION_MARK_CHAR = 0x3F; + private const int QuestionMarkChar = 0x3F; private static bool EightBitByteCheck(string encodingName, string content) { @@ -54,7 +54,7 @@ internal static int TryEncodeEightBitByte(string content, string encodingName, i currentChar[0] = content[index]; bytes = encoding.GetBytes(currentChar); int length = bytes.Length; - if (currentChar[0] != '?' && length == 1 && bytes[0] == QUESTION_MARK_CHAR) + if (currentChar[0] != '?' && length == 1 && bytes[0] == QuestionMarkChar) { return index; } @@ -69,7 +69,7 @@ internal static int TryEncodeEightBitByte(string content, string encodingName, i currentChar[0] = content[index]; bytes = encoding.GetBytes(currentChar); int length = bytes.Length; - if (currentChar[0] != '?' && length == 1 && bytes[0] == QUESTION_MARK_CHAR) + if (currentChar[0] != '?' && length == 1 && bytes[0] == QuestionMarkChar) { return index; } diff --git a/WalletWasabi/Gma/QrCodeNet/Encoding/Versions/VersionControl.cs b/WalletWasabi/Gma/QrCodeNet/Encoding/Versions/VersionControl.cs index 1aeed35fae8..d8129ada9b9 100644 --- a/WalletWasabi/Gma/QrCodeNet/Encoding/Versions/VersionControl.cs +++ b/WalletWasabi/Gma/QrCodeNet/Encoding/Versions/VersionControl.cs @@ -5,8 +5,8 @@ namespace Gma.QrCodeNet.Encoding.Versions { internal static class VersionControl { - private const int NUM_BITS_MODE_INDICATOR = 4; - private const string DEFAULT_ENCODING = QRCodeConstantVariable.DefaultEncoding; + private const int NumBitsModeIndicator = 4; + private const string DefaultEncoding = QRCodeConstantVariable.DefaultEncoding; /// /// Determine which version to use @@ -22,7 +22,7 @@ internal static VersionControlStruct InitialSetup(int dataBitsLength, ErrorCorre BitList eciHeader = new BitList(); - if (encodingName != DEFAULT_ENCODING && encodingName != QRCodeConstantVariable.UTF8Encoding) + if (encodingName != DefaultEncoding && encodingName != QRCodeConstantVariable.UTF8Encoding) { ECISet eciSet = new ECISet(ECISet.AppendOption.NameToValue); int eciValue = eciSet.GetECIValueByName(encodingName); @@ -37,7 +37,7 @@ internal static VersionControlStruct InitialSetup(int dataBitsLength, ErrorCorre int[] charCountIndicator = CharCountIndicatorTable.GetCharCountIndicatorSet(); - totalDataBits += (NUM_BITS_MODE_INDICATOR + charCountIndicator[searchGroup]); + totalDataBits += (NumBitsModeIndicator + charCountIndicator[searchGroup]); int lowerSearchBoundary = searchGroup == 0 ? 1 : (VERSION_GROUP[searchGroup - 1] + 1); int higherSearchBoundary = VERSION_GROUP[searchGroup]; @@ -93,7 +93,7 @@ private static int DynamicSearchIndicator(int numBits, ErrorCorrectionLevel leve int loopLength = VERSION_GROUP.Length; for (int i = 0; i < loopLength; i++) { - int totalBits = numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator[i]; + int totalBits = numBits + NumBitsModeIndicator + charCountIndicator[i]; QRCodeVersion version = VersionTable.GetVersionByNum(VERSION_GROUP[i]); int numECCodewords = version.GetECBlocksByLevel(level).NumErrorCorrectionCodewards; @@ -106,7 +106,7 @@ private static int DynamicSearchIndicator(int numBits, ErrorCorrectionLevel leve } } - throw new InputOutOfBoundaryException($"QRCode do not have enough space for {(numBits + NUM_BITS_MODE_INDICATOR + charCountIndicator[2])} bits"); + throw new InputOutOfBoundaryException($"QRCode do not have enough space for {(numBits + NumBitsModeIndicator + charCountIndicator[2])} bits"); } /// diff --git a/WalletWasabi/Helpers/Constants.cs b/WalletWasabi/Helpers/Constants.cs index 4f7f3afbbe4..452e4277142 100644 --- a/WalletWasabi/Helpers/Constants.cs +++ b/WalletWasabi/Helpers/Constants.cs @@ -11,26 +11,26 @@ public static class Constants public const string BackendMajorVersion = "3"; public static readonly VersionsResponse VersionsResponse = new VersionsResponse { ClientVersion = ClientVersion.ToString(), BackendMajorVersion = BackendMajorVersion }; - public const uint ProtocolVersion_WITNESS_VERSION = 70012; + public const uint ProtocolVersionWitnessVersion = 70012; public static readonly NodeRequirement NodeRequirements = new NodeRequirement { RequiredServices = NodeServices.NODE_WITNESS, - MinVersion = ProtocolVersion_WITNESS_VERSION, + MinVersion = ProtocolVersionWitnessVersion, MinProtocolCapabilities = new ProtocolCapabilities { SupportGetBlock = true, SupportWitness = true, SupportMempoolQuery = true } }; public static readonly NodeRequirement LocalNodeRequirements = new NodeRequirement { RequiredServices = NodeServices.NODE_WITNESS, - MinVersion = ProtocolVersion_WITNESS_VERSION, + MinVersion = ProtocolVersionWitnessVersion, MinProtocolCapabilities = new ProtocolCapabilities { SupportGetBlock = true, SupportWitness = true } }; public static readonly NodeRequirement LocalBackendNodeRequirements = new NodeRequirement { RequiredServices = NodeServices.NODE_WITNESS, - MinVersion = ProtocolVersion_WITNESS_VERSION, + MinVersion = ProtocolVersionWitnessVersion, MinProtocolCapabilities = new ProtocolCapabilities { SupportGetBlock = true, diff --git a/WalletWasabi/Services/MempoolBehavior.cs b/WalletWasabi/Services/MempoolBehavior.cs index dc98573b114..7205907ca6e 100644 --- a/WalletWasabi/Services/MempoolBehavior.cs +++ b/WalletWasabi/Services/MempoolBehavior.cs @@ -12,7 +12,7 @@ namespace WalletWasabi.Services { public class MempoolBehavior : NodeBehavior { - private const int MAX_INV_SIZE = 50000; + private const int MaxInvSize = 50000; public MempoolService MempoolService { get; } @@ -66,9 +66,9 @@ private async void AttachedNode_MessageReceivedAsync(Node node, IncomingMessage private async Task ProcessGetDataAsync(Node node, GetDataPayload payload) { - if (payload.Inventory.Count > MAX_INV_SIZE) + if (payload.Inventory.Count > MaxInvSize) { - Logger.LogDebug($"Received inventory too big. {nameof(MAX_INV_SIZE)}: {MAX_INV_SIZE}, Node: {node.RemoteSocketEndpoint}"); + Logger.LogDebug($"Received inventory too big. {nameof(MaxInvSize)}: {MaxInvSize}, Node: {node.RemoteSocketEndpoint}"); return; } @@ -105,9 +105,9 @@ private async Task ProcessGetDataAsync(Node node, GetDataPayload payload) private async Task ProcessInvAsync(Node node, InvPayload payload) { - if (payload.Inventory.Count > MAX_INV_SIZE) + if (payload.Inventory.Count > MaxInvSize) { - Logger.LogDebug($"Received inventory too big. {nameof(MAX_INV_SIZE)}: {MAX_INV_SIZE}, Node: {node.RemoteSocketEndpoint}"); + Logger.LogDebug($"Received inventory too big. {nameof(MaxInvSize)}: {MaxInvSize}, Node: {node.RemoteSocketEndpoint}"); return; }