Browse Source

Better code.

cl-refactor
subtly 10 years ago
parent
commit
7b8a4cebd8
  1. 6
      libethereum/EthereumHost.cpp
  2. 2
      libethereum/EthereumHost.h
  3. 2
      libp2p/Session.cpp

6
libethereum/EthereumHost.cpp

@ -218,11 +218,11 @@ void EthereumHost::maintainTransactions()
} }
} }
tuple<vector<shared_ptr<EthereumPeer>>, vector<shared_ptr<EthereumPeer>>, list<shared_ptr<Session>>> EthereumHost::randomSelection(unsigned _percent, std::function<bool(EthereumPeer*)> const& _allow) tuple<vector<shared_ptr<EthereumPeer>>, vector<shared_ptr<EthereumPeer>>, vector<shared_ptr<Session>>> EthereumHost::randomSelection(unsigned _percent, std::function<bool(EthereumPeer*)> const& _allow)
{ {
vector<shared_ptr<EthereumPeer>> chosen; vector<shared_ptr<EthereumPeer>> chosen;
vector<shared_ptr<EthereumPeer>> allowed; vector<shared_ptr<EthereumPeer>> allowed;
list<shared_ptr<Session>> sessions; vector<shared_ptr<Session>> sessions;
auto const& ps = peerSessions(); auto const& ps = peerSessions();
allowed.reserve(ps.size()); allowed.reserve(ps.size());
@ -243,7 +243,7 @@ tuple<vector<shared_ptr<EthereumPeer>>, vector<shared_ptr<EthereumPeer>>, list<s
chosen.push_back(std::move(allowed[n])); chosen.push_back(std::move(allowed[n]));
allowed.erase(allowed.begin() + n); allowed.erase(allowed.begin() + n);
} }
return make_tuple(chosen, allowed, sessions); return make_tuple(move(chosen), move(allowed), move(sessions));
} }
void EthereumHost::maintainBlocks(h256 const& _currentHash) void EthereumHost::maintainBlocks(h256 const& _currentHash)

2
libethereum/EthereumHost.h

@ -80,7 +80,7 @@ public:
void noteNewBlocks() { m_newBlocks = true; } void noteNewBlocks() { m_newBlocks = true; }
private: private:
std::tuple<std::vector<std::shared_ptr<EthereumPeer>>, std::vector<std::shared_ptr<EthereumPeer>>, std::list<std::shared_ptr<p2p::Session>>> randomSelection(unsigned _percent = 25, std::function<bool(EthereumPeer*)> const& _allow = [](EthereumPeer const*){ return true; }); std::tuple<std::vector<std::shared_ptr<EthereumPeer>>, std::vector<std::shared_ptr<EthereumPeer>>, std::vector<std::shared_ptr<p2p::Session>>> randomSelection(unsigned _percent = 25, std::function<bool(EthereumPeer*)> const& _allow = [](EthereumPeer const*){ return true; });
/// Session is tell us that we may need (re-)syncing with the peer. /// Session is tell us that we may need (re-)syncing with the peer.
void noteNeedsSyncing(EthereumPeer* _who); void noteNeedsSyncing(EthereumPeer* _who);

2
libp2p/Session.cpp

@ -319,7 +319,7 @@ void Session::send(bytes&& _msg)
void Session::write() void Session::write()
{ {
bytes *out; bytes const* out;
DEV_GUARDED(x_writeQueue) DEV_GUARDED(x_writeQueue)
{ {
m_io->writeSingleFramePacket(&m_writeQueue[0], m_writeQueue[0]); m_io->writeSingleFramePacket(&m_writeQueue[0], m_writeQueue[0]);

Loading…
Cancel
Save