diff --git a/src/Neo/Ledger/Blockchain.cs b/src/Neo/Ledger/Blockchain.cs index 830aff738b..c12186d646 100644 --- a/src/Neo/Ledger/Blockchain.cs +++ b/src/Neo/Ledger/Blockchain.cs @@ -542,7 +542,8 @@ private static void InvokeHandlers(Delegate[] handlers, Action handler } catch (Exception ex) when (handler.Target is Plugin plugin) { - Utility.Log(nameof(plugin.Name), LogLevel.Error, $"{plugin.Name} exception: {ex.Message}{Environment.NewLine}{ex.StackTrace}"); + var cause = ex.InnerException ?? ex; + Utility.Log(nameof(plugin.Name), LogLevel.Error, $"{plugin.Name} exception: {cause.Message}{Environment.NewLine}{cause.StackTrace}"); switch (plugin.ExceptionPolicy) { case UnhandledExceptionPolicy.StopNode: diff --git a/src/Neo/Network/P2P/Peer.cs b/src/Neo/Network/P2P/Peer.cs index 133d54cce0..5c52e6c809 100644 --- a/src/Neo/Network/P2P/Peer.cs +++ b/src/Neo/Network/P2P/Peer.cs @@ -12,7 +12,6 @@ using Akka.Actor; using Akka.IO; using Neo.Extensions; -using Neo.Extensions.Factories; using System; using System.Buffers.Binary; using System.Collections.Concurrent; @@ -201,6 +200,11 @@ protected override void OnReceive(object message) ConnectToPeer(connect.EndPoint, connect.IsTrusted); break; case Tcp.Connected connected: + if (connected.RemoteAddress is null) + { + Sender.Tell(Tcp.Abort.Instance); + break; + } OnTcpConnected(((IPEndPoint)connected.RemoteAddress).UnMap(), ((IPEndPoint)connected.LocalAddress).UnMap()); break; case Tcp.Bound _: @@ -249,6 +253,12 @@ private void OnStart(ChannelsConfig config) /// The local endpoint of TCP connection. private void OnTcpConnected(IPEndPoint remote, IPEndPoint local) { + if (Config is null) // OnStart is not called yet + { + Sender.Tell(Tcp.Abort.Instance); + return; + } + ImmutableInterlocked.Update(ref ConnectingPeers, p => p.Remove(remote)); if (Config.MaxConnections != -1 && ConnectedPeers.Count >= Config.MaxConnections && !TrustedIpAddresses.Contains(remote.Address)) {