aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-02-28 17:01:53 -0500
committerMarcoFalke <falke.marco@gmail.com>2020-02-28 17:01:58 -0500
commiteca4d8ef6afff6706d8626f72345768b1f78f630 (patch)
treeac5c421ac47f3c1c4e1ab6ad28766e5262fa6002 /src/net.h
parent1a51cd1ac5a094c911d6cafb3f57ef0798d51570 (diff)
parent16d6113f4faa901e248adb693d4768a9e5019a16 (diff)
Merge #16562: Refactor message transport packaging
16d6113f4faa901e248adb693d4768a9e5019a16 Refactor message transport packaging (Jonas Schnelli) Pull request description: This PR factors out transport packaging logic from `CConnman::PushMessage()`. It's similar to #16202 (where we refactor deserialization). This allows implementing a new message transport protocol like BIP324. ACKs for top commit: dongcarl: ACK 16d6113f4faa901e248adb693d4768a9e5019a16 FWIW ariard: Code review ACK 16d6113 elichai: semiACK 16d6113f4faa901e248adb693d4768a9e5019a16 ran functional+unit tests. MarcoFalke: ACK 16d6113f4faa901e248adb693d4768a9e5019a16 🙎 Tree-SHA512: 8c2f8ab9f52e9b94327973ae15019a08109d5d9f9247492703a842827c5b5d634fc0411759e0bb316d824c586614b0220c2006410851933613bc143e58f7e6c1
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index 819947658a..7d3eaa2e0d 100644
--- a/src/net.h
+++ b/src/net.h
@@ -703,12 +703,27 @@ public:
CNetMessage GetMessage(const CMessageHeader::MessageStartChars& message_start, int64_t time) override;
};
+/** The TransportSerializer prepares messages for the network transport
+ */
+class TransportSerializer {
+public:
+ // prepare message for transport (header construction, error-correction computation, payload encryption, etc.)
+ virtual void prepareForTransport(CSerializedNetMsg& msg, std::vector<unsigned char>& header) = 0;
+ virtual ~TransportSerializer() {}
+};
+
+class V1TransportSerializer : public TransportSerializer {
+public:
+ void prepareForTransport(CSerializedNetMsg& msg, std::vector<unsigned char>& header) override;
+};
+
/** Information about a peer */
class CNode
{
friend class CConnman;
public:
std::unique_ptr<TransportDeserializer> m_deserializer;
+ std::unique_ptr<TransportSerializer> m_serializer;
// socket
std::atomic<ServiceFlags> nServices{NODE_NONE};