Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Fix OnShowPoolCommand after Mempool changes (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
vncoelho authored and erikzhang committed Mar 6, 2019
1 parent 2efb245 commit a24cd2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
28 changes: 19 additions & 9 deletions neo-cli/Shell/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ECCurve = Neo.Cryptography.ECC.ECCurve;
using ECPoint = Neo.Cryptography.ECC.ECPoint;
Expand Down Expand Up @@ -495,7 +494,8 @@ private bool OnCreateWalletCommand(string[] args)
WalletAccount account = Program.Wallet.CreateAccount();
Console.WriteLine($"address: {account.Address}");
Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}");
system.RpcServer?.OpenWallet(Program.Wallet);
if (system.RpcServer != null)
system.RpcServer.Wallet = Program.Wallet;
}
break;
case ".json":
Expand All @@ -507,7 +507,8 @@ private bool OnCreateWalletCommand(string[] args)
Program.Wallet = wallet;
Console.WriteLine($"address: {account.Address}");
Console.WriteLine($" pubkey: {account.GetKey().PublicKey.EncodePoint(true).ToHexString()}");
system.RpcServer?.OpenWallet(Program.Wallet);
if (system.RpcServer != null)
system.RpcServer.Wallet = Program.Wallet;
}
break;
default:
Expand Down Expand Up @@ -863,7 +864,8 @@ private bool OnOpenWalletCommand(string[] args)
{
Console.WriteLine($"failed to open file \"{path}\"");
}
system.RpcServer?.OpenWallet(Program.Wallet);
if (system.RpcServer != null)
system.RpcServer.Wallet = Program.Wallet;
return true;
}

Expand Down Expand Up @@ -1000,11 +1002,19 @@ private bool OnShowCommand(string[] args)
private bool OnShowPoolCommand(string[] args)
{
bool verbose = args.Length >= 3 && args[2] == "verbose";
Transaction[] transactions = Blockchain.Singleton.GetMemoryPool().ToArray();
if (verbose)
foreach (Transaction tx in transactions)
Console.WriteLine($"{tx.Hash} {tx.GetType().Name}");
Console.WriteLine($"total: {transactions.Length}");
{
Blockchain.Singleton.MemPool.GetVerifiedAndUnverifiedTransactions(
out IEnumerable<Transaction> verifiedTransactions,
out IEnumerable<Transaction> unverifiedTransactions);
Console.WriteLine("Verified Transactions:");
foreach (Transaction tx in verifiedTransactions)
Console.WriteLine($" {tx.Hash} {tx.GetType().Name}");
Console.WriteLine("Unverified Transactions:");
foreach (Transaction tx in unverifiedTransactions)
Console.WriteLine($" {tx.Hash} {tx.GetType().Name}");
}
Console.WriteLine($"total: {Blockchain.Singleton.MemPool.Count}, verified: {Blockchain.Singleton.MemPool.VerifiedCount}, unverified: {Blockchain.Singleton.MemPool.UnVerifiedCount}");
return true;
}

Expand Down Expand Up @@ -1244,7 +1254,7 @@ private static Wallet OpenWallet(WalletIndexer indexer, string path, string pass
}
}

private static void WriteLineWithoutFlicker(string message = "", int maxWidth=80)
private static void WriteLineWithoutFlicker(string message = "", int maxWidth = 80)
{
if (message.Length > 0) Console.Write(message);
var spacesToErase = maxWidth - message.Length;
Expand Down
4 changes: 2 additions & 2 deletions neo-cli/neo-cli.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Copyright>2016-2019 The Neo Project</Copyright>
<AssemblyTitle>Neo.CLI</AssemblyTitle>
Expand Down Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="2.9.4" />
<PackageReference Include="Neo" Version="2.10.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.5.0" />
</ItemGroup>

Expand Down

0 comments on commit a24cd2d

Please sign in to comment.