Bitcoin ABC 0.30.7
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// 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 <serialize.h>
10
12class CVectorWriter;
13
15public:
16 explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn) {}
17
18 template <typename... Args>
19 CSerializedNetMsg Make(int nFlags, std::string msg_type,
20 Args &&...args) const {
22 msg.m_type = std::move(msg_type);
23 CVectorWriter{SER_NETWORK, nFlags | nVersion, msg.data, 0,
24 std::forward<Args>(args)...};
25 return msg;
26 }
27
28 template <typename... Args>
29 CSerializedNetMsg Make(std::string msg_type, Args &&...args) const {
30 return Make(0, std::move(msg_type), std::forward<Args>(args)...);
31 }
32
33private:
34 const int nVersion;
35};
36
37#endif // BITCOIN_NETMESSAGEMAKER_H
const int nVersion
CNetMsgMaker(int nVersionIn)
CSerializedNetMsg Make(int nFlags, std::string msg_type, Args &&...args) const
CSerializedNetMsg Make(std::string msg_type, Args &&...args) const
Minimal stream for overwriting and/or appending to an existing byte vector.
Definition: streams.h:65
@ SER_NETWORK
Definition: serialize.h:152
std::vector< uint8_t > data
Definition: net.h:131
std::string m_type
Definition: net.h:132