diff --git a/plugins/gateway-ipns.js b/plugins/gateway-ipns.js
index 50deee8b5e1456477e105b36312151ed977ab882..c192d002f1eb0c80a500bba0f21ab824b720e540 100644
--- a/plugins/gateway-ipns.js
+++ b/plugins/gateway-ipns.js
@@ -32,7 +32,12 @@
'https://ipfs.sloppyta.co/ipns/', // UK
'https://gateway.temporal.cloud/ipns/', // Germany
'https://ipfs.best-practice.se/ipns/' // Sweden
- ]
+ ],
+ // how many simultaneous connections to gateways we want
+ // more concurrency means higher chance of a request succeeding
+ // but uses morebandwidth and other resources;
+ // 3 seems a reasonable default
+ concurrency: 3
}
// merge the defaults with settings from SamizdatConfig
@@ -55,15 +60,16 @@
// https://<gateway_address>/<pubkey>/<rest_of_URL>
var ipnsUrl = config.ipnsPubkey + url.replace(/https?:\/\/[^/]+/, '')
- // pick 3 gateways, at random
+ // we don't want to modify the original gateways array
var sourceGateways = [...config.ipfsGateways]
- // if we have fewer than 3 gateways configured, use all of them
- if (sourceGateways.length <= 3) {
+
+ // if we have fewer than the configured concurrency, use all of them
+ if (sourceGateways.length <= config.concurrency) {
var useGateways = sourceGateways
- // otherwise get 3 at random
+ // otherwise get `config.concurrency` gateways at random
} else {
var useGateways = new Array()
- while (useGateways.length < 3) {
+ while (useGateways.length < config.concurrency) {
// put in the address while we're at it
useGateways.push(
sourceGateways