Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lightning-block-sync/src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ impl RestClient {
{
let host = format!("{}:{}", self.endpoint.host(), self.endpoint.port());
let uri = format!("{}/{}", self.endpoint.path().trim_end_matches("/"), resource_path);
let mut client = if let Some(client) = self.client.lock().unwrap().take() {
let reserved_client = self.client.lock().unwrap().take();
Copy link
Contributor

Choose a reason for hiding this comment

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

Want to note that it's a bit weird this is race-y as we'd create and drop unnecessary HTTPClients for parallel calls, but this is pre-existing anyways.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I mean except for the extra memory usage or too-many-parallel-calls it doesn't really matter. Caching the TCP socket is nice, but certainly not a requirement for things to work.

let mut client = if let Some(client) = reserved_client {
client
} else {
HttpClient::connect(&self.endpoint)?
Expand Down
3 changes: 2 additions & 1 deletion lightning-block-sync/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl RpcClient {
"id": &self.id.fetch_add(1, Ordering::AcqRel).to_string()
});

let mut client = if let Some(client) = self.client.lock().unwrap().take() {
let reserved_client = self.client.lock().unwrap().take();
let mut client = if let Some(client) = reserved_client {
client
} else {
HttpClient::connect(&self.endpoint)?
Expand Down