Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::pending_snapshot Class Reference
Collaboration diagram for sysio::pending_snapshot:

Public Types

using next_t = producer_plugin::next_function<producer_plugin::snapshot_information>
 

Public Member Functions

 pending_snapshot (const block_id_type &block_id, next_t &next, std::string pending_path, std::string final_path)
 
uint32_t get_height () const
 
producer_plugin::snapshot_information finalize (const chain::controller &chain) const
 

Static Public Member Functions

static bfs::path get_final_path (const block_id_type &block_id, const bfs::path &snapshots_dir)
 
static bfs::path get_pending_path (const block_id_type &block_id, const bfs::path &snapshots_dir)
 
static bfs::path get_temp_path (const block_id_type &block_id, const bfs::path &snapshots_dir)
 

Public Attributes

block_id_type block_id
 
next_t next
 
std::string pending_path
 
std::string final_path
 

Detailed Description

Definition at line 122 of file producer_plugin.cpp.

Member Typedef Documentation

◆ next_t

Constructor & Destructor Documentation

◆ pending_snapshot()

sysio::pending_snapshot::pending_snapshot ( const block_id_type & block_id,
next_t & next,
std::string pending_path,
std::string final_path )
inline

Member Function Documentation

◆ finalize()

producer_plugin::snapshot_information sysio::pending_snapshot::finalize ( const chain::controller & chain) const
inline

Definition at line 149 of file producer_plugin.cpp.

149 {
150 auto block_ptr = chain.fetch_block_by_id( block_id );
151 auto in_chain = (bool)block_ptr;
152 boost::system::error_code ec;
153
154 if (!in_chain) {
155 bfs::remove(bfs::path(pending_path), ec);
156 SYS_THROW(snapshot_finalization_exception,
157 "Snapshotted block was forked out of the chain. ID: ${block_id}",
158 ("block_id", block_id));
159 }
160
161 bfs::rename(bfs::path(pending_path), bfs::path(final_path), ec);
162 SYS_ASSERT(!ec, snapshot_finalization_exception,
163 "Unable to finalize valid snapshot of block number ${bn}: [code: ${ec}] ${message}",
164 ("bn", get_height())
165 ("ec", ec.value())
166 ("message", ec.message()));
167
168 return {block_id, block_ptr->block_num(), block_ptr->timestamp, chain_snapshot_header::current_version, final_path};
169 }
#define SYS_THROW(exc_type, FORMAT,...)
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
static constexpr uint32_t current_version
Here is the call graph for this function:

◆ get_final_path()

static bfs::path sysio::pending_snapshot::get_final_path ( const block_id_type & block_id,
const bfs::path & snapshots_dir )
inlinestatic

Definition at line 137 of file producer_plugin.cpp.

137 {
138 return snapshots_dir / fc::format_string("snapshot-${id}.bin", fc::mutable_variant_object()("id", block_id));
139 }
An order-preserving dictionary of variants.
fc::string format_string(const fc::string &, const variant_object &, bool minimize=false)
Definition variant.cpp:773
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_height()

uint32_t sysio::pending_snapshot::get_height ( ) const
inline

Definition at line 133 of file producer_plugin.cpp.

133 {
135 }
static uint32_t num_from_id(const block_id_type &id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pending_path()

static bfs::path sysio::pending_snapshot::get_pending_path ( const block_id_type & block_id,
const bfs::path & snapshots_dir )
inlinestatic

Definition at line 141 of file producer_plugin.cpp.

141 {
142 return snapshots_dir / fc::format_string(".pending-snapshot-${id}.bin", fc::mutable_variant_object()("id", block_id));
143 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_temp_path()

static bfs::path sysio::pending_snapshot::get_temp_path ( const block_id_type & block_id,
const bfs::path & snapshots_dir )
inlinestatic

Definition at line 145 of file producer_plugin.cpp.

145 {
146 return snapshots_dir / fc::format_string(".incomplete-snapshot-${id}.bin", fc::mutable_variant_object()("id", block_id));
147 }
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ block_id

block_id_type sysio::pending_snapshot::block_id

Definition at line 171 of file producer_plugin.cpp.

◆ final_path

std::string sysio::pending_snapshot::final_path

Definition at line 174 of file producer_plugin.cpp.

◆ next

next_t sysio::pending_snapshot::next

Definition at line 172 of file producer_plugin.cpp.

◆ pending_path

std::string sysio::pending_snapshot::pending_path

Definition at line 173 of file producer_plugin.cpp.


The documentation for this class was generated from the following file: