diff --git a/src/neo/Cryptography/Base58.cs b/src/neo/Cryptography/Base58.cs index 92ec97291e..7d52704a95 100644 --- a/src/neo/Cryptography/Base58.cs +++ b/src/neo/Cryptography/Base58.cs @@ -45,7 +45,9 @@ public static byte[] Base58CheckDecode(this string input) } /// - /// Converts a byte array to its equivalent representation that is encoded with base-58 digits. The encoded contains the checksum of the binary data. + /// Converts a byte array to its equivalent + /// representation that is encoded with base-58 digits. + /// The encoded contains the checksum of the binary data. /// /// The byte array to convert. /// The representation, in base-58, of the contents of . @@ -67,7 +69,7 @@ public static string Base58CheckEncode(this ReadOnlySpan data) /// A byte array that is equivalent to . public static byte[] Decode(string input) { - // Decode Base58 string to BigInteger + // Decode Base58 string to BigInteger var bi = BigInteger.Zero; for (int i = 0; i < input.Length; i++) { diff --git a/src/neo/Cryptography/ECC/ECPoint.cs b/src/neo/Cryptography/ECC/ECPoint.cs index 8474864052..d49a0641da 100644 --- a/src/neo/Cryptography/ECC/ECPoint.cs +++ b/src/neo/Cryptography/ECC/ECPoint.cs @@ -241,10 +241,10 @@ internal static ECPoint Multiply(ECPoint p, BigInteger k) // width of the Window NAF sbyte width; - // Required length of precomputation array + // Required length of precomputing array int reqPreCompLen; - // Determine optimal width and corresponding length of precomputation + // Determine optimal width and corresponding length of precomputing array // array based on literature values if (m < 13) { @@ -282,7 +282,7 @@ internal static ECPoint Multiply(ECPoint p, BigInteger k) reqPreCompLen = 127; } - // The length of the precomputation array + // The length of the precomputing array int preCompLen = 1; ECPoint[] preComp = new ECPoint[] { p }; @@ -290,7 +290,7 @@ internal static ECPoint Multiply(ECPoint p, BigInteger k) if (preCompLen < reqPreCompLen) { - // Precomputation array must be made bigger, copy existing preComp + // Precomputing array must be made bigger, copy existing preComp // array into the larger new preComp array ECPoint[] oldPreComp = preComp; preComp = new ECPoint[reqPreCompLen]; @@ -298,7 +298,7 @@ internal static ECPoint Multiply(ECPoint p, BigInteger k) for (int i = preCompLen; i < reqPreCompLen; i++) { - // Compute the new ECPoints for the precomputation array. + // Compute the new ECPoints for the precomputing array. // The values 1, 3, 5, ..., 2^(width-1)-1 times p are // computed preComp[i] = twiceP + preComp[i - 1]; diff --git a/src/neo/Helper.cs b/src/neo/Helper.cs index fa47cb6669..c81e34bf41 100644 --- a/src/neo/Helper.cs +++ b/src/neo/Helper.cs @@ -288,7 +288,7 @@ public static ulong ToTimestampMS(this DateTime time) } /// - /// Checks if address is IPv4 Maped to IPv6 format, if so, Map to IPv4. + /// Checks if address is IPv4 Mapped to IPv6 format, if so, Map to IPv4. /// Otherwise, return current address. /// internal static IPAddress Unmap(this IPAddress address) @@ -299,7 +299,7 @@ internal static IPAddress Unmap(this IPAddress address) } /// - /// Checks if IPEndPoint is IPv4 Maped to IPv6 format, if so, unmap to IPv4. + /// Checks if IPEndPoint is IPv4 Mapped to IPv6 format, if so, unmap to IPv4. /// Otherwise, return current endpoint. /// internal static IPEndPoint Unmap(this IPEndPoint endPoint) diff --git a/src/neo/IO/ByteArrayEqualityComparer.cs b/src/neo/IO/ByteArrayEqualityComparer.cs index b069d87228..d6121fc9fb 100644 --- a/src/neo/IO/ByteArrayEqualityComparer.cs +++ b/src/neo/IO/ByteArrayEqualityComparer.cs @@ -1,10 +1,10 @@ // Copyright (C) 2015-2021 The Neo Project. -// -// The neo is free software distributed under the MIT software license, +// +// The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the -// project or http://www.opensource.org/licenses/mit-license.php +// project or http://www.opensource.org/licenses/mit-license.php // for more details. -// +// // Redistribution and use in source and binary forms with or without // modifications are permitted. diff --git a/src/neo/IO/Caching/HashSetCache.cs b/src/neo/IO/Caching/HashSetCache.cs index 3e6eea90f7..ba15393787 100644 --- a/src/neo/IO/Caching/HashSetCache.cs +++ b/src/neo/IO/Caching/HashSetCache.cs @@ -1,10 +1,10 @@ // Copyright (C) 2015-2021 The Neo Project. -// -// The neo is free software distributed under the MIT software license, +// +// The neo is free software distributed under the MIT software license, // see the accompanying file LICENSE in the main directory of the -// project or http://www.opensource.org/licenses/mit-license.php +// project or http://www.opensource.org/licenses/mit-license.php // for more details. -// +// // Redistribution and use in source and binary forms with or without // modifications are permitted. @@ -18,12 +18,12 @@ class HashSetCache : IReadOnlyCollection where T : IEquatable { /// /// Sets where the Hashes are stored - /// + /// private readonly LinkedList> sets = new(); /// /// Maximum capacity of each bucket inside each HashSet of . - /// + /// private readonly int bucketCapacity; /// diff --git a/src/neo/IO/Caching/IndexedQueue.cs b/src/neo/IO/Caching/IndexedQueue.cs index 0cdca447a5..40fc8e6a89 100644 --- a/src/neo/IO/Caching/IndexedQueue.cs +++ b/src/neo/IO/Caching/IndexedQueue.cs @@ -107,9 +107,9 @@ public void Enqueue(T item) } /// - /// Provides access to the item at the front of the queue without dequeueing it + /// Provides access to the item at the front of the queue without dequeuing it /// - /// The frontmost item + /// The front most item public T Peek() { if (_count == 0) @@ -201,7 +201,7 @@ public void TrimExcess() } /// - /// Copys the queue's items to a destination array + /// Copy the queue's items to a destination array /// /// The destination array /// The index in the destination to start copying at diff --git a/src/neo/Ledger/MemoryPool.cs b/src/neo/Ledger/MemoryPool.cs index 839af3e7b1..6ade372ee1 100644 --- a/src/neo/Ledger/MemoryPool.cs +++ b/src/neo/Ledger/MemoryPool.cs @@ -29,13 +29,13 @@ public class MemoryPool : IReadOnlyCollection public event EventHandler TransactionAdded; public event EventHandler TransactionRemoved; - // Allow a reverified transaction to be rebroadcasted if it has been this many block times since last broadcast. + // Allow a reverified transaction to be rebroadcast if it has been this many block times since last broadcast. private const int BlocksTillRebroadcast = 10; private int RebroadcastMultiplierThreshold => Capacity / 10; private readonly double MaxMillisecondsToReverifyTx; - // These two are not expected to be hit, they are just safegaurds. + // These two are not expected to be hit, they are just safeguards. private readonly double MaxMillisecondsToReverifyTxPerIdle; private readonly NeoSystem _system; @@ -55,7 +55,7 @@ public class MemoryPool : IReadOnlyCollection /// private readonly Dictionary _unsortedTransactions = new(); /// - /// Stores the verified sorted transactins currently in the pool. + /// Stores the verified sorted transactions currently in the pool. /// private readonly SortedSet _sortedTransactions = new(); diff --git a/src/neo/NeoSystem.cs b/src/neo/NeoSystem.cs index c72d81fd3a..1007e0f40d 100644 --- a/src/neo/NeoSystem.cs +++ b/src/neo/NeoSystem.cs @@ -165,7 +165,7 @@ public void Dispose() { foreach (var p in Plugin.Plugins) p.Dispose(); - EnsureStoped(LocalNode); + EnsureStopped(LocalNode); // Dispose will call ActorSystem.Terminate() ActorSystem.Dispose(); ActorSystem.WhenTerminated.Wait(); @@ -194,15 +194,14 @@ public T GetService(Func filter = null) IEnumerable result = services.OfType(); if (filter is null) return result.FirstOrDefault(); - else - return result.FirstOrDefault(filter); + return result.FirstOrDefault(filter); } /// /// Blocks the current thread until the specified actor has stopped. /// /// The actor to wait. - public void EnsureStoped(IActorRef actor) + public void EnsureStopped(IActorRef actor) { using Inbox inbox = Inbox.Create(ActorSystem); inbox.Watch(actor); diff --git a/src/neo/Network/P2P/LocalNode.cs b/src/neo/Network/P2P/LocalNode.cs index 0929b59140..6dbbf31d88 100644 --- a/src/neo/Network/P2P/LocalNode.cs +++ b/src/neo/Network/P2P/LocalNode.cs @@ -112,7 +112,7 @@ private void BroadcastMessage(MessageCommand command, ISerializable payload = nu /// /// Broadcast a message to all connected nodes. /// - /// The message to be broadcasted. + /// The message to be broadcast. private void BroadcastMessage(Message message) => SendToRemoteNodes(message); /// @@ -160,7 +160,8 @@ internal static IPEndPoint GetIpEndPoint(string hostAndPort) /// /// Checks the new connection. - /// If it is equal to the nonce of local or any remote node, it'll return false, else we'll return true and update the Listener address of the connected remote node. + /// If it is equal to the nonce of local or any remote node, it'll return false, + /// else we'll return true and update the Listener address of the connected remote node. /// /// Remote node actor. /// Remote node object. @@ -200,8 +201,10 @@ public IEnumerable GetUnconnectedPeers() } /// - /// Performs a broadcast with the command , which, eventually, tells all known connections. - /// If there are no connected peers it will try with the default, respecting limit. + /// Performs a broadcast with the command , + /// which, eventually, tells all known connections. + /// If there are no connected peers it will try with the default, + /// respecting limit. /// /// Number of peers that are being requested. protected override void NeedMorePeers(int count) @@ -244,7 +247,8 @@ protected override void OnReceive(object message) private void OnRelayDirectly(IInventory inventory) { var message = new RemoteNode.Relay { Inventory = inventory }; - // When relaying a block, if the block's index is greater than 'LastBlockIndex' of the RemoteNode, relay the block; + // When relaying a block, if the block's index is greater than + // 'LastBlockIndex' of the RemoteNode, relay the block; // otherwise, don't relay. if (inventory is Block block) { diff --git a/src/neo/Network/P2P/Payloads/Header.cs b/src/neo/Network/P2P/Payloads/Header.cs index f5473d48f9..0cee55b052 100644 --- a/src/neo/Network/P2P/Payloads/Header.cs +++ b/src/neo/Network/P2P/Payloads/Header.cs @@ -133,7 +133,7 @@ public UInt256 Hash sizeof(uint) + // Index sizeof(byte) + // PrimaryIndex UInt160.Length + // NextConsensus - 1 + Witness.Size; // Witness + 1 + Witness.Size; // Witness Witness[] IVerifiable.Witnesses { diff --git a/src/neo/Network/P2P/Payloads/PingPayload.cs b/src/neo/Network/P2P/Payloads/PingPayload.cs index 048c8b7157..d744702c3a 100644 --- a/src/neo/Network/P2P/Payloads/PingPayload.cs +++ b/src/neo/Network/P2P/Payloads/PingPayload.cs @@ -30,7 +30,8 @@ public class PingPayload : ISerializable public uint Timestamp; /// - /// A random number. This number must be the same in and messages. + /// A random number. This number must be the same in + /// and messages. /// public uint Nonce; diff --git a/src/neo/Network/P2P/Payloads/Signer.cs b/src/neo/Network/P2P/Payloads/Signer.cs index b91d1d45f5..e6a2ce0a78 100644 --- a/src/neo/Network/P2P/Payloads/Signer.cs +++ b/src/neo/Network/P2P/Payloads/Signer.cs @@ -40,17 +40,20 @@ public class Signer : IInteroperable, ISerializable public WitnessScope Scopes; /// - /// The contracts that allowed by the witness. Only available when the flag is set. + /// The contracts that allowed by the witness. + /// Only available when the flag is set. /// public UInt160[] AllowedContracts; /// - /// The groups that allowed by the witness. Only available when the flag is set. + /// The groups that allowed by the witness. + /// Only available when the flag is set. /// public ECPoint[] AllowedGroups; /// - /// The rules that the witness must meet. Only available when the flag is set. + /// The rules that the witness must meet. + /// Only available when the flag is set. /// public WitnessRule[] Rules; @@ -81,7 +84,7 @@ public void Deserialize(ref MemoryReader reader) } /// - /// Converts all rules contianed in the object to . + /// Converts all rules contained in the object to . /// /// The array used to represent the current signer. public IEnumerable GetAllRules() diff --git a/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs b/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs index 85b1b4f628..ad6350a777 100644 --- a/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs +++ b/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs @@ -233,7 +233,8 @@ private void OnGetBlockByIndexMessageReceived(GetBlockByIndexPayload payload) /// /// Will be triggered when a MessageCommand.GetData message is received. /// The payload includes an array of hash values. - /// For different payload.Type (Tx, Block, Consensus), get the corresponding (Txs, Blocks, Consensus) and tell them to RemoteNode actor. + /// For different payload.Type (Tx, Block, Consensus), + /// get the corresponding (Txs, Blocks, Consensus) and tell them to RemoteNode actor. /// /// The payload containing the requested information. private void OnGetDataMessageReceived(InvPayload payload) diff --git a/src/neo/Network/P2P/TaskManager.cs b/src/neo/Network/P2P/TaskManager.cs index 6825639171..ace01b16f9 100644 --- a/src/neo/Network/P2P/TaskManager.cs +++ b/src/neo/Network/P2P/TaskManager.cs @@ -51,7 +51,7 @@ private class Timer { } private static readonly TimeSpan TaskTimeout = TimeSpan.FromMinutes(1); private static readonly UInt256 HeaderTaskHash = UInt256.Zero; - private const int MaxConncurrentTasks = 3; + private const int MaxConcurrentTasks = 3; private readonly NeoSystem system; /// @@ -278,7 +278,7 @@ private bool IncrementGlobalTask(UInt256 hash) globalInvTasks[hash] = 1; return true; } - if (value >= MaxConncurrentTasks) + if (value >= MaxConcurrentTasks) return false; globalInvTasks[hash] = value + 1; @@ -293,7 +293,7 @@ private bool IncrementGlobalTask(uint index) globalIndexTasks[index] = 1; return true; } - if (value >= MaxConncurrentTasks) + if (value >= MaxConcurrentTasks) return false; globalIndexTasks[index] = value + 1; @@ -379,9 +379,10 @@ private void RequestTasks(IActorRef remoteNode, TaskSession session) uint currentHeight = Math.Max(NativeContract.Ledger.CurrentIndex(snapshot), lastSeenPersistedIndex); uint headerHeight = system.HeaderCache.Last?.Index ?? currentHeight; - // When the number of AvailableTasks is no more than 0, no pending tasks of InventoryType.Block, it should process pending the tasks of headers + // When the number of AvailableTasks is no more than 0, + // no pending tasks of InventoryType.Block, it should process pending the tasks of headers // If not HeaderTask pending to be processed it should ask for more Blocks - if ((!HasHeaderTask || globalInvTasks[HeaderTaskHash] < MaxConncurrentTasks) && headerHeight < session.LastBlockIndex && !system.HeaderCache.Full) + if ((!HasHeaderTask || globalInvTasks[HeaderTaskHash] < MaxConcurrentTasks) && headerHeight < session.LastBlockIndex && !system.HeaderCache.Full) { session.InvTasks[HeaderTaskHash] = DateTime.UtcNow; IncrementGlobalTask(HeaderTaskHash); diff --git a/src/neo/Plugins/Plugin.cs b/src/neo/Plugins/Plugin.cs index c5f348fb71..fa8818d8ec 100644 --- a/src/neo/Plugins/Plugin.cs +++ b/src/neo/Plugins/Plugin.cs @@ -19,7 +19,8 @@ namespace Neo.Plugins { /// - /// Represents the base class of all plugins. Any plugin should inherit this class. The plugins are automatically loaded when the process starts. + /// Represents the base class of all plugins. Any plugin should inherit this class. + /// The plugins are automatically loaded when the process starts. /// public abstract class Plugin : IDisposable { @@ -89,7 +90,8 @@ protected Plugin() } /// - /// Called when the plugin is loaded and need to load the configure file, or the configuration file has been modified and needs to be reconfigured. + /// Called when the plugin is loaded and need to load the configure file, + /// or the configuration file has been modified and needs to be reconfigured. /// protected virtual void Configure() { @@ -211,7 +213,7 @@ protected void Log(object message, LogLevel level = LogLevel.Info) } /// - /// Called when a message to the plugins is received. The messnage is sent by calling . + /// Called when a message to the plugins is received. The message is sent by calling . /// /// The received message. /// if the has been handled; otherwise, . diff --git a/src/neo/SmartContract/ContractParametersContext.cs b/src/neo/SmartContract/ContractParametersContext.cs index 0618943b63..643c655a7e 100644 --- a/src/neo/SmartContract/ContractParametersContext.cs +++ b/src/neo/SmartContract/ContractParametersContext.cs @@ -193,7 +193,7 @@ public bool AddSignature(Contract contract, ECPoint pubkey, byte[] signature) if (index == -1) { - // unable to find ContractParameterType.Signature in contract.ParameterList + // unable to find ContractParameterType.Signature in contract.ParameterList // return now to prevent array index out of bounds exception return false; } diff --git a/src/neo/SmartContract/Manifest/ContractPermission.cs b/src/neo/SmartContract/Manifest/ContractPermission.cs index 035e15beb3..c0aa1b2eaf 100644 --- a/src/neo/SmartContract/Manifest/ContractPermission.cs +++ b/src/neo/SmartContract/Manifest/ContractPermission.cs @@ -19,21 +19,26 @@ namespace Neo.SmartContract.Manifest { /// - /// Represents a permission of a contract. It describes which contracts may be invoked and which methods are called. - /// If a contract invokes a contract or method that is not declared in the manifest at runtime, the invocation will fail. + /// Represents a permission of a contract. It describes which contracts may be + /// invoked and which methods are called. + /// If a contract invokes a contract or method that is not declared in the manifest + /// at runtime, the invocation will fail. /// public class ContractPermission : IInteroperable { /// /// Indicates which contract to be invoked. /// It can be a hash of a contract, a public key of a group, or a wildcard *. - /// If it specifies a hash of a contract, then the contract will be invoked; If it specifies a public key of a group, then any contract in this group may be invoked; If it specifies a wildcard *, then any contract may be invoked. + /// If it specifies a hash of a contract, then the contract will be invoked; + /// If it specifies a public key of a group, then any contract in this group + /// may be invoked; If it specifies a wildcard *, then any contract may be invoked. /// public ContractPermissionDescriptor Contract { get; set; } /// /// Indicates which methods to be called. - /// It can also be assigned with a wildcard *. If it is a wildcard *, then it means that any method can be called. + /// It can also be assigned with a wildcard *. If it is a wildcard *, + /// then it means that any method can be called. /// public WildcardContainer Methods { get; set; } diff --git a/src/neo/Wallets/Wallet.cs b/src/neo/Wallets/Wallet.cs index ff6babd738..33076b7b36 100644 --- a/src/neo/Wallets/Wallet.cs +++ b/src/neo/Wallets/Wallet.cs @@ -455,9 +455,9 @@ public virtual WalletAccount Import(string nep2, string passphrase, int N = 1638 /// The snapshot used to read data. /// The array of that contain the asset, amount, and targets of the transfer. /// The account to transfer from. - /// The cosigners to be added to the transction. + /// The cosigners to be added to the transaction. /// The block environment to execute the transaction. If null, will be used. - /// The created transction. + /// The created transaction. public Transaction MakeTransaction(DataCache snapshot, TransferOutput[] outputs, UInt160 from = null, Signer[] cosigners = null, Block persistingBlock = null) { UInt160[] accounts; @@ -530,11 +530,11 @@ public Transaction MakeTransaction(DataCache snapshot, TransferOutput[] outputs, /// The snapshot used to read data. /// The script to be loaded in the transaction. /// The sender of the transaction. - /// The cosigners to be added to the transction. - /// The attributes to be added to the transction. + /// The cosigners to be added to the transaction. + /// The attributes to be added to the transaction. /// The maximum gas that can be spent to execute the script. /// The block environment to execute the transaction. If null, will be used. - /// The created transction. + /// The created transaction. public Transaction MakeTransaction(DataCache snapshot, ReadOnlyMemory script, UInt160 sender = null, Signer[] cosigners = null, TransactionAttribute[] attributes = null, long maxGas = ApplicationEngine.TestModeGas, Block persistingBlock = null) { UInt160[] accounts; @@ -565,7 +565,7 @@ private Transaction MakeTransaction(DataCache snapshot, ReadOnlyMemory scr Attributes = attributes, }; - // will try to execute 'transfer' script to check if it works + // will try to execute 'transfer' script to check if it works using (ApplicationEngine engine = ApplicationEngine.Run(script, snapshot.CreateSnapshot(), tx, settings: ProtocolSettings, gas: maxGas, persistingBlock: persistingBlock)) { if (engine.State == VMState.FAULT)