Browse Source

coding standards

cl-refactor
subtly 10 years ago
parent
commit
8845967a1d
  1. 3
      libp2p/Host.cpp
  2. 6
      libp2p/NodeTable.cpp
  3. 8
      libp2p/NodeTable.h
  4. 2
      test/peer.cpp

3
libp2p/Host.cpp

@ -53,7 +53,6 @@ Host::Host(std::string const& _clientVersion, NetworkPreferences const& _n, bool
m_ioService(2),
m_tcp4Acceptor(m_ioService),
m_key(move(getHostIdentifier()))
// m_nodeTable(new NodeTable(m_ioService, m_key))
{
for (auto address: m_ifAddresses)
if (address.is_v4())
@ -157,8 +156,6 @@ unsigned Host::protocolVersion() const
void Host::registerPeer(std::shared_ptr<Session> _s, CapDescs const& _caps)
{
asserts(!!_s->m_peer->id);
{
RecursiveGuard l(x_sessions);
if (!m_peers.count(_s->m_peer->id))

6
libp2p/NodeTable.cpp

@ -53,6 +53,12 @@ NodeTable::~NodeTable()
m_socketPtr->disconnect();
}
void NodeTable::processEvents()
{
if (m_nodeEvents)
m_nodeEvents->processEvents();
}
shared_ptr<NodeEntry> NodeTable::addNode(Public const& _pubk, bi::udp::endpoint const& _udp, bi::tcp::endpoint const& _tcp)
{
auto node = Node(_pubk, NodeIPEndpoint(_udp, _tcp));

8
libp2p/NodeTable.h

@ -94,7 +94,8 @@ public:
protected:
/// Called by NodeTable on behalf of an implementation (Host) to process new events without blocking nodetable.
void processEvents() {
void processEvents()
{
std::list<std::pair<NodeId,NodeTableEventType>> events;
{
Guard l(x_events);
@ -183,10 +184,7 @@ public:
void setEventHandler(NodeTableEventHandler* _handler) { m_nodeEvents.reset(_handler); }
/// Called by implementation which provided handler to process NodeEntryAdded/NodeEntryRemoved events. Events are coalesced by type whereby old events are ignored.
void processEvents() {
if (m_nodeEvents)
m_nodeEvents->processEvents();
}
void processEvents();
/// Add node. Node will be pinged if it's not already known.
std::shared_ptr<NodeEntry> addNode(Public const& _pubk, bi::udp::endpoint const& _udp, bi::tcp::endpoint const& _tcp = bi::tcp::endpoint());

2
test/peer.cpp

@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(host)
host1.addNode(node2, "127.0.0.1", host2prefs.listenPort, host2prefs.listenPort);
this_thread::sleep_for(chrono::seconds(2));
this_thread::sleep_for(chrono::seconds(1));
}
BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save