-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Headers for forward declarations * Conversions for endpoint_key * Time helpers * Store timestamps in peer store * Introduce `peer_cache` * Tests for peer cache * Reach out to cached peers * Test reconnecting to cached peers * Fixes * Rename to `peer_history`
- Loading branch information
1 parent
f329911
commit ea6557d
Showing
35 changed files
with
545 additions
and
120 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
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
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
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,48 @@ | ||
#include <nano/node/peer_history.hpp> | ||
#include <nano/test_common/system.hpp> | ||
#include <nano/test_common/testutil.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST (peer_history, store_live) | ||
{ | ||
nano::test::system system; | ||
|
||
auto & node1 = *system.add_node (); | ||
auto & node2 = *system.add_node (); | ||
auto & node3 = *system.add_node (); | ||
|
||
ASSERT_TIMELY (5s, node1.peer_history.exists (node2.network.endpoint ())); | ||
ASSERT_TIMELY (5s, node1.peer_history.exists (node3.network.endpoint ())); | ||
|
||
ASSERT_TIMELY (5s, node2.peer_history.exists (node1.network.endpoint ())); | ||
ASSERT_TIMELY (5s, node2.peer_history.exists (node3.network.endpoint ())); | ||
|
||
ASSERT_TIMELY (5s, node3.peer_history.exists (node1.network.endpoint ())); | ||
ASSERT_TIMELY (5s, node3.peer_history.exists (node2.network.endpoint ())); | ||
} | ||
|
||
TEST (peer_history, erase_old) | ||
{ | ||
nano::test::system system; | ||
|
||
auto & node1 = *system.add_node (); | ||
auto & node2 = *system.add_node (); | ||
|
||
ASSERT_TIMELY (5s, node1.peer_history.exists (node2.network.endpoint ())); | ||
ASSERT_TIMELY (5s, node2.peer_history.exists (node1.network.endpoint ())); | ||
|
||
// Endpoint won't be available after node is stopped | ||
auto node2_endpoint = node2.network.endpoint (); | ||
|
||
system.stop_node (node2); | ||
|
||
auto cached1 = node1.peer_history.peers (); | ||
ASSERT_EQ (cached1.size (), 1); | ||
ASSERT_EQ (cached1[0], node2_endpoint); | ||
|
||
ASSERT_TIMELY (5s, !node1.peer_history.exists (node2_endpoint)); | ||
|
||
auto cached2 = node1.peer_history.peers (); | ||
ASSERT_EQ (cached2.size (), 0); | ||
} |
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,10 @@ | ||
#pragma once | ||
|
||
#include <nano/boost/asio/ip/tcp.hpp> | ||
#include <nano/boost/asio/ip/udp.hpp> | ||
|
||
namespace nano | ||
{ | ||
using endpoint = boost::asio::ip::udp::endpoint; | ||
using tcp_endpoint = boost::asio::ip::tcp::endpoint; | ||
} |
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
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
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
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
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,11 @@ | ||
#pragma once | ||
|
||
#include <nano/store/fwd.hpp> | ||
|
||
namespace nano | ||
{ | ||
class logger; | ||
class node; | ||
class network; | ||
class stats; | ||
} |
Oops, something went wrong.