Skip to content

Commit

Permalink
Merge branch 'main' of github.com:AntelopeIO/spring into gh_47
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed May 6, 2024
2 parents 9cd5fd0 + 3cefaf1 commit 9a81911
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
14 changes: 7 additions & 7 deletions libraries/libfc/include/fc/network/listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct listener_base<boost::asio::local::stream_protocol> {
/// detail for fc::create_listener().
///
/////////////////////////////////////////////////////////////////////////////////////////////
template <typename Protocol, typename CreateSession>
struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener<Protocol, CreateSession>> {
template <typename Protocol, typename Executor, typename CreateSession>
struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener<Protocol, Executor, CreateSession>> {
private:
typename Protocol::acceptor acceptor_;
boost::asio::deadline_timer accept_error_timer_;
Expand All @@ -71,7 +71,7 @@ struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener

public:
using endpoint_type = typename Protocol::endpoint;
listener(boost::asio::io_context& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
listener(Executor& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
const std::string& local_address, const endpoint_type& endpoint,
const std::string& extra_listening_log_info, const CreateSession& create_session)
: listener_base<Protocol>(local_address), acceptor_(executor, endpoint), accept_error_timer_(executor),
Expand Down Expand Up @@ -159,8 +159,8 @@ struct listener : listener_base<Protocol>, std::enable_shared_from_this<listener
///
/// @tparam Protocol either \c boost::asio::ip::tcp or \c boost::asio::local::stream_protocol
/// @throws std::system_error or boost::system::system_error
template <typename Protocol, typename CreateSession>
void create_listener(boost::asio::io_context& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
template <typename Protocol, typename Executor, typename CreateSession>
void create_listener(Executor& executor, logger& logger, boost::posix_time::time_duration accept_timeout,
const std::string& address, const std::string& extra_listening_log_info,
const CreateSession& create_session) {
using tcp = boost::asio::ip::tcp;
Expand All @@ -186,7 +186,7 @@ void create_listener(boost::asio::io_context& executor, logger& logger, boost::p
auto create_listener = [&](const auto& endpoint) {
const auto& ip_addr = endpoint.address();
try {
auto listener = std::make_shared<fc::listener<Protocol, CreateSession>>(
auto listener = std::make_shared<fc::listener<Protocol, Executor, CreateSession>>(
executor, logger, accept_timeout, address, endpoint, extra_listening_log_info, create_session);
listener->log_listening(endpoint, address);
listener->do_accept();
Expand Down Expand Up @@ -256,7 +256,7 @@ void create_listener(boost::asio::io_context& executor, logger& logger, boost::p
fs::remove(sock_path);
}

auto listener = std::make_shared<fc::listener<stream_protocol, CreateSession>>(
auto listener = std::make_shared<fc::listener<stream_protocol, Executor, CreateSession>>(
executor, logger, accept_timeout, address, endpoint, extra_listening_log_info, create_session);
listener->log_listening(endpoint, address);
listener->do_accept();
Expand Down
16 changes: 9 additions & 7 deletions libraries/state_history/include/eosio/state_history/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static constexpr int state_history_log_header_serial_size = sizeof(state_history
sizeof(state_history_log_header::payload_size);
static_assert(sizeof(state_history_log_header) == state_history_log_header_serial_size);

static constexpr unsigned ship_log_iostreams_buffer_size = 64*1024;

namespace state_history {
struct prune_config {
uint32_t prune_blocks; //number of blocks to prune to when doing a prune
Expand Down Expand Up @@ -108,16 +110,16 @@ struct locked_decompress_stream {
template <typename StateHistoryLog>
void init(StateHistoryLog&& log, fc::cfile& stream, uint64_t compressed_size) {
auto istream = std::make_unique<bio::filtering_istreambuf>();
istream->push(bio::zlib_decompressor());
istream->push(bio::restrict(bio::file_source(stream.get_file_path().string()), stream.tellp(), compressed_size));
istream->push(bio::zlib_decompressor(), ship_log_iostreams_buffer_size);
istream->push(bio::restrict(bio::file_source(stream.get_file_path().string()), stream.tellp(), compressed_size), ship_log_iostreams_buffer_size);
buf = std::move(istream);
}

template <typename LogData>
void init(LogData&& log, fc::datastream<const char*>& stream, uint64_t compressed_size) {
auto istream = std::make_unique<bio::filtering_istreambuf>();
istream->push(bio::zlib_decompressor());
istream->push(bio::restrict(bio::file_source(log.filename), stream.pos() - log.data(), compressed_size));
istream->push(bio::zlib_decompressor(), ship_log_iostreams_buffer_size);
istream->push(bio::restrict(bio::file_source(log.filename), stream.pos() - log.data(), compressed_size), ship_log_iostreams_buffer_size);
buf = std::move(istream);
}

Expand Down Expand Up @@ -433,9 +435,9 @@ class state_history_log {
detail::counter cnt;
{
bio::filtering_ostreambuf buf;
buf.push(boost::ref(cnt));
buf.push(bio::zlib_compressor(boost::iostreams::zlib::no_compression));
buf.push(bio::file_descriptor_sink(stream.fileno(), bio::never_close_handle));
buf.push(boost::ref(cnt), ship_log_iostreams_buffer_size);
buf.push(bio::zlib_compressor(bio::zlib::no_compression, ship_log_iostreams_buffer_size));
buf.push(bio::file_descriptor_sink(stream.fileno(), bio::never_close_handle), ship_log_iostreams_buffer_size);
pack_to(buf);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/state_history_plugin/tests/session_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ struct test_server : mock_state_history_plugin {
};

// Create and launch a listening port
auto server = std::make_shared<fc::listener<tcp, decltype(create_session)>>(
auto server = std::make_shared<fc::listener<tcp, decltype(ship_ioc), decltype(create_session)>>(
ship_ioc, logger, boost::posix_time::milliseconds(100), "", local_address, "", create_session);
server->do_accept();
local_address = server->acceptor().local_endpoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def main():

myStr = result.stdout
myStr = myStr.rstrip("\n")
myStr = re.sub(":\n\s+-",':@@@\n -', string=myStr)
myStr = re.sub(":\n\\s+-",':@@@\n -', string=myStr)
myStr = re.sub("\n\n",'\n@@@', string=myStr)
myStr = re.sub("Application Options:\n",'', string=myStr)
pluginSections = re.split("(@@@.*?@@@\n)", string=myStr)
Expand All @@ -68,16 +68,16 @@ def pairwise(iterable):

pluginOptsDict = {}
for section, options in pairwise(pluginSections[1:]):
myOpts = re.sub("\s+", " ", options)
myOpts = re.sub("\\s+", " ", options)
myOpts = re.sub("\n", " ", myOpts)
myOpts = re.sub(" --", "\n--",string = myOpts)
splitOpts=re.split("\n", myOpts)

argDescDict = {}
for opt in splitOpts[1:]:
secondSplit = re.split("(--[\w\-]+)", opt)[1:]
secondSplit = re.split("(--[\\w\\-]+)", opt)[1:]
argument=secondSplit[0]
argDefaultDesc=secondSplit[1].lstrip("\s")
argDefaultDesc=secondSplit[1].lstrip("\\s")
argDescDict[argument] = argDefaultDesc
section=re.sub("@@@", "", section)
section=re.sub("\n", "", section)
Expand Down Expand Up @@ -122,7 +122,7 @@ def writeDataclass(plugin:str, dataFieldDict:dict, pluginOptsDict:dict):
newKey="".join([x.capitalize() for x in key.split('-')]).replace('--','')
newKey="".join([newKey[0].lower(), newKey[1:]])
value = chainPluginArgs[newKey]
match = re.search("\(=.*?\)", value)
match = re.search("\\(=.*?\\)", value)
if match is not None:
value = match.group(0)[2:-1]
try:
Expand Down

0 comments on commit 9a81911

Please sign in to comment.