How to use @liskhq/lisk-p2p - 2 common examples

To help you get started, we’ve selected a few @liskhq/lisk-p2p examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk / framework / src / modules / network / network.js View on Github external
wsPort: peer.wsPort,
			})),
			previousPeers,
			maxOutboundConnections: this.options.maxOutboundConnections,
			maxInboundConnections: this.options.maxInboundConnections,
			peerBanTime: this.options.peerBanTime,
			populatorInterval: this.options.populatorInterval,
			sendPeerLimit: this.options.sendPeerLimit,
			maxPeerDiscoveryResponseLength: this.options
				.maxPeerDiscoveryResponseLength,
			maxPeerInfoSize: this.options.maxPeerInfoSize,
			wsMaxPayload: this.options.wsMaxPayload,
			secret: this.secret,
		};

		this.p2p = new P2P(p2pConfig);

		this.channel.subscribe('app:state:updated', event => {
			const newNodeInfo = sanitizeNodeInfo(event.data);
			try {
				this.p2p.applyNodeInfo(newNodeInfo);
			} catch (error) {
				this.logger.error(
					`Applying NodeInfo failed because of error: ${error.message ||
						error}`,
				);
			}
		});

		// ---- START: Bind event handlers ----
		this.p2p.on(EVENT_NETWORK_READY, () => {
			this.logger.debug('Node connected to the network');
github LiskArchive / lisk-elements / packages / lisk-node / src / application.ts View on Github external
public constructor() {
		this._initialized = false;
		this._logger = bunyan.createLogger({ name: 'lisk-node' });
		this._logger.info('Starting application');

		const genesisStr = fs.readFileSync(
			`${__dirname}/../configs/mainnet/genesis_block.json`,
			'utf8',
		);
		this._logger.info('Genesis block file obtained');
		const genesis = JSON.parse(genesisStr);
		this._p2p = new P2P({
			blacklistedPeers: [],
			connectTimeout: 5000,
			ackTimeout: 15000,
			seedPeers: [
				{
					ipAddress: '83.136.254.92',
					wsPort: 8001,
				},
				{
					ipAddress: '83.136.249.76',
					wsPort: 8001,
				},
			],
			wsEngine: 'ws',
			nodeInfo: {
				wsPort: 8001,

@liskhq/lisk-p2p

Unstructured P2P library for use with Lisk-related software

Apache-2.0
Latest version published 12 months ago

Package Health Score

50 / 100
Full package analysis

Popular @liskhq/lisk-p2p functions