-
Notifications
You must be signed in to change notification settings - Fork 228
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: move network protocol related variables to SupportProtocols #2096
Conversation
9e4ce2a
to
af7c5b2
Compare
51a4456
to
6338eae
Compare
6338eae
to
63a699b
Compare
@@ -11,6 +11,9 @@ use log::info; | |||
|
|||
pub struct InvalidLocatorSize; | |||
|
|||
// test same value as ckb_sync::MAX_LOCATOR_SIZE; | |||
const MAX_LOCATOR_SIZE: usize = 101; | |||
|
|||
impl Spec for InvalidLocatorSize { |
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.
Line 53 in 63a699b
pub const MAX_LOCATOR_SIZE: usize = 101; |
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.
This refractory does not affect MAX_LOCATOR_SIZE
, it should not be defined twice. remain unchanged.
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.
This PR want to remove the dependence of ckb-sync
crate in the integration test, 3 constants are copied to test code: RETRY_ASK_TX_TIMEOUT_INCREASE / BLOCK_DOWNLOAD_TIMEOUT / MAX_LOCATOR_SIZE, we may move them and more shared constants to a new crate (ckb-constants), and change ckb-sync
and integration test to use this new crate in the future PR.
I prefer to re-define it in test code regarding this PR, let's keep changes to a minimum.
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.
I insist on this should remain unchanged, since this PR does not move it.
I think this is the so-called minimum change.
63a699b
to
a44c04a
Compare
OK, I have reverted related change and will create a new PR for integration-test change, please review again, thanks. |
a44c04a
to
9af130b
Compare
}; | ||
use tokio_util::codec::length_delimited; | ||
|
||
pub enum SupportProtocols { |
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.
FYI. SupportProtocols
is just like a "constants wrapper", which wraps the protocols and their contributions. It seems that the protocols and contributions are pre-defined. I think the plain style would be more intuitive(define as constants):
pub const PING_PROTOCOL_NAME = "ping";
pub const PING_SUPPORTED_VERSIONS = vec!["1"];
9af130b
to
dcdb45d
Compare
ping @zhangsoledad |
dcdb45d
to
a076992
Compare
@doitian @zhangsoledad rebased this PR, please review again |
bors r=doitian,zhangsoledad |
Build succeeded: |
To eliminate dependence of
ckb-sync
crate, this PR refactored network protocol related variables and move them to a new enum:SupportProtocols