Joel Grunbaum
2022-01-11 0594ac9ba0f38944ef810b5ac48a2067b1ce5a09
commit | author | age
16b655 1 #pragma once
JG 2
3 #include "book.hpp"
4 #include "json.hpp"
5
6 #include <string>
7 #include <unordered_map>
8
9 namespace protocol
10 {
11 enum OrderEnum { ADD, DELETE, BROKER_REQUEST, BROKER_CONFIRM };
12
6926be 13 // Catchup utilities
16b655 14 std::unordered_map<std::string, book::Book> recoverBook();
4fdb65 15 void catchUp(std::unordered_map<std::string, book::Book>& bs);
16b655 16
6926be 17 // Outgoing messages
JG 18 json::Message* addOrder(json::AddMessage& order);
19 json::Message* deleteOrder(json::DeleteMessage& order);
16b655 20
JG 21 // Incoming messages
22 void handleMessage(std::unordered_map<std::string, book::Book>& bs,
23                    json::Message* message);
24 void announce(std::unordered_map<std::string, book::Book>& bs,
25               json::AnnounceMessage* message);
26 void settle(std::unordered_map<std::string, book::Book>& bs,
27             json::SettleMessage* message);
28 void addedOrder(std::unordered_map<std::string, book::Book>& bs,
6926be 29                 json::AddedMessage* message);
16b655 30 void deletedOrder(std::unordered_map<std::string, book::Book>& bs,
6926be 31                   json::DeletedMessage* message);
16b655 32 void tradeOrder(std::unordered_map<std::string, book::Book>& bs,
JG 33                 json::TradeMessage* message);
34 void broker(std::unordered_map<std::string, book::Book>& bs,
35             json::Broker* message);
36
6926be 37 json::Message* send(std::string& message);
16b655 38 } // namespace protocol