#pragma once #include "server.hpp" #include "nodeclient.hpp" #include "prevnode.hpp" #include "nextnode.hpp" #include "api.h" #include "curve25519.h" #include "cmix.pb.h" #include #include /*! * \file */ /*! * \brief The NodeNetworkSettings struct */ struct NodeNetworkSettings { bool is_first; ///< Are we the first node in the network. std::string next_host; ///< Next nodes host. std::string next_port; ///< Next nodes port. }; /*! * \brief The Node class */ class Node { boost::asio::io_service io_service; Server server; std::list purgatory; std::list clients; NodeNetworkSettings network_settings; PrevNode prev_node; NextNode next_node; Api api; KeyPair keypair; std::vector network_pub_key; void accept_handler(boost::asio::ip::tcp::socket&& socket); void start_precomputation(); void start_initialisation(); void handle_initialization(cmix_proto::Initialization const& init); void handle_message(std::vector const& message_buffer); void handle_imanode(std::list::iterator handle); void handle_imaclient(std::list::iterator handle); void handle_message(std::list::iterator handle, std::vector const& message_buffer); public: /*! * \brief Node * \param listen_settings The listen settings for the accepter. * \param network_settings The network settings containing if we are first and who is the next node. */ Node(ListenSettings const& listen_settings, NodeNetworkSettings network_settings); ~Node(); /*! * \brief run Starts the underlying io_service */ void run(); };