Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 604 #726

Merged
merged 3 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ To be released.
- Added `InvalidGenesisBlockException` class. [[#688]]
- Added `StateDownloadState` class which reports state preloading iteration
progress. [[#703]]
- Added `PeerDiscoveryException` class which inherits `SwarmException`
class. [[#604], [#726]]

### Behavioral changes

Expand All @@ -76,6 +78,8 @@ To be released.
[[#706]]
- Increased `Swarm<T>`'s network timeout value, in order to be stable
a high latency internet connection. [[#709]]
- `Swarm<T>.BootstrapAsync()` became to report `PeerDiscoveryException`
instead of `SwarmException` directly. [[#604], [#726]]

### Bug fixes

Expand All @@ -92,6 +96,7 @@ To be released.
nonce. [[#718]]
- Fixed a bug where mined transactions were staged again. [[#719]]

[#604]: https://github.com/planetarium/libplanet/issues/604
[#613]: https://github.com/planetarium/libplanet/issues/613
[#662]: https://github.com/planetarium/libplanet/pull/662
[#665]: https://github.com/planetarium/libplanet/pull/665
Expand All @@ -112,6 +117,7 @@ To be released.
[#718]: https://github.com/planetarium/libplanet/pull/718
[#719]: https://github.com/planetarium/libplanet/pull/719
[#725]: https://github.com/planetarium/libplanet/pull/725
[#726]: https://github.com/planetarium/libplanet/pull/726
[#727]: https://github.com/planetarium/libplanet/pull/727


Expand Down
5 changes: 3 additions & 2 deletions Libplanet.Tests/Net/SwarmTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Libplanet.Crypto;
using Libplanet.Net;
using Libplanet.Net.Messages;
using Libplanet.Net.Protocols;
using Libplanet.Store;
using Libplanet.Tests.Blockchain;
using Libplanet.Tests.Common.Action;
Expand Down Expand Up @@ -334,7 +335,7 @@ public async Task BootstrapException()

try
{
await Assert.ThrowsAsync<SwarmException>(
await Assert.ThrowsAsync<PeerDiscoveryException>(
() => swarmB.BootstrapAsync(new[] { swarmA.AsPeer }, 3000, 3000));

await StartAsync(swarmA);
Expand Down Expand Up @@ -530,7 +531,7 @@ void GameHandler(object sender, DifferentProtocolVersionEventArgs e)
{
await StartAsync(b);

await Assert.ThrowsAsync<SwarmException>(() => BootstrapAsync(a, b.AsPeer));
await Assert.ThrowsAsync<PeerDiscoveryException>(() => BootstrapAsync(a, b.AsPeer));

Assert.True(isCalled);
}
Expand Down
5 changes: 2 additions & 3 deletions Libplanet/Net/Protocols/KademliaProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ public async Task BootstrapAsync(

if (!_routing.Peers.Any())
{
// FIXME: Need more precise exception
throw new SwarmException("No seed available.");
throw new PeerDiscoveryException("All seeds are unreachable.");
}

if (findPeerTasks.Count == 0)
{
throw new SwarmException("Bootstrap failed.");
throw new PeerDiscoveryException("Bootstrap failed.");
}

try
Expand Down
30 changes: 30 additions & 0 deletions Libplanet/Net/Protocols/PeerDiscoveryException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Runtime.Serialization;

namespace Libplanet.Net.Protocols
{
public class PeerDiscoveryException : SwarmException
{
public PeerDiscoveryException()
{
}

public PeerDiscoveryException(string message)
: base(message)
{
}

public PeerDiscoveryException(string message, Exception innerException)
: base(message, innerException)
{
}

protected PeerDiscoveryException(
SerializationInfo info,
StreamingContext context
)
: base(info, context)
{
}
}
}