78 {
81 const auto end = block_logger.read_head();
82 SYS_ASSERT( end, block_log_exception,
"No blocks found in block log" );
83 SYS_ASSERT( end->block_num() > 1, block_log_exception,
"Only one block found in block log" );
84
85
86 ilog(
"existing block log contains block num ${first} through block num ${n}",
87 ("first",block_logger.first_block_num())("n",end->block_num()) );
90 }
91
94 ilog(
"opening fork_db" );
96
98 const flat_set<digest_type>& cur_features,
100 );
101
102 fork_db_branch = fork_db.fetch_branch( fork_db.head()->id );
103 if( fork_db_branch.empty() ) {
104 elog(
"no blocks available in reversible block database: only block_log blocks are available" );
105 } else {
106 auto first = fork_db_branch.rbegin();
107 auto last = fork_db_branch.rend() - 1;
108 ilog(
"existing reversible fork_db block num ${first} through block num ${last} ",
109 ("first", (*first)->block_num)( "last", (*last)->block_num ) );
110 SYS_ASSERT( end->block_num() + 1 == (*first)->block_num, block_log_exception,
111 "fork_db does not start at end of block log" );
112 }
113 }
114
115 std::ofstream output_blocks;
116 std::ostream* out;
118 output_blocks.open(
output_file.generic_string().c_str());
119 if (output_blocks.fail()) {
120 std::ostringstream
ss;
121 ss <<
"Unable to open file '" <<
output_file.string() <<
"'";
122 throw std::runtime_error(
ss.str());
123 }
124 out = &output_blocks;
125 }
126 else
127 out = &std::cout;
128
130 *out << "[";
137 pretty_output,
138 [](
account_name n ) {
return std::optional<abi_serializer>(); },
140 const auto block_id =
next->calculate_id();
141 const uint32_t ref_block_prefix = block_id._hash[1];
143 (
"block_num",
next->block_num())
144 ("id", block_id)
145 ("ref_block_prefix", ref_block_prefix)
150 else
152 };
153 bool contains_obj = false;
154 while((block_num <=
last_block) && (next = block_logger.read_block_by_num( block_num ))) {
156 *out << ",";
157 print_block(next);
158 ++block_num;
159 contains_obj = true;
160 }
161
162 if( !fork_db_branch.empty() ) {
163 for(
auto bitr = fork_db_branch.rbegin(); bitr != fork_db_branch.rend() && block_num <=
last_block; ++bitr ) {
165 *out << ",";
166 auto next = (*bitr)->block;
167 print_block(next);
168 ++block_num;
169 contains_obj = true;
170 }
171 }
172
174 *out << "]";
175 rt.report();
176}
static string to_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
static string to_pretty_string(const variant &v, const yield_function_t &yield, const output_formatting format=output_formatting::stringify_large_ints_and_doubles)
An order-preserving dictionary of variants.
static constexpr time_point maximum()
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
variant_object & get_object()
manages light-weight state for all potential unconfirmed forks
static const Segment ss(Segment::ss)
bool exists(const path &p)
constexpr microseconds seconds(int64_t s)
deque< block_state_ptr > branch_type
std::shared_ptr< signed_block > signed_block_ptr
uint32_t next(octet_iterator &it, octet_iterator end)
static yield_function_t create_yield_function(const fc::microseconds &max_serialization_time)
static void to_variant(const T &o, fc::variant &vo, Resolver resolver, const yield_function_t &yield)
namespace sysio::chain::impl
Immutable except for fc::from_variant.