Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct typos, comments #2785

Merged
merged 10 commits into from
Jul 10, 2022
6 changes: 4 additions & 2 deletions src/neo/Cryptography/Base58.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public static byte[] Base58CheckDecode(this string input)
}

/// <summary>
/// Converts a byte array to its equivalent <see cref="string"/> representation that is encoded with base-58 digits. The encoded <see cref="string"/> contains the checksum of the binary data.
/// Converts a byte array to its equivalent <see cref="string"/>
/// representation that is encoded with base-58 digits.
/// The encoded <see cref="string"/> contains the checksum of the binary data.
/// </summary>
/// <param name="data">The byte array to convert.</param>
/// <returns>The <see cref="string"/> representation, in base-58, of the contents of <paramref name="data"/>.</returns>
Expand All @@ -67,7 +69,7 @@ public static string Base58CheckEncode(this ReadOnlySpan<byte> data)
/// <returns>A byte array that is equivalent to <paramref name="input"/>.</returns>
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++)
{
Expand Down
10 changes: 5 additions & 5 deletions src/neo/Cryptography/ECC/ECPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -282,23 +282,23 @@ 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 };
ECPoint twiceP = p.Twice();

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];
Array.Copy(oldPreComp, 0, preComp, 0, preCompLen);

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];
Expand Down
4 changes: 2 additions & 2 deletions src/neo/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static ulong ToTimestampMS(this DateTime time)
}

/// <summary>
/// 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.
/// </summary>
internal static IPAddress Unmap(this IPAddress address)
Expand All @@ -299,7 +299,7 @@ internal static IPAddress Unmap(this IPAddress address)
}

/// <summary>
/// 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.
/// </summary>
internal static IPEndPoint Unmap(this IPEndPoint endPoint)
Expand Down
8 changes: 4 additions & 4 deletions src/neo/IO/ByteArrayEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 6 additions & 6 deletions src/neo/IO/Caching/HashSetCache.cs
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -18,12 +18,12 @@ class HashSetCache<T> : IReadOnlyCollection<T> where T : IEquatable<T>
{
/// <summary>
/// Sets where the Hashes are stored
/// </summary>
/// </summary>
private readonly LinkedList<HashSet<T>> sets = new();

/// <summary>
/// Maximum capacity of each bucket inside each HashSet of <see cref="sets"/>.
/// </summary>
/// </summary>
private readonly int bucketCapacity;

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/neo/IO/Caching/IndexedQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public void Enqueue(T item)
}

/// <summary>
/// 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
/// </summary>
/// <returns>The frontmost item</returns>
/// <returns>The front most item</returns>
public T Peek()
{
if (_count == 0)
Expand Down Expand Up @@ -201,7 +201,7 @@ public void TrimExcess()
}

/// <summary>
/// Copys the queue's items to a destination array
/// Copy the queue's items to a destination array
/// </summary>
/// <param name="array">The destination array</param>
/// <param name="arrayIndex">The index in the destination to start copying at</param>
Expand Down
6 changes: 3 additions & 3 deletions src/neo/Ledger/MemoryPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public class MemoryPool : IReadOnlyCollection<Transaction>
public event EventHandler<Transaction> TransactionAdded;
public event EventHandler<TransactionRemovedEventArgs> 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;
Expand All @@ -55,7 +55,7 @@ public class MemoryPool : IReadOnlyCollection<Transaction>
/// </summary>
private readonly Dictionary<UInt256, PoolItem> _unsortedTransactions = new();
/// <summary>
/// Stores the verified sorted transactins currently in the pool.
/// Stores the verified sorted transactions currently in the pool.
/// </summary>
private readonly SortedSet<PoolItem> _sortedTransactions = new();

Expand Down
7 changes: 3 additions & 4 deletions src/neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -194,15 +194,14 @@ public T GetService<T>(Func<T, bool> filter = null)
IEnumerable<T> result = services.OfType<T>();
if (filter is null)
return result.FirstOrDefault();
else
return result.FirstOrDefault(filter);
return result.FirstOrDefault(filter);
}

/// <summary>
/// Blocks the current thread until the specified actor has stopped.
/// </summary>
/// <param name="actor">The actor to wait.</param>
public void EnsureStoped(IActorRef actor)
public void EnsureStopped(IActorRef actor)
{
using Inbox inbox = Inbox.Create(ActorSystem);
inbox.Watch(actor);
Expand Down
14 changes: 9 additions & 5 deletions src/neo/Network/P2P/LocalNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private void BroadcastMessage(MessageCommand command, ISerializable payload = nu
/// <summary>
/// Broadcast a message to all connected nodes.
/// </summary>
/// <param name="message">The message to be broadcasted.</param>
/// <param name="message">The message to be broadcast.</param>
private void BroadcastMessage(Message message) => SendToRemoteNodes(message);

/// <summary>
Expand Down Expand Up @@ -160,7 +160,8 @@ internal static IPEndPoint GetIpEndPoint(string hostAndPort)

/// <summary>
/// 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.
/// </summary>
/// <param name="actor">Remote node actor.</param>
/// <param name="node">Remote node object.</param>
Expand Down Expand Up @@ -200,8 +201,10 @@ public IEnumerable<IPEndPoint> GetUnconnectedPeers()
}

/// <summary>
/// Performs a broadcast with the command <see cref="MessageCommand.GetAddr"/>, which, eventually, tells all known connections.
/// If there are no connected peers it will try with the default, respecting <see cref="MaxCountFromSeedList"/> limit.
/// Performs a broadcast with the command <see cref="MessageCommand.GetAddr"/>,
/// which, eventually, tells all known connections.
/// If there are no connected peers it will try with the default,
/// respecting <see cref="MaxCountFromSeedList"/> limit.
/// </summary>
/// <param name="count">Number of peers that are being requested.</param>
protected override void NeedMorePeers(int count)
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/neo/Network/P2P/Payloads/Header.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion src/neo/Network/P2P/Payloads/PingPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public class PingPayload : ISerializable
public uint Timestamp;

/// <summary>
/// A random number. This number must be the same in <see cref="MessageCommand.Ping"/> and <see cref="MessageCommand.Pong"/> messages.
/// A random number. This number must be the same in
/// <see cref="MessageCommand.Ping"/> and <see cref="MessageCommand.Pong"/> messages.
/// </summary>
public uint Nonce;

Expand Down
11 changes: 7 additions & 4 deletions src/neo/Network/P2P/Payloads/Signer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ public class Signer : IInteroperable, ISerializable
public WitnessScope Scopes;

/// <summary>
/// The contracts that allowed by the witness. Only available when the <see cref="WitnessScope.CustomContracts"/> flag is set.
/// The contracts that allowed by the witness.
/// Only available when the <see cref="WitnessScope.CustomContracts"/> flag is set.
/// </summary>
public UInt160[] AllowedContracts;

/// <summary>
/// The groups that allowed by the witness. Only available when the <see cref="WitnessScope.CustomGroups"/> flag is set.
/// The groups that allowed by the witness.
/// Only available when the <see cref="WitnessScope.CustomGroups"/> flag is set.
/// </summary>
public ECPoint[] AllowedGroups;

/// <summary>
/// The rules that the witness must meet. Only available when the <see cref="WitnessScope.WitnessRules"/> flag is set.
/// The rules that the witness must meet.
/// Only available when the <see cref="WitnessScope.WitnessRules"/> flag is set.
/// </summary>
public WitnessRule[] Rules;

Expand Down Expand Up @@ -81,7 +84,7 @@ public void Deserialize(ref MemoryReader reader)
}

/// <summary>
/// Converts all rules contianed in the <see cref="Signer"/> object to <see cref="WitnessRule"/>.
/// Converts all rules contained in the <see cref="Signer"/> object to <see cref="WitnessRule"/>.
/// </summary>
/// <returns>The <see cref="WitnessRule"/> array used to represent the current signer.</returns>
public IEnumerable<WitnessRule> GetAllRules()
Expand Down
3 changes: 2 additions & 1 deletion src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ private void OnGetBlockByIndexMessageReceived(GetBlockByIndexPayload payload)
/// <summary>
/// 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.
/// </summary>
/// <param name="payload">The payload containing the requested information.</param>
private void OnGetDataMessageReceived(InvPayload payload)
Expand Down
11 changes: 6 additions & 5 deletions src/neo/Network/P2P/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/// <summary>
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions src/neo/Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace Neo.Plugins
{
/// <summary>
/// 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.
/// </summary>
public abstract class Plugin : IDisposable
{
Expand Down Expand Up @@ -89,7 +90,8 @@ protected Plugin()
}

/// <summary>
/// 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.
/// </summary>
protected virtual void Configure()
{
Expand Down Expand Up @@ -211,7 +213,7 @@ protected void Log(object message, LogLevel level = LogLevel.Info)
}

/// <summary>
/// Called when a message to the plugins is received. The messnage is sent by calling <see cref="SendMessage"/>.
/// Called when a message to the plugins is received. The message is sent by calling <see cref="SendMessage"/>.
/// </summary>
/// <param name="message">The received message.</param>
/// <returns><see langword="true"/> if the <paramref name="message"/> has been handled; otherwise, <see langword="false"/>.</returns>
Expand Down
2 changes: 1 addition & 1 deletion src/neo/SmartContract/ContractParametersContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading