Websocket re-architecture with websocketd and websocat (#89)

- Replaced beast with websocketd and websocat. #79 #83 #84
- Implemented inbound/outbound peer connection merging.
- Added graceful shutdown of hpcore with sigint. #87
This commit is contained in:
Ravin Perera
2020-04-05 08:12:55 +05:30
committed by GitHub
parent 1904c1800a
commit 920be03ade
60 changed files with 1786 additions and 1753 deletions

View File

@@ -1,4 +1,3 @@
#include <flatbuffers/flatbuffers.h>
#include "../pchheader.hpp"
#include "../conf.hpp"
#include "../crypto.hpp"
@@ -6,6 +5,7 @@
#include "../fbschema/common_helpers.hpp"
#include "../fbschema/ledger_helpers.hpp"
#include "../fbschema/p2pmsg_helpers.hpp"
#include "../hplog.hpp"
#include "ledger_handler.hpp"
#include "cons.hpp"
@@ -232,9 +232,10 @@ void send_ledger_history_request(const std::string &minimum_lcl, const std::stri
p2p::history_request hr;
hr.required_lcl = required_lcl;
hr.minimum_lcl = minimum_lcl;
p2p::peer_outbound_message msg(std::make_unique<flatbuffers::FlatBufferBuilder>(1024));
p2pmsg::create_msg_from_history_request(msg.builder(), hr);
p2p::send_message_to_random_peer(msg);
flatbuffers::FlatBufferBuilder fbuf(1024);
p2pmsg::create_msg_from_history_request(fbuf, hr);
p2p::send_message_to_random_peer(fbuf);
ctx.last_requested_lcl = required_lcl;
@@ -365,19 +366,6 @@ const p2p::history_response retrieve_ledger_history(const p2p::history_request &
return history_response;
}
/**
* Send ledger history response for history request.
* @param hr lcl history request information.
* @return peer outbound message object with ledger history response.
*/
p2p::peer_outbound_message send_ledger_history(const p2p::history_request &hr)
{
p2p::peer_outbound_message msg(std::make_unique<flatbuffers::FlatBufferBuilder>(1024));
p2pmsg::create_msg_from_history_response(msg.builder(), retrieve_ledger_history(hr));
return msg;
}
/**
* Handle recieved ledger history response.
* @param hr lcl history request information.
@@ -479,7 +467,7 @@ void handle_ledger_history_response(const p2p::history_response &hr)
cons::ctx.led_seq_no = latest_lcl_itr->first;
}
LOG_DBG << "Finished lcl sync. New lcl: " << cons::ctx.lcl.substr(0, 15);
LOG_INFO << "lcl sync complete. New lcl:" << cons::ctx.lcl.substr(0, 15);
}
} // namespace cons