UNPKG

decentralized-internet

Version:

An NPM library of programs to create decentralized web and distributed computing projects

28 lines (21 loc) 504 B
'use strict'; const freeport = require('freeport'); const Peer = require('./Peer'); const createPeer = function (options, callback) { freeport((errFreeport, port) => { if (errFreeport) { return callback(errFreeport); } const peer = new Peer({ port, serviceInterval: options.serviceInterval }); peer.start(errStart => { if (errStart) { return callback(errStart); } callback(null, peer); }); }); }; module.exports = createPeer;