Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/lexnv/stable-connections' into l…
Browse files Browse the repository at this point in the history
…exnv/holistic-litep2p-test
  • Loading branch information
lexnv committed Oct 3, 2024
2 parents c3491ff + 7ff145a commit 58b7bf7
Show file tree
Hide file tree
Showing 2 changed files with 583 additions and 118 deletions.
9 changes: 9 additions & 0 deletions src/protocol/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ impl ConnectionHandle {
}
}

/// Try to upgrade the connection to active state.
pub fn try_open(&mut self) {
if let ConnectionType::Inactive(inactive) = &self.connection {
if let Some(active) = inactive.upgrade() {
self.connection = ConnectionType::Active(active);
}
}
}

/// Attempt to acquire permit which will keep the connection open for indefinite time.
pub fn try_get_permit(&self) -> Option<Permit> {
match &self.connection {
Expand Down
Loading

0 comments on commit 58b7bf7

Please sign in to comment.