Raven Core  3.0.0
P2P Digital Currency
netmessagemaker.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Copyright (c) 2017-2019 The Raven Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef RAVEN_NETMESSAGEMAKER_H
8 #define RAVEN_NETMESSAGEMAKER_H
9 
10 #include "net.h"
11 #include "serialize.h"
12 
14 {
15 public:
16  explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}
17 
18  template <typename... Args>
19  CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const
20  {
22  msg.command = std::move(sCommand);
23  CVectorWriter{ SER_NETWORK, nFlags | nVersion, msg.data, 0, std::forward<Args>(args)... };
24  return msg;
25  }
26 
27  template <typename... Args>
28  CSerializedNetMsg Make(std::string sCommand, Args&&... args) const
29  {
30  return Make(0, std::move(sCommand), std::forward<Args>(args)...);
31  }
32 
33 private:
34  const int nVersion;
35 };
36 
37 #endif // RAVEN_NETMESSAGEMAKER_H
std::vector< unsigned char > data
Definition: net.h:115
CSerializedNetMsg Make(std::string sCommand, Args &&... args) const
const int nVersion
CNetMsgMaker(int nVersionIn)
std::string command
Definition: net.h:116
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args &&... args) const