63 lines
2.2 KiB
C++
63 lines
2.2 KiB
C++
|
|
/// @file dpf/launch.hpp
|
||
|
|
/// @brief Start here: run a composed protocol as 2 or 3 parties.
|
||
|
|
/// @details
|
||
|
|
/// * In one process: `dpf::run_two_party` / `dpf::run_three_party`, with
|
||
|
|
/// every choice in `app::run_config` (transport: async memory, unix
|
||
|
|
/// sockets, TCP mux, parallel TCP, SCTP; lanes; framing; instances;
|
||
|
|
/// window; timeouts). Party 2 is the dealer / RSS third party.
|
||
|
|
/// * In separate processes: `app::parse_node_args(argc, argv)` then
|
||
|
|
/// `app::run_node(args, plan, values)`, started as
|
||
|
|
/// `--party=i --peers=host:port,host:port[,host:port]` on each machine.
|
||
|
|
/// See `examples/protocol/party_node.cpp`.
|
||
|
|
/// Both ends exchange a plan-shape hello, so a lane, framing, instance, or
|
||
|
|
/// plan mismatch fails with a message that names the field.
|
||
|
|
#ifndef LIBDPF_INCLUDE_DPF_LAUNCH_HPP__
|
||
|
|
#define LIBDPF_INCLUDE_DPF_LAUNCH_HPP__
|
||
|
|
|
||
|
|
#include <cstdint>
|
||
|
|
#include <map>
|
||
|
|
#include <vector>
|
||
|
|
|
||
|
|
#include "dpf/party_runner.hpp"
|
||
|
|
#include "dpf/run_config.hpp"
|
||
|
|
|
||
|
|
namespace dpf
|
||
|
|
{
|
||
|
|
|
||
|
|
/// @brief Parties 0 and 1 on threads over `cfg.kind`.
|
||
|
|
inline app::parties_result run_two_party(const protocol::plan & p0,
|
||
|
|
const protocol::plan & p1, app::party_values & v0, app::party_values & v1,
|
||
|
|
const std::map<std::uint32_t, protocol::kernel_fn> & kernels = {},
|
||
|
|
const app::run_config & cfg = {})
|
||
|
|
{
|
||
|
|
std::vector<app::party_values> values(2);
|
||
|
|
values[0] = std::move(v0);
|
||
|
|
values[1] = std::move(v1);
|
||
|
|
auto r = app::run_parties({p0, p1}, values, kernels, cfg);
|
||
|
|
v0 = std::move(values[0]);
|
||
|
|
v1 = std::move(values[1]);
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// @brief Parties 0, 1, and 2 (dealer / RSS third party) on threads.
|
||
|
|
inline app::parties_result run_three_party(const protocol::plan & p0,
|
||
|
|
const protocol::plan & p1, const protocol::plan & p2, app::party_values & v0,
|
||
|
|
app::party_values & v1, app::party_values & v2,
|
||
|
|
const std::map<std::uint32_t, protocol::kernel_fn> & kernels = {},
|
||
|
|
const app::run_config & cfg = {})
|
||
|
|
{
|
||
|
|
std::vector<app::party_values> values(3);
|
||
|
|
values[0] = std::move(v0);
|
||
|
|
values[1] = std::move(v1);
|
||
|
|
values[2] = std::move(v2);
|
||
|
|
auto r = app::run_parties({p0, p1, p2}, values, kernels, cfg);
|
||
|
|
v0 = std::move(values[0]);
|
||
|
|
v1 = std::move(values[1]);
|
||
|
|
v2 = std::move(values[2]);
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
} // namespace dpf
|
||
|
|
|
||
|
|
#endif
|