Fabcoin Core  0.16.2
P2P Digital Currency
HostCapability.cpp
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #include "HostCapability.h"
23 
24 #include "Session.h"
25 #include "Host.h"
26 using namespace std;
27 using namespace dev;
28 using namespace dev::p2p;
29 
30 std::vector<std::pair<std::shared_ptr<SessionFace>, std::shared_ptr<Peer>>> HostCapabilityFace::peerSessions() const
31 {
32  return peerSessions(version());
33 }
34 
35 std::vector<std::pair<std::shared_ptr<SessionFace>, std::shared_ptr<Peer>>> HostCapabilityFace::peerSessions(u256 const& _version) const
36 {
37  RecursiveGuard l(m_host->x_sessions);
38  std::vector<std::pair<std::shared_ptr<SessionFace>, std::shared_ptr<Peer>>> ret;
39  for (auto const& i: m_host->m_sessions)
40  if (std::shared_ptr<SessionFace> s = i.second.lock())
41  if (s->capabilities().count(std::make_pair(name(), _version)))
42  ret.push_back(make_pair(s,s->peer()));
43  return ret;
44 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::hash for asio::adress
Definition: Common.h:323
void version()
Definition: main.cpp:53
const char * name
Definition: rest.cpp:36
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
std::lock_guard< std::recursive_mutex > RecursiveGuard
Definition: Guards.h:43