-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3789 from greymistcube/refactor/deprecate-pow-eva…
…luation 💥 Deprecate PoW evaluation
- Loading branch information
Showing
12 changed files
with
378 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Libplanet.Action.Tests/BlockProtocolVersionNotSupportedExceptionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Runtime.Serialization.Formatters.Binary; | ||
using Xunit; | ||
|
||
namespace Libplanet.Action.Tests | ||
{ | ||
public class BlockProtocolVersionNotSupportedExceptionTest | ||
{ | ||
[Fact] | ||
public void Serializable() | ||
{ | ||
var exc = new BlockProtocolVersionNotSupportedException("Foo", 5); | ||
|
||
var formatter = new BinaryFormatter(); | ||
using (var ms = new MemoryStream()) | ||
{ | ||
formatter.Serialize(ms, exc); | ||
|
||
ms.Seek(0, SeekOrigin.Begin); | ||
var deserialized = Assert.IsType<BlockProtocolVersionNotSupportedException>( | ||
formatter.Deserialize(ms)); | ||
Assert.Equal("Foo", deserialized.Message); | ||
Assert.Equal(5, deserialized.BlockProtocolVersion); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Libplanet.Action/BlockProtocolVersionNotSupportedException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
using Libplanet.Types.Blocks; | ||
|
||
namespace Libplanet.Action | ||
{ | ||
/// <summary> | ||
/// The exception that is thrown when an <see cref="IPreEvaluationBlock"/> with | ||
/// a protocol version that is not supported by an implementation of | ||
/// <see cref="IActionEvaluator"/> is passed as an argument to | ||
/// <see cref="IActionEvaluator.Evaluate"/>. | ||
/// </summary> | ||
[Serializable] | ||
public sealed class BlockProtocolVersionNotSupportedException : Exception | ||
{ | ||
/// <summary> | ||
/// Creates a new <see cref="BlockProtocolVersionNotSupportedException"/> object. | ||
/// </summary> | ||
/// <param name="message">Specifies a <see cref="Exception.Message"/>.</param> | ||
/// <param name="blockProtocolVersion">The <see cref="Block.ProtocolVersion"/> of the | ||
/// <see cref="Block"/> that <paramref name="action"/> belongs to.</param> | ||
public BlockProtocolVersionNotSupportedException( | ||
string message, | ||
int blockProtocolVersion) | ||
: base(message) | ||
{ | ||
BlockProtocolVersion = blockProtocolVersion; | ||
} | ||
|
||
private BlockProtocolVersionNotSupportedException( | ||
SerializationInfo info, | ||
StreamingContext context) | ||
: base(info, context) | ||
{ | ||
BlockProtocolVersion = (int)info.GetValue( | ||
nameof(BlockProtocolVersion), | ||
typeof(int))!; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="Block.ProtocolVersion"/> of the <see cref="Block"/> that is | ||
/// not supported by an implementation of <see cref="IActionEvaluator"/>. | ||
/// </summary> | ||
public int BlockProtocolVersion { get; } | ||
|
||
public override void GetObjectData(SerializationInfo info, StreamingContext context) | ||
{ | ||
base.GetObjectData(info, context); | ||
info.AddValue(nameof(BlockProtocolVersion), BlockProtocolVersion, typeof(int)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.