Skip to content

Commit

Permalink
chore: remove deprecated serialization for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
limebell committed Jan 14, 2025
1 parent d552ef5 commit ceb29b1
Show file tree
Hide file tree
Showing 19 changed files with 10 additions and 334 deletions.
20 changes: 2 additions & 18 deletions src/Libplanet.Net/Consensus/InvalidConsensusMessageException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using Libplanet.Net.Messages;

namespace Libplanet.Net.Consensus
Expand All @@ -13,7 +12,7 @@ namespace Libplanet.Net.Consensus
public class InvalidConsensusMessageException : InvalidMessageContentException
{
/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidConsensusMessageException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -30,7 +29,7 @@ public InvalidConsensusMessageException(
}

/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidConsensusMessageException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -40,20 +39,5 @@ public InvalidConsensusMessageException(string message, MessageContent receivedM
: base(message, receivedMessage)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidConsensusMessageException"/>
/// class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">The <see cref="StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
protected InvalidConsensusMessageException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}
20 changes: 1 addition & 19 deletions src/Libplanet.Net/Consensus/InvalidHeightIncreasingException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using Libplanet.Blockchain;

namespace Libplanet.Net.Consensus
Expand All @@ -12,30 +11,13 @@ namespace Libplanet.Net.Consensus
public class InvalidHeightIncreasingException : Exception
{
/// <summary>
/// Initializes a new instance of <see cref="InvalidHeightIncreasingException"/> class.
/// Initializes a new instance of the <see cref="InvalidHeightIncreasingException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
public InvalidHeightIncreasingException(string message)
: base(message)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidHeightIncreasingException"/>
/// class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo" />
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">The <see cref="StreamingContext" />
/// that contains contextual information about the source or destination.
/// </param>
protected InvalidHeightIncreasingException(
SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
}
30 changes: 2 additions & 28 deletions src/Libplanet.Net/Consensus/InvalidMaj23Exception.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using Libplanet.Consensus;

namespace Libplanet.Net.Consensus
Expand All @@ -13,7 +12,7 @@ namespace Libplanet.Net.Consensus
public class InvalidMaj23Exception : Exception
{
/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidMaj23Exception"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -31,7 +30,7 @@ public InvalidMaj23Exception(
}

/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidMaj23Exception"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -43,31 +42,6 @@ public InvalidMaj23Exception(string message, Maj23 maj23)
Maj23 = maj23;
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidConsensusMessageException"/>
/// class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">The <see cref="StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
protected InvalidMaj23Exception(SerializationInfo info, StreamingContext context)
{
Maj23 =
info.GetValue(nameof(Maj23), typeof(Maj23)) as Maj23 ??
throw new SerializationException(
$"{nameof(Maj23)} is expected to be a non-null {nameof(Maj23)}.");
}

public Maj23 Maj23 { get; }

public override void GetObjectData(
SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(Maj23), Maj23);
}
}
}
30 changes: 2 additions & 28 deletions src/Libplanet.Net/Consensus/InvalidProposalException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using Libplanet.Consensus;

namespace Libplanet.Net.Consensus
Expand All @@ -13,7 +12,7 @@ namespace Libplanet.Net.Consensus
public class InvalidProposalException : Exception
{
/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidProposalException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -31,7 +30,7 @@ public InvalidProposalException(
}

/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidProposalException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -43,31 +42,6 @@ public InvalidProposalException(string message, Proposal proposal)
Proposal = proposal;
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidConsensusMessageException"/>
/// class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">The <see cref="StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
protected InvalidProposalException(SerializationInfo info, StreamingContext context)
{
Proposal =
info.GetValue(nameof(Proposal), typeof(Proposal)) as Proposal ??
throw new SerializationException(
$"{nameof(Proposal)} is expected to be a non-null {nameof(Proposal)}.");
}

public Proposal Proposal { get; }

public override void GetObjectData(
SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(Proposal), Proposal);
}
}
}
30 changes: 2 additions & 28 deletions src/Libplanet.Net/Consensus/InvalidVoteException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using Libplanet.Types.Consensus;

namespace Libplanet.Net.Consensus
Expand All @@ -13,7 +12,7 @@ namespace Libplanet.Net.Consensus
public class InvalidVoteException : Exception
{
/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidVoteException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -31,7 +30,7 @@ public InvalidVoteException(
}

/// <summary>
/// Initializes a new instance of <see cref="InvalidConsensusMessageException"/> class.
/// Initializes a new instance of the <see cref="InvalidVoteException"/> class.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception.
/// </param>
Expand All @@ -43,31 +42,6 @@ public InvalidVoteException(string message, Vote vote)
Vote = vote;
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidConsensusMessageException"/>
/// class with serialized data.
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/>
/// that holds the serialized object data about the exception being thrown.
/// </param>
/// <param name="context">The <see cref="StreamingContext"/>
/// that contains contextual information about the source or destination.
/// </param>
protected InvalidVoteException(SerializationInfo info, StreamingContext context)
{
Vote =
info.GetValue(nameof(Vote), typeof(Vote)) as Vote ??
throw new SerializationException(
$"{nameof(Vote)} is expected to be a non-null {nameof(Vote)}.");
}

public Vote Vote { get; }

public override void GetObjectData(
SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(Vote), Vote);
}
}
}
20 changes: 0 additions & 20 deletions src/Libplanet.Net/InvalidMessageContentException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;
using Libplanet.Net.Messages;

namespace Libplanet.Net
Expand All @@ -23,25 +22,6 @@ internal InvalidMessageContentException(string message, MessageContent content)
Content = content;
}

protected InvalidMessageContentException(
SerializationInfo info,
StreamingContext context
)
: base(info, context)
{
Content =
info.GetValue(nameof(Content), typeof(MessageContent)) as MessageContent ??
throw new SerializationException(
$"{nameof(Content)} is expected to be a non-null {nameof(Message)}.");
}

internal MessageContent Content { get; }

public override void GetObjectData(
SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue(nameof(Content), Content);
}
}
}
6 changes: 0 additions & 6 deletions src/Libplanet.Net/InvalidStateTargetException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Libplanet.Net
{
Expand All @@ -19,10 +18,5 @@ public InvalidStateTargetException(string message, Exception innerException)
: base(message, innerException)
{
}

protected InvalidStateTargetException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions src/Libplanet.Net/NoSwarmContextException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Libplanet.Net
{
Expand All @@ -19,13 +18,5 @@ public NoSwarmContextException(string message, Exception innerException)
: base(message, innerException)
{
}

protected NoSwarmContextException(
SerializationInfo info,
StreamingContext context
)
: base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions src/Libplanet.Net/PeerNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Libplanet.Net
{
Expand All @@ -19,13 +18,5 @@ public PeerNotFoundException(string message, Exception innerException)
: base(message, innerException)
{
}

protected PeerNotFoundException(
SerializationInfo info,
StreamingContext context
)
: base(info, context)
{
}
}
}
9 changes: 0 additions & 9 deletions src/Libplanet.Net/Protocols/PeerDiscoveryException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Libplanet.Net.Protocols
{
Expand All @@ -18,13 +17,5 @@ public PeerDiscoveryException(string message, Exception innerException)
: base(message, innerException)
{
}

protected PeerDiscoveryException(
SerializationInfo info,
StreamingContext context
)
: base(info, context)
{
}
}
}
22 changes: 0 additions & 22 deletions src/Libplanet.Net/Protocols/PingTimeoutException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Libplanet.Net.Protocols
{
Expand All @@ -24,27 +23,6 @@ public PingTimeoutException(string message, BoundPeer target, Exception innerExc
Target = target;
}

protected PingTimeoutException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Target = info.GetValue(nameof(Target), typeof(BoundPeer)) is BoundPeer target
? target
: throw new SerializationException(
$"{nameof(Target)} is expected to be a non-null {nameof(BoundPeer)}.");
}

public BoundPeer Target { get; private set; }

public override void GetObjectData(
SerializationInfo info, StreamingContext context)
{
if (info is null)
{
throw new System.ArgumentNullException(nameof(info));
}

base.GetObjectData(info, context);
info.AddValue(nameof(Target), Target);
}
}
}
Loading

2 comments on commit ceb29b1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Benchmark.Net Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: ceb29b1 Previous: 99d7426 Ratio
Libplanet.Benchmarks.AppendBlock.AppendBlockOneTransactionNoAction 2163773.5 ns (± 1110751.3986843422) 979776.6428571428 ns (± 46982.44994487537) 2.21

This comment was automatically generated by workflow using github-action-benchmark.

CC: @libplanet

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Benchmark.Net Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: ceb29b1 Previous: 99d7426 Ratio
Libplanet.Benchmarks.AppendBlock.AppendBlockOneTransactionNoAction 2975507.6923076925 ns (± 21856.214277959996) 928882.9896907216 ns (± 71949.58987844877) 3.20
Libplanet.Benchmarks.AppendBlock.AppendBlockOneTransactionWithActions 3212122 ns (± 1439207.4186351825) 1421194.4444444445 ns (± 76898.47876391798) 2.26

This comment was automatically generated by workflow using github-action-benchmark.

CC: @libplanet

Please sign in to comment.