Skip to content

Commit

Permalink
use random_access_file for ship log; refactor catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
spoonincode committed Jun 4, 2024
1 parent bd4fa28 commit 078145e
Show file tree
Hide file tree
Showing 11 changed files with 1,383 additions and 878 deletions.
1 change: 0 additions & 1 deletion libraries/state_history/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ file(GLOB HEADERS "include/eosio/state-history/*.hpp")

add_library( state_history
abi.cpp
compression.cpp
create_deltas.cpp
trace_converter.cpp
${HEADERS}
Expand Down
34 changes: 0 additions & 34 deletions libraries/state_history/compression.cpp

This file was deleted.

This file was deleted.

46 changes: 46 additions & 0 deletions libraries/state_history/include/eosio/state_history/counter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include <boost/iostreams/filtering_streambuf.hpp>

namespace eosio::detail {

namespace bio = boost::iostreams;

// directly adapt from boost/iostreams/filter/counter.hpp and change the type of chars_ to uint64_t.
class counter {
public:
typedef char char_type;
struct category
: bio::dual_use,
bio::filter_tag,
bio::multichar_tag,
bio::optimally_buffered_tag
{ };

uint64_t characters() const { return chars_; }
std::streamsize optimal_buffer_size() const { return 64*1024; }

template<typename Source>
std::streamsize read(Source& src, char_type* s, std::streamsize n)
{
std::streamsize result = bio::read(src, s, n);
if (result == -1)
return -1;
chars_ += result;
return result;
}

template<typename Sink>
std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
{
std::streamsize result = bio::write(snk, s, n);
chars_ += result;
return result;
}

private:
uint64_t chars_ = 0;
};
BOOST_IOSTREAMS_PIPABLE(counter, 0)

}
Loading

0 comments on commit 078145e

Please sign in to comment.