Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@moosty/lisk-connection-provider

Package Overview
Dependencies
Maintainers
2
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moosty/lisk-connection-provider - npm Package Compare versions

Comparing version 0.0.113 to 0.0.114

5

dist/controllers/ServiceRPCController.d.ts

@@ -7,4 +7,7 @@ import { ConnectionController } from "./ConnectionController";

subscribe: (method: SubscribeMethods) => void;
requestCache: (request: object) => void;
pushCache: (request: object, result: object) => void;
useCache: (request: any) => Promise<object>;
useCache: (request: any, cb: any) => Promise<{
cache: any;
}>;
get: (method: GetMethods, params?: Param, v1?: boolean) => Promise<Envelope | StatusDataType | ReadyDataType>;

@@ -11,0 +14,0 @@ getMore: (method: GetMethods, params?: {

39

dist/controllers/ServiceRPCController.js

@@ -21,18 +21,24 @@ "use strict";

};
this.pushCache = (request, result) => {
this.requestCache = (request) => {
const now = new Date().getTime();
const jsonRequest = JSON.stringify(request);
const cash = this.cache.find(c => c.requests === jsonRequest);
cash?.subscriptions?.map((sub) => sub(result));
this.cache = [{
request: jsonRequest,
result: null,
subscriptions: [],
expire: now + 5000
}, ...this.cache];
};
this.pushCache = (request, result) => {
const jsonRequest = JSON.stringify(request);
const cache = this.cache.find(c => c.requests === jsonRequest);
cache?.subscriptions?.map((sub) => sub(result));
this.cache = [{
...cache,
result,
subscriptions: [],
expire: now + 3000
}, ...this.cache].slice(0, 30);
};
this.useCache = async (request) => {
this.useCache = async (request, cb) => {
const cache = this.cache.find(c => c.request === JSON.stringify(request));
const now = new Date().getTime();
let cb = async (res) => res;
if (cache?.result && now > cache.expire) {

@@ -43,10 +49,12 @@ return { cache };

this.cache = [{ ...cache, subscriptions: [cb, ...cache?.subscriptions] }, ...this.cache];
return { cache: true };
}
return { cache: await cb };
return { cache: false };
};
this.get = async (method, params = {}, v1 = false) => {
this.get = async (method, params = {}, v1 = false) => new Promise(async (resolve) => {
if (this.isConnected()) {
const foundCache = await this.useCache({ method, params });
if (!foundCache) {
const foundCache = await this.useCache({ method, params }, resolve);
if (!foundCache?.cache) {
this.id++;
this.requestCache({ method, params });
const result = await helpers_1.ws({

@@ -61,10 +69,7 @@ socket: !v1 || !this.isV1Connected() ? this.connection : this.v1, requests: [{

this.pushCache({ method, params }, result);
return result;
resolve(result);
}
else {
return foundCache;
}
}
return {};
};
resolve({});
});
this.getMore = async (method, params = {}, v1 = false) => {

@@ -71,0 +76,0 @@ if (this.isConnected()) {

{
"name": "@moosty/lisk-connection-provider",
"version": "0.0.113",
"version": "0.0.114",
"description": "Lisk connection provider component to connect react to Lisk endpoints",

@@ -37,3 +37,3 @@ "author": "Moosty <info@moosty.com>",

},
"gitHead": "5fc1bfa5ab8fece32eeeb82dca02ada5fcff2ffc"
"gitHead": "70ef3469ad8c73c3d9926c21591f6a44162c4e19"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc