Skip to content

Commit 0cefda7

Browse files
authored
Merge pull request #628 from evoskuil/master
Refactor log dumps, add config dump.
2 parents d67369c + 610cd11 commit 0cefda7

9 files changed

Lines changed: 48 additions & 44 deletions

console/executor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ class executor
6464
void dump_version() const;
6565
void dump_hardware() const;
6666
void dump_options() const;
67+
void dump_configuration() const;
6768
void dump_body_sizes() const;
6869
void dump_records() const;
6970
void dump_buckets() const;
7071
void dump_progress() const;
7172
void dump_collisions() const;
72-
void dump_sizes() const;
7373

7474
// Store functions.
7575
bool check_store_path(bool create=false) const;

console/executor_commands.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const std::string executor::name_{ "bs" };
3333
bool executor::do_help()
3434
{
3535
log_.stop();
36-
printer help(metadata_.load_options(), name_, BS_INFORMATION_MESSAGE);
36+
printer help(metadata_.load_options(), name_, BS_DETAIL_MESSAGE);
3737
help.initialize();
3838
help.commandline(output_);
3939
return true;
@@ -124,7 +124,14 @@ bool executor::do_information()
124124
!open_store())
125125
return false;
126126

127-
dump_sizes();
127+
dump_body_sizes();
128+
dump_records();
129+
dump_buckets();
130+
dump_collisions();
131+
132+
// This one can take a few seconds on cold iron.
133+
logger(BS_INFORMATION_PROGRESS_START);
134+
dump_progress();
128135
return close_store();
129136
}
130137

console/executor_dumps.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ void executor::dump_options() const
7575
logger(format("[v]erbose...... " BS_LOG_TABLE) % levels::verbose_defined % toggle_.at(levels::verbose));
7676
}
7777

78+
// query_ not valid unless store is loaded.
79+
void executor::dump_configuration() const
80+
{
81+
logger(format(BS_INFORMATION_START)
82+
% store_.is_dirty()
83+
% query_.interval_span());
84+
}
85+
7886
void executor::dump_body_sizes() const
7987
{
80-
logger(format(BS_MEASURE_SIZES) %
88+
logger(format(BS_INFORMATION_SIZES) %
8189
query_.header_body_size() %
8290
query_.txs_body_size() %
8391
query_.tx_body_size() %
@@ -100,7 +108,7 @@ void executor::dump_body_sizes() const
100108

101109
void executor::dump_records() const
102110
{
103-
logger(format(BS_MEASURE_RECORDS) %
111+
logger(format(BS_INFORMATION_RECORDS) %
104112
query_.header_records() %
105113
query_.tx_records() %
106114
query_.point_records() %
@@ -116,7 +124,7 @@ void executor::dump_records() const
116124

117125
void executor::dump_buckets() const
118126
{
119-
logger(format(BS_MEASURE_BUCKETS) %
127+
logger(format(BS_INFORMATION_BUCKETS) %
120128
query_.header_buckets() %
121129
query_.txs_buckets() %
122130
query_.tx_buckets() %
@@ -133,7 +141,7 @@ void executor::dump_buckets() const
133141

134142
void executor::dump_collisions() const
135143
{
136-
logger(format(BS_MEASURE_COLLISION_RATES) %
144+
logger(format(BS_INFORMATION_COLLISION_RATES) %
137145
(to_double(query_.header_records()) / query_.header_buckets()) %
138146
(to_double(query_.tx_records()) / query_.tx_buckets()) %
139147
(to_double(query_.point_records()) / query_.point_buckets()) %
@@ -147,7 +155,7 @@ void executor::dump_progress() const
147155
{
148156
using namespace system;
149157

150-
logger(format(BS_MEASURE_PROGRESS) %
158+
logger(format(BS_INFORMATION_PROGRESS) %
151159
query_.get_fork() %
152160
query_.get_top_confirmed() %
153161
encode_hash(query_.get_top_confirmed_hash()) %
@@ -159,18 +167,5 @@ void executor::dump_progress() const
159167
query_.get_candidate_size());
160168
}
161169

162-
// file and logical sizes.
163-
void executor::dump_sizes() const
164-
{
165-
dump_body_sizes();
166-
dump_records();
167-
dump_buckets();
168-
dump_collisions();
169-
170-
// This one can take a few seconds on cold iron.
171-
logger(BS_MEASURE_PROGRESS_START);
172-
dump_progress();
173-
}
174-
175170
} // namespace server
176171
} // namespace libbitcoin

console/executor_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ void executor::do_resume()
176176
// [i]nfo
177177
void executor::do_info() const
178178
{
179+
dump_configuration();
179180
dump_body_sizes();
180181
dump_records();
181182
dump_buckets();
182183
dump_collisions();
183-
////dump_progress();
184184
}
185185

186186
// [m]enu

console/executor_runner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ bool executor::do_run()
140140
dump_body_sizes();
141141
dump_records();
142142
dump_buckets();
143-
////logger(BS_MEASURE_PROGRESS_START);
143+
////logger(BS_INFORMATION_PROGRESS_START);
144144
////dump_progress();
145145

146146
// Stopped by stopper.
@@ -173,7 +173,7 @@ bool executor::do_run()
173173
// Sizes and records change, buckets don't.
174174
dump_body_sizes();
175175
dump_records();
176-
////logger(BS_MEASURE_PROGRESS_START);
176+
////logger(BS_INFORMATION_PROGRESS_START);
177177
////dump_progress();
178178

179179
if (!close_store(true))

console/executor_scans.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void executor::scan_flags() const
7676
// input and output table slab counts.
7777
void executor::scan_slabs() const
7878
{
79-
logger(BS_MEASURE_SLABS);
79+
logger(BS_INFORMATION_SLABS);
8080
logger(BS_OPERATION_INTERRUPT);
8181
database::tx_link::integer link{};
8282
size_t inputs{}, outputs{};
@@ -92,14 +92,14 @@ void executor::scan_slabs() const
9292
inputs += puts.first;
9393
outputs += puts.second;
9494
if (is_zero(link % frequency))
95-
logger(format(BS_MEASURE_SLABS_ROW) % link % inputs % outputs);
95+
logger(format(BS_INFORMATION_SLABS_ROW) % link % inputs % outputs);
9696
}
9797

9898
if (canceled())
9999
logger(BS_OPERATION_CANCELED);
100100

101101
const auto span = duration_cast<seconds>(logger::now() - start);
102-
logger(format(BS_MEASURE_STOP) % inputs % outputs % span.count());
102+
logger(format(BS_INFORMATION_STOP) % inputs % outputs % span.count());
103103
}
104104

105105
// hashmap bucket fill rates.

console/executor_store.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ code executor::open_store_coded(bool details)
113113
return ec;
114114
}
115115

116-
logger(store_.is_dirty() ? BS_DATABASE_STARTED_DIRTY : BS_DATABASE_STARTED);
116+
logger(BS_DATABASE_STARTED);
117117
return error::success;
118118
}
119119

console/localize.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// --settings
3333
#define BS_SETTINGS_MESSAGE \
3434
"These are the configuration settings that can be set."
35-
#define BS_INFORMATION_MESSAGE \
35+
#define BS_DETAIL_MESSAGE \
3636
"Runs a full bitcoin node server."
3737

3838
// --initchain
@@ -67,8 +67,12 @@
6767
#define BS_RESTORE_COMPLETE \
6868
"Restored the database in %1% secs."
6969

70-
// --measure
71-
#define BS_MEASURE_SIZES \
70+
// --information
71+
#define BS_INFORMATION_START \
72+
"Configuration...\n" \
73+
" dirty :%1%\n" \
74+
" interval :%2%"
75+
#define BS_INFORMATION_SIZES \
7276
"Body sizes...\n" \
7377
" header :%1%\n" \
7478
" txs :%2%\n" \
@@ -88,7 +92,7 @@
8892
" filter_bk :%16%\n" \
8993
" filter_tx :%17%\n" \
9094
" address :%18%"
91-
#define BS_MEASURE_RECORDS \
95+
#define BS_INFORMATION_RECORDS \
9296
"Table records...\n" \
9397
" header :%1%\n" \
9498
" tx :%2%\n" \
@@ -101,15 +105,15 @@
101105
" strong_tx :%9%\n" \
102106
" filter_bk :%10%\n" \
103107
" address :%11%"
104-
#define BS_MEASURE_SLABS \
108+
#define BS_INFORMATION_SLABS \
105109
"Table slabs..."
106-
#define BS_MEASURE_SLABS_ROW \
110+
#define BS_INFORMATION_SLABS_ROW \
107111
" @tx :%1%, inputs:%2%, outputs:%3%"
108-
#define BS_MEASURE_STOP \
112+
#define BS_INFORMATION_STOP \
109113
" input :%1%\n" \
110114
" output :%2%\n" \
111115
" seconds :%3%"
112-
#define BS_MEASURE_BUCKETS \
116+
#define BS_INFORMATION_BUCKETS \
113117
"Head buckets...\n" \
114118
" header :%1%\n" \
115119
" txs :%2%\n" \
@@ -123,17 +127,17 @@
123127
" filter_bk :%10%\n" \
124128
" filter_tx :%11%\n" \
125129
" address :%12%"
126-
#define BS_MEASURE_COLLISION_RATES \
130+
#define BS_INFORMATION_COLLISION_RATES \
127131
"Collision rates...\n" \
128132
" header :%1%\n" \
129133
" tx :%2%\n" \
130134
" point :%3%\n" \
131135
" strong_tx :%4%\n" \
132136
" valid_tx :%5%\n" \
133137
" address :%6%"
134-
#define BS_MEASURE_PROGRESS_START \
138+
#define BS_INFORMATION_PROGRESS_START \
135139
"Thinking..."
136-
#define BS_MEASURE_PROGRESS \
140+
#define BS_INFORMATION_PROGRESS \
137141
"Chain progress...\n" \
138142
" fork pt :%1%\n" \
139143
" top conf :%2%:%3%\n" \
@@ -171,9 +175,7 @@
171175
#define BS_NODE_INTERRUPT \
172176
"Press CTRL-C to stop the node."
173177
#define BS_DATABASE_STARTED \
174-
"Database is started (clean)."
175-
#define BS_DATABASE_STARTED_DIRTY \
176-
"Database is started (dirty)."
178+
"Database is started."
177179
#define BS_NETWORK_STARTING \
178180
"Please wait while network is starting..."
179181
#define BS_NODE_START_FAIL \

src/protocols/protocol_electrum.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void protocol_electrum::handle_blockchain_block_headers(const code& ec,
230230
{
231231
object_t
232232
{
233-
{ "count", quantity },
233+
{ "count", uint64_t{ quantity } },
234234
{ "headers", std::move(headers) },
235235
{ "max", maximum }
236236
}
@@ -296,7 +296,7 @@ void protocol_electrum::handle_blockchain_headers_subscribe(const code& ec,
296296
{
297297
object_t
298298
{
299-
{ "height", top },
299+
{ "height", uint64_t{ top } },
300300
{ "hex", to_hex(*header, chain::header::serialized_size()) }
301301
}
302302
}, 256, BIND(complete, _1));

0 commit comments

Comments
 (0)