private void AttachedNode_StateChanged(Node node, NodeState oldState) { this.logger.LogTrace("({0}:'{1}',{2}:{3},{4}:{5})", nameof(node), node.RemoteSocketEndpoint, nameof(oldState), oldState, nameof(node.State), node.State); if (node.State == NodeState.HandShaked) { this.ConnectionManager.AddConnectedNode(node); this.infoLogger.LogInformation("Node {0} connected ({1}), agent {2}, height {3}", node.RemoteSocketEndpoint, this.Inbound ? "inbound" : "outbound", node.PeerVersion.UserAgent, node.PeerVersion.StartHeight); node.SendMessageAsync(new SendHeadersPayload()); } if ((node.State == NodeState.Failed) || (node.State == NodeState.Offline)) { this.infoLogger.LogInformation("Node {0} offline.", node.RemoteSocketEndpoint); NodeDisconnectReason reason = node.DisconnectReason; if ((reason != null) && !string.IsNullOrEmpty(reason.Reason)) { this.infoLogger.LogInformation("Reason: {0}", reason.Reason); } this.ConnectionManager.RemoveConnectedNode(node); } this.logger.LogTrace("(-)"); }
private string ToString(NodeDisconnectReason reason) { if (reason == null) { return(null); } return(reason.Reason + " " + reason.Exception == null ? "" : Utils.ExceptionToString(reason.Exception)); }