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

lisk-interchain

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lisk-interchain - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

49

index.js

@@ -0,1 +1,3 @@

const shuffle = require('lodash.shuffle');
let defaultSelectForRequestFunction;

@@ -11,7 +13,2 @@ let defaultSelectForSendFunction;

function interchainSelectForConnection(input) {
let {nodeInfo, peers} = input;
return peers;
}
function interchainSelectForRequest(input) {

@@ -23,5 +20,9 @@ let {nodeInfo, peers, peerLimit, requestPacket} = input;

let matchingPeers = peers.filter((peerInfo) => {
return peerInfo.
return peerInfo.modules && peerInfo.modules[procedureTargetModule];
});
return; // TODO 2
if (!matchingPeers.length) {
return [];
}
let chosenPeer = matchingPeers[Math.floor(Math.random() * matchingPeers.length)];
return [chosenPeer];
}

@@ -35,4 +36,11 @@

if (messagePacket) {
return; // TODO 2
let eventSourceModule = getAffectedModule(messagePacket.event);
if (eventSourceModule) {
let matchingPeers = peers.filter((peerInfo) => {
return peerInfo.modules && peerInfo.modules[eventSourceModule];
});
if (!matchingPeers.length) {
return [];
}
return shuffle(matchingPeers).slice(0, input.peerLimit);
}

@@ -43,14 +51,31 @@

module.exports = function (app) {
function attachInterchain(app) {
let realLoadFunction = app.getModule('network').prototype.load;
app.getModule('network').prototype.load = async function (channel) {
await realLoadFunction.call(this, channel);
let availableModules = Object.keys(app.getModules() || {}).reduce((modulesMap, moduleName) => {
return {
...modulesMap,
[moduleName]: {}
};
}, {});
let realApplyNodeInfoFunction = this.network.p2p.applyNodeInfo;
this.network.p2p.applyNodeInfo = function (nodeInfo) {
let extendedNodeInfo = {
...nodeInfo,
modules: availableModules
};
realApplyNodeInfoFunction.call(this, extendedNodeInfo);
};
defaultSelectForRequestFunction = this.network.p2p._peerPool._peerSelectForRequest;
defaultSelectForSendFunction = this.network.p2p._peerPool._peerSelectForSend;
this.network.p2p._peerPool._peerSelectForConnection = interchainSelectForConnection;
this.network.p2p._peerPool._peerSelectForRequest = interchainSelectForRequest;
this.network.p2p._peerPool._peerSelectForSend = interchainSelectForSend;
};
};
}
module.exports = attachInterchain;
{
"name": "lisk-interchain",
"version": "1.0.0",
"version": "1.0.1",
"description": "Custom peer selector plugin for Lisk interchain.",

@@ -24,3 +24,6 @@ "main": "index.js",

},
"homepage": "https://github.com/jondubois/lisk-interchain#readme"
"homepage": "https://github.com/jondubois/lisk-interchain#readme",
"dependencies": {
"lodash.shuffle": "^4.2.0"
}
}
# lisk-interchain
Custom peer selector plugin for Lisk interchain.
Custom peer matching plugin for Lisk interchain.
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