Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_NETMESSAGEMAKER_H
7 #define BITCOIN_NETMESSAGEMAKER_H
8 
9 #include <net.h>
10 #include <serialize.h>
11 
13 {
14 public:
15  explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}
16 
17  template <typename... Args>
18  CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args) const
19  {
21  msg.command = std::move(sCommand);
22  msg.data.reserve(4 * 1024);
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 // BITCOIN_NETMESSAGEMAKER_H
std::vector< unsigned char > data
Definition: net.h:131
CSerializedNetMsg Make(std::string sCommand, Args &&... args) const
const int nVersion
CNetMsgMaker(int nVersionIn)
std::string command
Definition: net.h:132
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args &&... args) const
Released under the MIT license