-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(relay): split compact block execute code, more readable #3244
Merged
bors
merged 1 commit into
nervosnetwork:develop
from
chanhsu001:factor_compact_block_process
Dec 29, 2021
Merged
refactor(relay): split compact block execute code, more readable #3244
bors
merged 1 commit into
nervosnetwork:develop
from
chanhsu001:factor_compact_block_process
Dec 29, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chanhsu001
requested review from
quake,
doitian,
keroro520,
zhangsoledad,
driftluo and
yangby-cryptape
December 20, 2021 15:51
driftluo
reviewed
Dec 21, 2021
driftluo
reviewed
Dec 21, 2021
…extual and contextual check
keroro520
approved these changes
Dec 21, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Comment on lines
+314
to
+333
pending_compact_blocks | ||
.entry(block_hash.clone()) | ||
.or_insert_with(|| (compact_block, HashMap::default(), unix_time_as_millis())) | ||
.1 | ||
.insert(peer, (missing_transactions.clone(), missing_uncles.clone())); | ||
|
||
let content = packed::GetBlockTransactions::new_builder() | ||
.block_hash(block_hash) | ||
.indexes(missing_transactions.pack()) | ||
.uncle_indexes(missing_uncles.pack()) | ||
.build(); | ||
let message = packed::RelayMessage::new_builder().set(content).build(); | ||
let sending = send_message_to(nc.as_ref(), peer, &message); | ||
if !sending.is_ok() { | ||
ckb_logger::warn_target!( | ||
crate::LOG_TARGET_RELAY, | ||
"ignore the sending message error, error: {}", | ||
sending | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let content = packed::GetBlockTransactions::new_builder()
.block_hash(block_hash)
.indexes(missing_transactions.pack())
.uncle_indexes(missing_uncles.pack())
.build();
let message = packed::RelayMessage::new_builder().set(content).build();
match send_message_to(nc.as_ref(), peer, &message) {
Ok(_) => {
pending_compact_blocks
.entry(block_hash.clone())
.or_insert_with(|| (compact_block, HashMap::default(), unix_time_as_millis()))
.1
.insert(peer, (missing_transactions, missing_uncles));
}
Err(err) => {
ckb_logger::warn_target!(
crate::LOG_TARGET_RELAY,
"ignore the sending message error, error: {:?}",
err
);
}
}
driftluo
approved these changes
Dec 29, 2021
bors merge=driftluo,keroro520 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
non_contextual_check() and contextual_check() function
after failed to rebuild whole block, found missing or collided transactions.
i still not sure about function comments, please help.
Problem Summary:
the execute() function is about 250 lines, and contains some of pre-checks, and post-process after re-build block failed.
i tried to make it more readable and hope you guys provide suggestions about how to make refactor better.
What is changed and how it works?
What's Changed:
only split bunch of codes into 3 functions, not mean to change logic and behavior
I've run test and integration-test and passed ("Refactor Flow" should include these tests).
Related changes
Check List
Tests
Release note