Skip to content

Commit a00ba13

Browse files
authored
Merge pull request #4250 from EthanYuan/text-optimize
chore: CKB Text Optimization
2 parents 98a583d + b8c2698 commit a00ba13

File tree

78 files changed

+407
-381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+407
-381
lines changed

block-filter/src/filter.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ impl BlockFilter {
7878
let tip_header = snapshot.get_tip_header().expect("tip stored");
7979
let start_number = match snapshot.get_latest_built_filter_data_block_hash() {
8080
Some(block_hash) => {
81-
debug!("Latest built block hash {:#x}", block_hash);
81+
debug!("Hash of the latest created block {:#x}", block_hash);
8282
if snapshot.is_main_chain(&block_hash) {
8383
let header = snapshot
8484
.get_block_header(&block_hash)
8585
.expect("header stored");
8686
debug!(
87-
"Latest built block is main chain, start from {}",
87+
"Latest created block on the main chain, starting from {}",
8888
header.number() + 1
8989
);
9090
header.number() + 1
@@ -99,7 +99,7 @@ impl BlockFilter {
9999
.expect("parent header stored");
100100
}
101101
debug!(
102-
"Latest built filter data block is fork chain, start from {}",
102+
"Block with the latest built filter data on the forked chain, starting from {}",
103103
header.number()
104104
);
105105
header.number()
@@ -126,7 +126,7 @@ impl BlockFilter {
126126
let db = self.shared.store();
127127
if db.get_block_filter_hash(&header.hash()).is_some() {
128128
debug!(
129-
"Filter data for block {:#x} already exist, skip build",
129+
"Filter data for block {:#x} already exists. Skip building.",
130130
header.hash()
131131
);
132132
return;
@@ -144,8 +144,8 @@ impl BlockFilter {
144144
let (filter_data, missing_out_points) = build_filter_data(provider, &transactions);
145145
for out_point in missing_out_points {
146146
warn!(
147-
"Can't find input cell for out_point: {:#x}, \
148-
should only happen in test, skip adding to filter",
147+
"Unable to find the input cell for the out_point: {:#x}, \
148+
Skip adding it to the filter. This should only happen during testing.",
149149
out_point
150150
);
151151
}

chain/src/chain.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,13 @@ impl ChainService {
345345
let block_number = block.number();
346346
let block_hash = block.hash();
347347

348-
debug!("begin processing block: {}-{}", block_number, block_hash);
348+
debug!("Begin processing block: {}-{}", block_number, block_hash);
349349
if block_number < 1 {
350-
warn!("receive 0 number block: 0-{}", block_hash);
350+
warn!("Receive 0 number block: 0-{}", block_hash);
351351
}
352352

353353
self.insert_block(block, switch).map(|ret| {
354-
debug!("finish processing block");
354+
debug!("Finish processing block");
355355
ret
356356
})
357357
}
@@ -444,7 +444,7 @@ impl ChainService {
444444

445445
let current_total_difficulty = shared_snapshot.total_difficulty().to_owned();
446446
debug!(
447-
"difficulty current = {:#x}, cannon = {:#x}",
447+
"Current difficulty = {:#x}, cannon = {:#x}",
448448
current_total_difficulty, cannon_total_difficulty,
449449
);
450450

@@ -453,7 +453,7 @@ impl ChainService {
453453

454454
if new_best_block {
455455
debug!(
456-
"new best block found: {} => {:#x}, difficulty diff = {:#x}",
456+
"Newly found best block : {} => {:#x}, difficulty diff = {:#x}",
457457
block.header().number(),
458458
block.header().hash(),
459459
&cannon_total_difficulty - &current_total_difficulty
@@ -506,7 +506,7 @@ impl ChainService {
506506
fork.detached_proposal_id().clone(),
507507
new_snapshot,
508508
) {
509-
error!("notify update_tx_pool_for_reorg error {}", e);
509+
error!("Notify update_tx_pool_for_reorg error {}", e);
510510
}
511511
}
512512

@@ -535,7 +535,7 @@ impl ChainService {
535535
if tx_pool_controller.service_started() {
536536
let block_ref: &BlockView = &block;
537537
if let Err(e) = tx_pool_controller.notify_new_uncle(block_ref.as_uncle()) {
538-
error!("notify new_uncle error {}", e);
538+
error!("Notify new_uncle error {}", e);
539539
}
540540
}
541541
}
@@ -576,7 +576,7 @@ impl ChainService {
576576
let proposal_start =
577577
cmp::max(1, (new_tip + 1).saturating_sub(proposal_window.farthest()));
578578

579-
debug!("reload_proposal_table [{}, {}]", proposal_start, common);
579+
debug!("Reload_proposal_table [{}, {}]", proposal_start, common);
580580
for bn in proposal_start..=common {
581581
let blk = self
582582
.shared
@@ -930,13 +930,13 @@ impl ChainService {
930930

931931
fn print_error(&self, b: &BlockView, err: &Error) {
932932
error!(
933-
"block verify error, block number: {}, hash: {}, error: {:?}",
933+
"Block verify error. Block number: {}, hash: {}, error: {:?}",
934934
b.header().number(),
935935
b.header().hash(),
936936
err
937937
);
938938
if log_enabled!(ckb_logger::Level::Trace) {
939-
trace!("block {}", b.data());
939+
trace!("Block {}", b.data());
940940
}
941941
}
942942

ckb-bin/src/helper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn deadlock_detection() {
1313
use ckb_util::parking_lot::deadlock;
1414
use std::{thread, time::Duration};
1515

16-
info!("deadlock_detection enable");
16+
info!("deadlock_detection enabled");
1717
let dead_lock_jh = thread::spawn({
1818
let ticker = ckb_channel::tick(Duration::from_secs(10));
1919
let stop_rx = new_crossbeam_exit_rx();

ckb-bin/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ pub fn run_app(version: Version) -> Result<(), ExitCode> {
8080
handle.drop_guard();
8181

8282
tokio::task::block_in_place(|| {
83-
info!("waiting all tokio tasks exit...");
83+
info!("Waiting for all tokio tasks to exit...");
8484
handle_stop_rx.blocking_recv();
85-
info!("all tokio tasks and threads have exited, ckb shutdown");
85+
info!("All tokio tasks and threads have exited. CKB shutdown");
8686
});
8787
}
8888

ckb-bin/src/subcommand/init.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
2626
}
2727

2828
if args.chain != "dev" && !args.customize_spec.is_unset() {
29-
eprintln!("Customizing consensus parameters for chain spec only works for dev chains.");
29+
eprintln!("Customizing consensus parameters for chain spec; only works for dev chains.");
3030
return Err(ExitCode::Failure);
3131
}
3232

3333
let exported = Resource::exported_in(&args.root_dir);
3434
if !args.force && exported {
35-
eprintln!("Config files already exist, use --force to overwrite.");
35+
eprintln!("Config files already exist; use --force to overwrite.");
3636

3737
if args.interactive {
3838
let input = prompt("Overwrite config files now? ");
@@ -103,15 +103,15 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
103103
);
104104
} else if *default_code_hash != *hash {
105105
eprintln!(
106-
"WARN: the default secp256k1 code hash is `{default_code_hash}`, you are using `{hash}`.\n\
107-
It will require `ckb run --ba-advanced` to enable this block assembler"
106+
"WARN: Use the default secp256k1 code hash `{default_code_hash}` rather than `{hash}`.\n\
107+
To enable this block assembler, use `ckb run --ba-advanced`."
108108
);
109109
} else if args.block_assembler_args.len() != 1
110110
|| args.block_assembler_args[0].len() != SECP256K1_BLAKE160_SIGHASH_ALL_ARG_LEN
111111
{
112112
eprintln!(
113-
"WARN: the block assembler arg is not a valid secp256k1 pubkey hash.\n\
114-
It will require `ckb run --ba-advanced` to enable this block assembler"
113+
"WARN: The block assembler arg is not a valid secp256k1 pubkey hash.\n\
114+
To enable this block assembler, use `ckb run --ba-advanced`. "
115115
);
116116
}
117117
}
@@ -129,7 +129,7 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
129129
)
130130
}
131131
None => {
132-
eprintln!("WARN: mining feature is disabled because of lacking the block assembler config options");
132+
eprintln!("WARN: Mining feature is disabled because of the lack of the block assembler config options.");
133133
format!(
134134
"# secp256k1_blake160_sighash_all example:\n\
135135
# [block_assembler]\n\
@@ -175,7 +175,7 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
175175
let target_file = specs_dir.join(format!("{}.toml", args.chain));
176176

177177
if spec_file == "-" {
178-
println!("create specs/{}.toml from stdin", args.chain);
178+
println!("Create specs/{}.toml from stdin", args.chain);
179179
let mut encoded_content = String::new();
180180
io::stdin().read_to_string(&mut encoded_content)?;
181181
let base64_config =
@@ -185,30 +185,32 @@ pub fn init(args: InitArgs) -> Result<(), ExitCode> {
185185
let spec_content = base64_engine.encode(encoded_content.trim());
186186
fs::write(target_file, spec_content)?;
187187
} else {
188-
println!("cp {} specs/{}.toml", spec_file, args.chain);
188+
println!("copy {} to specs/{}.toml", spec_file, args.chain);
189189
fs::copy(spec_file, target_file)?;
190190
}
191191
} else if args.chain == "dev" {
192-
println!("create {SPEC_DEV_FILE_NAME}");
192+
println!("Create {SPEC_DEV_FILE_NAME}");
193193
let bundled = Resource::bundled(SPEC_DEV_FILE_NAME.to_string());
194194
let kvs = args.customize_spec.key_value_pairs();
195195
let context_spec =
196196
TemplateContext::new("customize", kvs.iter().map(|(k, v)| (*k, v.as_str())));
197197
bundled.export(&context_spec, &args.root_dir)?;
198198
}
199199

200-
println!("create {CKB_CONFIG_FILE_NAME}");
200+
println!("Create {CKB_CONFIG_FILE_NAME}");
201201
Resource::bundled_ckb_config().export(&context, &args.root_dir)?;
202-
println!("create {MINER_CONFIG_FILE_NAME}");
202+
println!("Create {MINER_CONFIG_FILE_NAME}");
203203
Resource::bundled_miner_config().export(&context, &args.root_dir)?;
204-
println!("create {DB_OPTIONS_FILE_NAME}");
204+
println!("Create {DB_OPTIONS_FILE_NAME}");
205205
Resource::bundled_db_options().export(&context, &args.root_dir)?;
206206

207207
let genesis_hash = AppConfig::load_for_subcommand(args.root_dir, cli::CMD_INIT)?
208208
.chain_spec()?
209209
.build_genesis()
210210
.map_err(|err| {
211-
eprintln!("couldn't build genesis from generated chain spec, since {err}");
211+
eprintln!(
212+
"Couldn't build the genesis block from the generated chain spec, since {err}"
213+
);
212214
ExitCode::Failure
213215
})?
214216
.hash();

ckb-bin/src/subcommand/migrate.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ pub fn migrate(args: MigrateArgs) -> Result<(), ExitCode> {
1010

1111
{
1212
let read_only_db = migrate.open_read_only_db().map_err(|e| {
13-
eprintln!("migrate error {e}");
13+
eprintln!("Migration error {e}");
1414
ExitCode::Failure
1515
})?;
1616

1717
if let Some(db) = read_only_db {
1818
let db_status = migrate.check(&db);
1919
if matches!(db_status, Ordering::Greater) {
2020
eprintln!(
21-
"The database is created by a higher version CKB executable binary, \n\
22-
so that the current CKB executable binary couldn't open this database.\n\
21+
"The database was created by a higher version CKB executable binary \n\
22+
and cannot be opened by the current binary.\n\
2323
Please download the latest CKB executable binary."
2424
);
2525
return Err(ExitCode::Failure);
@@ -50,7 +50,7 @@ pub fn migrate(args: MigrateArgs) -> Result<(), ExitCode> {
5050
> ",
5151
);
5252
if input.trim().to_lowercase() != "yes" {
53-
eprintln!("The migration was declined since the user didn't confirm.");
53+
eprintln!("Migration was declined since the user didn't confirm.");
5454
return Err(ExitCode::Failure);
5555
}
5656
} else {
@@ -62,7 +62,7 @@ pub fn migrate(args: MigrateArgs) -> Result<(), ExitCode> {
6262
}
6363

6464
let bulk_load_db_db = migrate.open_bulk_load_db().map_err(|e| {
65-
eprintln!("migrate error {e}");
65+
eprintln!("Migration error {e}");
6666
ExitCode::Failure
6767
})?;
6868

ckb-bin/src/subcommand/replay.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ pub fn replay(args: ReplayArgs, async_handle: Handle) -> Result<(), ExitCode> {
2525

2626
if !args.tmp_target.is_dir() {
2727
eprintln!(
28-
"replay error: {:?}",
28+
"Replay error: {:?}",
2929
"The specified path does not exist or not directory"
3030
);
3131
return Err(ExitCode::Failure);
3232
}
3333
let tmp_db_dir = tempfile::tempdir_in(args.tmp_target).map_err(|err| {
34-
eprintln!("replay error: {err:?}");
34+
eprintln!("Replay error: {err:?}");
3535
ExitCode::Failure
3636
})?;
3737
{
@@ -58,7 +58,7 @@ pub fn replay(args: ReplayArgs, async_handle: Handle) -> Result<(), ExitCode> {
5858
}
5959
}
6060
tmp_db_dir.close().map_err(|err| {
61-
eprintln!("replay error: {err:?}");
61+
eprintln!("Replay error: {err:?}");
6262
ExitCode::Failure
6363
})?;
6464

@@ -72,7 +72,7 @@ fn profile(shared: Shared, mut chain: ChainService, from: Option<u64>, to: Optio
7272
.map(|v| std::cmp::min(v, tip_number))
7373
.unwrap_or(tip_number);
7474
process_range_block(&shared, &mut chain, 1..from);
75-
println!("start profiling, re-process blocks {from}..{to}:");
75+
println!("Start profiling; re-process blocks {from}..{to}:");
7676
let now = std::time::Instant::now();
7777
let tx_count = process_range_block(&shared, &mut chain, from..=to);
7878
let duration = std::time::Instant::now().saturating_duration_since(now);
@@ -136,7 +136,7 @@ fn sanity_check(shared: Shared, mut chain: ChainService, full_verification: bool
136136
let header = block.header();
137137
if let Err(e) = chain.process_block(Arc::new(block), switch) {
138138
eprintln!(
139-
"replay sanity-check error: {:?} at block({}-{})",
139+
"Replay sanity-check error: {:?} at block({}-{})",
140140
e,
141141
header.number(),
142142
header.hash(),
@@ -152,19 +152,19 @@ fn sanity_check(shared: Shared, mut chain: ChainService, full_verification: bool
152152

153153
if cursor != tip_header {
154154
eprintln!(
155-
"sanity-check break at block({}-{}), expect tip({}-{})",
155+
"Sanity-check break at block({}-{}); expect tip({}-{})",
156156
cursor.number(),
157157
cursor.hash(),
158158
tip_header.number(),
159159
tip_header.hash(),
160160
);
161161
} else {
162162
println!(
163-
"sanity-check pass, tip({}-{})",
163+
"Sanity-check pass, tip({}-{})",
164164
tip_header.number(),
165165
tip_header.hash()
166166
);
167167
}
168168

169-
println!("replay finishing, please wait...");
169+
println!("Finishing replay; please wait...");
170170
}

ckb-bin/src/subcommand/reset_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn reset_data(args: ResetDataArgs) -> Result<(), ExitCode> {
5050

5151
for dir in target_dirs.iter() {
5252
if dir.exists() {
53-
println!("deleting {}", dir.display());
53+
println!("Deleting {}", dir.display());
5454
if let Some(e) = fs::remove_dir_all(dir).err() {
5555
eprintln!("{e}");
5656
errors_count += 1;
@@ -60,7 +60,7 @@ pub fn reset_data(args: ResetDataArgs) -> Result<(), ExitCode> {
6060

6161
for file in target_files.iter() {
6262
if file.exists() {
63-
println!("deleting {}", file.display());
63+
println!("Deleting {}", file.display());
6464
if let Some(e) = fs::remove_file(file).err() {
6565
eprintln!("{e}");
6666
errors_count += 1;

db-migration/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ impl Migrations {
6262
}
6363
}
6464
};
65-
debug!("current database version [{}]", db_version);
65+
debug!("Current database version [{}]", db_version);
6666

6767
let latest_version = self
6868
.migrations
6969
.values()
7070
.last()
7171
.unwrap_or_else(|| panic!("should have at least one version"))
7272
.version();
73-
debug!("latest database version [{}]", latest_version);
73+
debug!("Latest database version [{}]", latest_version);
7474

7575
db_version.as_str().cmp(latest_version)
7676
}
@@ -176,8 +176,8 @@ impl Migrations {
176176
if m.version() < v.as_str() {
177177
error!(
178178
"Database downgrade detected. \
179-
The database schema version is newer than client schema version,\
180-
please upgrade to the newer version"
179+
The database schema version is more recent than the client schema version.\
180+
Please upgrade to the latest client version."
181181
);
182182
return Err(internal_error(
183183
"Database downgrade is not supported".to_string(),

error/src/internal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use thiserror::Error;
77

88
/// An error with no reason.
99
#[derive(Error, Debug, Clone, Copy)]
10-
#[error("no reason is provided")]
10+
#[error("No reason provided")]
1111
pub struct SilentError;
1212

1313
/// An error with only a string as the reason.

0 commit comments

Comments
 (0)