Skip to content
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

Connection Manager enhancements #371

Merged
merged 9 commits into from Dec 13, 2019

Conversation

RyanLassigBanks
Copy link
Contributor

@RyanLassigBanks RyanLassigBanks commented Dec 5, 2019

  • Replace crossbeam with standard library channels
  • Remove locks around connection state
  • Move the heartbeat monitor into its own module
  • Add remove connection to connection manager

agunde406
agunde406 previously approved these changes Dec 6, 2019
agunde406
agunde406 previously approved these changes Dec 9, 2019
Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Heartbeat monitor and connection manager no longer
share ConnectionState. Heartbeat messages are now sent
from the connection manager thread and requested by the
heartbeat monitor instead of the heartbeat monitor sending
them directly.

Signed-off-by: Ryan Banks <rbanks@bitwise.io>
libsplinter/src/network/connection_manager/mod.rs Outdated Show resolved Hide resolved
ConnectionManagerError::HeartbeatError("cannot create NetworkHeartbeat message".to_string())
})?;
fn create_heartbeat() -> Vec<u8> {
let heartbeat = NetworkHeartbeat::new().write_to_bytes().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is panicking here desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe @peterschwarz mentioned this a few times, but write_to_bytes only fails if the system completely runs out of memory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deviates from the way we handle these errors everywhere else in splinter, so I'm not sure I 100% agree with this change from a consistency perspective, but I won't block the PR because of that. However, this should be changed to an expect to provide an error message.

@RyanLassigBanks RyanLassigBanks dismissed peterschwarz’s stale review December 13, 2019 15:47

Peter is OOO until Tuesday, and I'd like to try to get his merged before then.

@@ -62,7 +61,13 @@ impl ConnectionManager {

pub fn start(&mut self) -> Result<Connector, ConnectionManagerError> {
let (sender, recv) = sync_channel(CHANNEL_CAPACITY);
let mut state = self.connection_state.clone();
let mut state = if let Some(state) = self.connection_state.take() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if let ... else ... could be simplified by using self.connection_state.take().ok_or_else(|| Err(...))?

ConnectionManagerError::HeartbeatError("cannot create NetworkHeartbeat message".to_string())
})?;
fn create_heartbeat() -> Vec<u8> {
let heartbeat = NetworkHeartbeat::new().write_to_bytes().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deviates from the way we handle these errors everywhere else in splinter, so I'm not sure I 100% agree with this change from a consistency perspective, but I won't block the PR because of that. However, this should be changed to an expect to provide an error message.

ltseeley
ltseeley previously approved these changes Dec 13, 2019
ConnectionState needs to be passed to the connection_manager thread in
`ConnectionManager::start`. ConnectionState can't be clonable because
Transports aren't clonable, so in order to pass it to the thread it will
be temporarily stored as an option.

Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Fixing clippy errors that were introduced when the connection-manager
feature was initially added

Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Change test ports from 8080 to 3030 to avoid conflicts with other tests
that use port 8080.

Signed-off-by: Ryan Banks <rbanks@bitwise.io>
Signed-off-by: Ryan Banks <rbanks@bitwise.io>
@RyanLassigBanks RyanLassigBanks merged commit 896b63e into Cargill:master Dec 13, 2019
@RyanLassigBanks RyanLassigBanks deleted the peering-manager-mkIV branch April 21, 2020 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants