6#include <condition_variable>
8#include <boost/filesystem.hpp>
21 :
std::runtime_error(what_arg)
24 :
std::runtime_error(what_arg)
31 :
std::runtime_error(what_arg)
34 :
std::runtime_error(what_arg)
41 :
std::runtime_error(what_arg)
44 :
std::runtime_error(what_arg)
51 :
std::runtime_error(what_arg)
54 :
std::runtime_error(what_arg)
65 template<
typename DataEntry,
typename File>
66 static uint64_t append_store(
const DataEntry &entry, File &file) {
68 const auto offset = file.tellp();
69 file.write(data.data(), data.size());
81 template<
typename DataEntry,
typename File>
82 static DataEntry extract_store( File& file ) {
84 auto ds = file.create_datastream();
104 std::optional<uint32_t> minimum_uncompressed_irreversible_history_blocks,
size_t compression_seek_point_stride);
113 return block_height / _width;
237 void create_new_index_slice_file(
fc::cfile& index_file)
const;
244 void process_irreversible_slice_range(
uint32_t lib,
uint32_t upper_bound_block, std::optional<uint32_t>& lower_bound_slice, F&&
f);
246 const boost::filesystem::path _slice_dir;
248 const std::optional<uint32_t> _minimum_irreversible_history_blocks;
249 std::optional<uint32_t> _last_cleaned_up_slice;
250 const std::optional<uint32_t> _minimum_uncompressed_irreversible_history_blocks;
251 std::optional<uint32_t> _last_compressed_slice;
252 const size_t _compression_seek_point_stride;
254 std::mutex _maintenance_mtx;
255 std::condition_variable _maintenance_condition;
256 std::thread _maintenance_thread;
257 bool _maintenance_shutdown{
false};
268 store_provider(
const boost::filesystem::path& slice_dir,
uint32_t stride_width, std::optional<uint32_t> minimum_irreversible_history_blocks,
269 std::optional<uint32_t> minimum_uncompressed_irreversible_history_blocks,
size_t compression_seek_point_stride);
271 template<
typename BlockTrace>
303 template<
typename Fn>
314 offset = index.tellp();
316 while (offset < end) {
318 const auto metadata = extract_store<metadata_log_entry>(index);
322 last_read_offset = offset;
323 offset = index.tellp();
325 return last_read_offset;
344 ctrace->seek(offset);
345 return extract_store<data_log_entry>(*ctrace);
348 const std::string offset_str = boost::lexical_cast<std::string>(offset);
349 const std::string bh_str = boost::lexical_cast<std::string>(block_height);
350 throw malformed_slice_file(
"Requested offset: " + offset_str +
" to retrieve block number: " + bh_str +
" but this trace file is new, so there are no traces present.");
353 if( offset >= end ) {
354 const std::string offset_str = boost::lexical_cast<std::string>(offset);
355 const std::string bh_str = boost::lexical_cast<std::string>(block_height);
356 const std::string end_str = boost::lexical_cast<std::string>(end);
357 throw malformed_slice_file(
"Requested offset: " + offset_str +
" to retrieve block number: " + bh_str +
" but this trace file only goes to offset: " + end_str);
360 return extract_store<data_log_entry>(trace);
fc::path get_file_path() const
incompatible_slice_files(const std::string &what_arg)
incompatible_slice_files(const char *what_arg)
old_slice_version(const std::string &what_arg)
old_slice_version(const char *what_arg)
path_does_not_exist(const std::string &what_arg)
path_does_not_exist(const char *what_arg)
bool find_or_create_index_slice(uint32_t slice_number, open_state state, fc::cfile &index_file) const
bool find_trace_slice(uint32_t slice_number, open_state state, fc::cfile &trace_file, bool open_file=true) const
bool find_or_create_trace_slice(uint32_t slice_number, open_state state, fc::cfile &trace_file) const
uint32_t slice_number(uint32_t block_height) const
std::optional< compressed_file > find_compressed_trace_slice(uint32_t slice_number, bool open_file=true) const
void start_maintenance_thread(log_handler log)
void run_maintenance_tasks(uint32_t lib, const log_handler &log)
slice_directory(const boost::filesystem::path &slice_dir, uint32_t width, std::optional< uint32_t > minimum_irreversible_history_blocks, std::optional< uint32_t > minimum_uncompressed_irreversible_history_blocks, size_t compression_seek_point_stride)
bool find_index_slice(uint32_t slice_number, open_state state, fc::cfile &index_file, bool open_file=true) const
bool find_or_create_trx_id_slice(uint32_t slice_number, open_state state, fc::cfile &trx_id_file) const
void find_or_create_slice_pair(uint32_t slice_number, open_state state, fc::cfile &trace, fc::cfile &index)
void set_lib(uint32_t lib)
void stop_maintenance_thread()
bool find_trx_id_slice(uint32_t slice_number, open_state state, fc::cfile &trx_id_file, bool open_file=true) const
void append_trx_ids(block_trxs_entry tt)
uint64_t scan_metadata_log_from(uint32_t block_height, uint64_t offset, Fn &&fn, const yield_function &yield)
get_block_n get_trx_block_number(const chain::transaction_id_type &trx_id, std::optional< uint32_t > minimum_irreversible_history_blocks, const yield_function &yield={})
void append(const BlockTrace &bt)
void initialize_new_index_slice_file(fc::cfile &index)
get_block_t get_block(uint32_t block_height, const yield_function &yield={})
void append_lib(uint32_t lib)
store_provider(const boost::filesystem::path &slice_dir, uint32_t stride_width, std::optional< uint32_t > minimum_irreversible_history_blocks, std::optional< uint32_t > minimum_uncompressed_irreversible_history_blocks, size_t compression_seek_point_stride)
void stop_maintenance_thread()
void validate_existing_index_slice_file(fc::cfile &index, open_state state)
slice_directory _slice_directory
void start_maintenance_thread(log_handler log)
std::optional< data_log_entry > read_data_log(uint32_t block_height, uint64_t offset)
void unpack(Stream &s, std::deque< T > &value)
void pack(Stream &s, const std::deque< T > &value)
uint64_t file_size(const path &p)
std::optional< std::tuple< data_log_entry, bool > > get_block_t
std::optional< uint32_t > get_block_n
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
unsigned __int64 uint64_t
slice_directory::open_state open_state
void bt(const Operand &op, const Reg ®)