Skip to content

Commit

Permalink
Merge branch 'master' into fix/leveldb-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cschuchardt88 authored Jan 9, 2025
2 parents 2da130d + 070d06a commit 18af18b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/Neo.CLI/CLI/CommandLineOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class CommandLineOptions
public string[]? Plugins { get; set; }
public string? DBEngine { get; init; }
public string? DBPath { get; init; }
public LogLevel Verbose { get; init; } = LogLevel.Info;
public bool? NoVerify { get; init; }

/// <summary>
Expand Down
15 changes: 8 additions & 7 deletions src/Neo.CLI/CLI/MainService.CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ public int OnStartWithCommandLine(string[] args)
{
RootCommand rootCommand = new(Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyTitleAttribute>()!.Title)
{
new Option<string>(new[] { "-c", "--config","/config" }, "Specifies the config file."),
new Option<string>(new[] { "-w", "--wallet","/wallet" }, "The path of the neo3 wallet [*.json]."),
new Option<string>(new[] { "-p", "--password" ,"/password" }, "Password to decrypt the wallet, either from the command line or config file."),
new Option<string>(new[] { "--db-engine","/db-engine" }, "Specify the db engine."),
new Option<string>(new[] { "--db-path","/db-path" }, "Specify the db path."),
new Option<string>(new[] { "--noverify","/noverify" }, "Indicates whether the blocks need to be verified when importing."),
new Option<string[]>(new[] { "--plugins","/plugins" }, "The list of plugins, if not present, will be installed [plugin1 plugin2]."),
new Option<string>(["-c", "--config","/config"], "Specifies the config file."),
new Option<string>(["-w", "--wallet","/wallet"], "The path of the neo3 wallet [*.json]."),
new Option<string>(["-p", "--password" ,"/password"], "Password to decrypt the wallet, either from the command line or config file."),
new Option<string>(["--db-engine","/db-engine"], "Specify the db engine."),
new Option<string>(["--db-path","/db-path"], "Specify the db path."),
new Option<string>(["--noverify","/noverify"], "Indicates whether the blocks need to be verified when importing."),
new Option<string[]>(["--plugins","/plugins"], "The list of plugins, if not present, will be installed [plugin1 plugin2]."),
new Option<LogLevel>(["--verbose","/verbose"], "The verbose log level, if not present, will be info."),
};

rootCommand.Handler = CommandHandler.Create<RootCommand, CommandLineOptions, InvocationContext>(Handle);
Expand Down
2 changes: 1 addition & 1 deletion src/Neo.CLI/CLI/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Neo.ConsoleService;
using Neo.Cryptography.ECC;
using Neo.Extensions;
using Neo.IO;
using Neo.Json;
using Neo.Ledger;
using Neo.Network.P2P;
Expand Down Expand Up @@ -373,6 +372,7 @@ public async void Start(CommandLineOptions options)
if (NeoSystem != null) return;
bool verifyImport = !(options.NoVerify ?? false);

Utility.LogLevel = options.Verbose;
ProtocolSettings protocol = ProtocolSettings.Load("config.json");
CustomProtocolSettings(options, protocol);
CustomApplicationSettings(options, Settings.Default);
Expand Down
4 changes: 4 additions & 0 deletions src/Neo.Extensions/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public Logger()
}
}

public static LogLevel LogLevel { get; set; } = LogLevel.Info;

public static event LogEventHandler? Logging;

/// <summary>
Expand All @@ -53,6 +55,8 @@ static Utility()
/// <param name="message">The message of the log.</param>
public static void Log(string source, LogLevel level, object message)
{
if ((int)level < (int)LogLevel) return;

Logging?.Invoke(source, level, message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Neo/SmartContract/ApplicationEngine.Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ internal protected UInt160 CreateStandardAccount(ECPoint pubKey)
/// The implementation of System.Contract.CreateMultisigAccount.
/// Calculates corresponding multisig account scripthash for the given public keys.
/// </summary>
/// <param name="m">The minimum number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="m">The number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="pubKeys">The public keys of the account.</param>
/// <returns>The hash of the account.</returns>
internal protected UInt160 CreateMultisigAccount(int m, ECPoint[] pubKeys)
Expand Down
4 changes: 2 additions & 2 deletions src/Neo/SmartContract/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static Contract Create(UInt160 scriptHash, params ContractParameterType[]
/// <summary>
/// Creates a multi-sig contract.
/// </summary>
/// <param name="m">The minimum number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="m">The number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="publicKeys">The public keys of the contract.</param>
/// <returns>The created contract.</returns>
public static Contract CreateMultiSigContract(int m, IReadOnlyCollection<ECPoint> publicKeys)
Expand All @@ -97,7 +97,7 @@ public static Contract CreateMultiSigContract(int m, IReadOnlyCollection<ECPoint
/// <summary>
/// Creates the script of multi-sig contract.
/// </summary>
/// <param name="m">The minimum number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="m">The number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="publicKeys">The public keys of the contract.</param>
/// <returns>The created script.</returns>
public static byte[] CreateMultiSigRedeemScript(int m, IReadOnlyCollection<ECPoint> publicKeys)
Expand Down
6 changes: 3 additions & 3 deletions src/Neo/SmartContract/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static long SignatureContractCost() =>
/// Calculates the verification fee for a multi-signature address.
/// In the unit of datoshi, 1 datoshi = 1e-8 GAS
/// </summary>
/// <param name="m">The minimum number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="m">The number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="n">The number of public keys in the account.</param>
/// <returns>The calculated cost.</returns>
public static long MultiSignatureContractCost(int m, int n)
Expand Down Expand Up @@ -131,7 +131,7 @@ public static bool IsMultiSigContract(ReadOnlySpan<byte> script)
/// Determines whether the specified contract is a multi-signature contract.
/// </summary>
/// <param name="script">The script of the contract.</param>
/// <param name="m">The minimum number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="m">The number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="n">The number of public keys in the account.</param>
/// <returns><see langword="true"/> if the contract is a multi-signature contract; otherwise, <see langword="false"/>.</returns>
public static bool IsMultiSigContract(ReadOnlySpan<byte> script, out int m, out int n)
Expand All @@ -143,7 +143,7 @@ public static bool IsMultiSigContract(ReadOnlySpan<byte> script, out int m, out
/// Determines whether the specified contract is a multi-signature contract.
/// </summary>
/// <param name="script">The script of the contract.</param>
/// <param name="m">The minimum number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="m">The number of correct signatures that need to be provided in order for the verification to pass.</param>
/// <param name="points">The public keys in the account.</param>
/// <returns><see langword="true"/> if the contract is a multi-signature contract; otherwise, <see langword="false"/>.</returns>
public static bool IsMultiSigContract(ReadOnlySpan<byte> script, out int m, out ECPoint[] points)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

namespace Neo.Cryptography.MPTTrie.Tests
{

[TestClass]
public class UT_Node
{
Expand All @@ -34,6 +33,20 @@ private byte[] NodeToArrayAsChild(Node n)
return ms.ToArray();
}

[TestMethod]
public void TestLogLevel()
{
Neo.Utility.LogLevel = LogLevel.Debug;
int raised = 0;
Neo.Utility.Logging += (a, b, c) => raised++;

Neo.Utility.Log("a", LogLevel.Warning, null);
Assert.AreEqual(1, raised);
Neo.Utility.LogLevel = LogLevel.Fatal;
Neo.Utility.Log("a", LogLevel.Warning, null);
Assert.AreEqual(1, raised);
}

[TestMethod]
public void TestHashSerialize()
{
Expand Down

0 comments on commit 18af18b

Please sign in to comment.