-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: limit concurrent HTTP requests (#16)
* fix: limit concurrent HTTP requests All HTTP requests made by this module are sent to the same delegate host. Browsers throttle the number of concurrent requests per hostname, right now it is 6 per host, which suffocates the use of delegate and blocking it from being used for preload or delegated peer routing. This change introduces task queues that limit the number of concurrent requests, making it safe to run in browser context. Optimizations: - preload calls via `refs` are known to take time, so we limit them to max two at a time - swarm.connect was the main offender (causing multiple requests to delegate), we now check if connection is already present and cache result for 1 minute removing most of redundant http requests - hostname of default delegate is changed Context: #12 Closes #12 * refactor: remove the need for swarm connect This removes all code that caused swarm connect calls from delegate to self. It was not needed: delegate is one of bootstrap nodes, so we are always connected to it. #12 (comment) * chore: remove unused dependencies We no longer need those (removed calls to swarm.connect) License: MIT Signed-off-by: Marcin Rataj <[email protected]>
- Loading branch information
Showing
4 changed files
with
38 additions
and
45 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,5 @@ typings/ | |
.env | ||
|
||
yarn.lock | ||
package-lock.json | ||
package-lock.json | ||
dist/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,10 @@ | |
"peer-id": "~0.13.1" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.1.1", | ||
"ipfs-http-client": "^33.1.0", | ||
"multiaddr": "^6.1.0" | ||
"multiaddr": "^6.1.0", | ||
"p-queue": "^6.1.0" | ||
}, | ||
"contributors": [ | ||
"Alan Shaw <[email protected]>", | ||
|
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
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