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