Browse Source

define constructors for windows

cl-refactor
subtly 10 years ago
parent
commit
506fe0f6e8
  1. 5
      libp2p/NodeTable.h
  2. 2
      libp2p/UDP.h
  3. 2
      test/net.cpp

5
libp2p/NodeTable.h

@ -46,6 +46,7 @@ namespace p2p
* @todo makeRequired: exclude bucket from refresh if we have node as peer. * @todo makeRequired: exclude bucket from refresh if we have node as peer.
* *
* [Optimization] * [Optimization]
* @todo encapsulate doFindNode into NetworkAlgorithm (task)
* @todo Pong to include ip:port where ping was received * @todo Pong to include ip:port where ping was received
* @todo expiration and sha3(id) 'to' for messages which are replies (prevents replay) * @todo expiration and sha3(id) 'to' for messages which are replies (prevents replay)
* @todo std::shared_ptr<PingNode> m_cachedPingPacket; * @todo std::shared_ptr<PingNode> m_cachedPingPacket;
@ -281,7 +282,7 @@ struct Pong: RLPXDatagram<Pong>
*/ */
struct FindNode: RLPXDatagram<FindNode> struct FindNode: RLPXDatagram<FindNode>
{ {
using RLPXDatagram<FindNode>::RLPXDatagram; FindNode(bi::udp::endpoint _ep): RLPXDatagram<FindNode>(_ep) {}
FindNode(bi::udp::endpoint _ep, NodeId _target, std::chrono::seconds _expiration = std::chrono::seconds(30)): RLPXDatagram<FindNode>(_ep), target(_target), expiration(futureFromEpoch(_expiration)) {} FindNode(bi::udp::endpoint _ep, NodeId _target, std::chrono::seconds _expiration = std::chrono::seconds(30)): RLPXDatagram<FindNode>(_ep), target(_target), expiration(futureFromEpoch(_expiration)) {}
h512 target; h512 target;
@ -312,7 +313,7 @@ struct Neighbours: RLPXDatagram<Neighbours>
void interpretRLP(RLP const& _r) { ipAddress = _r[0].toString(); port = _r[1].toInt<unsigned>(); node = h512(_r[2].toBytes()); } void interpretRLP(RLP const& _r) { ipAddress = _r[0].toString(); port = _r[1].toInt<unsigned>(); node = h512(_r[2].toBytes()); }
}; };
using RLPXDatagram<Neighbours>::RLPXDatagram; Neighbours(bi::udp::endpoint _ep): RLPXDatagram<Neighbours>(_ep) {}
Neighbours(bi::udp::endpoint _to, std::vector<std::shared_ptr<NodeTable::NodeEntry>> const& _nearest, unsigned _offset = 0, unsigned _limit = 0): RLPXDatagram<Neighbours>(_to) Neighbours(bi::udp::endpoint _to, std::vector<std::shared_ptr<NodeTable::NodeEntry>> const& _nearest, unsigned _offset = 0, unsigned _limit = 0): RLPXDatagram<Neighbours>(_to)
{ {
auto limit = _limit ? std::min(_nearest.size(), (size_t)(_offset + _limit)) : _nearest.size(); auto limit = _limit ? std::min(_nearest.size(), (size_t)(_offset + _limit)) : _nearest.size();

2
libp2p/UDP.h

@ -76,7 +76,7 @@ struct RLPXDatagramFace: public UDPDatagram
template <class T> template <class T>
struct RLPXDatagram: public RLPXDatagramFace struct RLPXDatagram: public RLPXDatagramFace
{ {
using RLPXDatagramFace::RLPXDatagramFace; RLPXDatagram(bi::udp::endpoint const& _ep): RLPXDatagramFace(_ep) {}
static T fromBytesConstRef(bi::udp::endpoint const& _ep, bytesConstRef _bytes) { T t(_ep); t.interpretRLP(_bytes); return std::move(t); } static T fromBytesConstRef(bi::udp::endpoint const& _ep, bytesConstRef _bytes) { T t(_ep); t.interpretRLP(_bytes); return std::move(t); }
}; };

2
test/net.cpp

@ -51,7 +51,7 @@ protected:
struct TestNodeTable: public NodeTable struct TestNodeTable: public NodeTable
{ {
/// Constructor /// Constructor
using NodeTable::NodeTable; TestNodeTable(ba::io_service& _io, KeyPair _alias, uint16_t _port = 30300): NodeTable(_io, _alias, _port) {}
static std::vector<std::pair<KeyPair,unsigned>> createTestNodes(unsigned _count) static std::vector<std::pair<KeyPair,unsigned>> createTestNodes(unsigned _count)
{ {

Loading…
Cancel
Save