Skip to content

Commit

Permalink
Peer docs
Browse files Browse the repository at this point in the history
  • Loading branch information
earlbread committed Apr 9, 2019
1 parent a3e367a commit 6774236
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Libplanet/Net/Peer.cs
Expand Up @@ -8,10 +8,23 @@

namespace Libplanet.Net
{
/// <summary>
/// A representation of peer node.
/// </summary>
/// <seealso cref="Swarm"/>
[Serializable]
[GeneratedEquality]
public partial class Peer : ISerializable
{
/// <summary>
/// Initializes a new instance of the <see cref="Peer"/> class.
/// <param name="publicKey">A <see cref="PublicKey"/> of the
/// <see cref="Peer"/>.</param>
/// <param name="endPoint">A <see cref="DnsEndPoint"/> consisting of the
/// host and port of the <see cref="Peer"/>.</param>
/// <param name="appProtocolVersion">A application protocol version that
/// the <see cref="Peer"/> is using.</param>
/// </summary>
public Peer(
PublicKey publicKey, DnsEndPoint endPoint, int appProtocolVersion)
{
Expand All @@ -38,20 +51,32 @@ protected Peer(SerializationInfo info, StreamingContext context)
AppProtocolVersion = info.GetInt32("app_protocol_version");
}

/// <summary>
/// The corresponding <see cref="Libplanet.Crypto.PublicKey"/> of
/// this peer.
/// </summary>
[EqualityKey]
[Pure]
public PublicKey PublicKey { get; }

/// <summary>
/// The corresponding <see cref="DnsEndPoint"/> of this peer.
/// </summary>
[EqualityKey]
[Pure]
public DnsEndPoint EndPoint { get; }

/// <summary>
/// The corresponding application protocol version of this peer.
/// </summary>
/// <seealso cref="Swarm.DifferentVersionPeerEncountered"/>
[Pure]
public int AppProtocolVersion { get; }

[Pure]
public Address Address => new Address(PublicKey);

/// <inheritdoc/>
public void GetObjectData(
SerializationInfo info,
StreamingContext context
Expand All @@ -63,6 +88,7 @@ StreamingContext context
info.AddValue("app_protocol_version", AppProtocolVersion);
}

/// <inheritdoc/>
public override string ToString()
{
return $"{Address}.{EndPoint}.{AppProtocolVersion}";
Expand Down

0 comments on commit 6774236

Please sign in to comment.