@polkadot-api/substrate-client
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -570,9 +570,24 @@ 'use strict'; | ||
const clientCache = /* @__PURE__ */ new Map(); | ||
const createClient = (provider) => { | ||
const cached = clientCache.get(provider); | ||
if (cached) { | ||
cached.refCount++; | ||
return cached.client; | ||
} | ||
const { request, disconnect } = createClient$1(provider); | ||
return { | ||
const destroy = () => { | ||
const cached2 = clientCache.get(provider); | ||
if (!cached2 || cached2.refCount <= 1) { | ||
clientCache.delete(provider); | ||
disconnect(); | ||
} else { | ||
cached2.refCount--; | ||
} | ||
}; | ||
const client = { | ||
chainHead: getChainHead(request), | ||
transaction: getTransaction(request), | ||
getChainSpecData: createGetChainSpec(request), | ||
destroy: disconnect, | ||
destroy, | ||
request: abortablePromiseFn( | ||
@@ -583,2 +598,4 @@ (onSuccess, onError, method, params) => request(method, params, { onSuccess, onError }) | ||
}; | ||
clientCache.set(provider, { client, refCount: 1 }); | ||
return client; | ||
}; | ||
@@ -585,0 +602,0 @@ |
{ | ||
"name": "@polkadot-api/substrate-client", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"author": "Josep M Sobrepere (https://github.com/josepot)", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1479
147806