forked from facebookresearch/fbpcf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (35 loc) · 1.2 KB
/
main.cpp
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
39
40
41
42
43
44
45
46
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <stdexcept>
#include <gflags/gflags.h>
#include "folly/init/Init.h"
#include "folly/logging/xlog.h"
#include "./MillionaireApp.h"
#include "fbpcf/exception/ExceptionBase.h"
DEFINE_int32(role, 1, "1 = Alice, 2 = Bob");
DEFINE_string(server_ip, "", "Server's IP address");
DEFINE_int32(port, 5000, "Server's port");
int main(int argc, char* argv[]) {
folly::init(&argc, &argv);
gflags::ParseCommandLineFlags(&argc, &argv, true);
XLOGF(INFO, "Role: {}", FLAGS_role);
XLOGF(INFO, "Server IP: {}", FLAGS_server_ip);
XLOGF(INFO, "Port: {}", FLAGS_port);
XLOG(INFO) << "Start Millionaire Game...";
auto role = static_cast<fbpcf::Party>(FLAGS_role);
try {
fbpcf::MillionaireApp(role, FLAGS_server_ip, FLAGS_port).run();
} catch (const fbpcf::ExceptionBase& e) {
XLOGF(ERR, "Some error occured: {}", e.what());
return 1;
} catch (const std::exception& e) {
XLOGF(ERR, "Some unknown error occured: {}", e.what());
return -1;
}
XLOG(INFO) << "Millionaire Game is completed.";
return 0;
}