UNPKG

decentralized-internet

Version:

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

24 lines (18 loc) 410 B
'use strict'; const fixPredecessor = function (peer) { if (!peer) { throw new Error('Peer is missing.'); } return (req, res) => { if (!peer.predecessor) { return res.sendStatus(200); } peer.remote(peer.predecessor).run('self', err => { if (err) { peer.setPredecessor(undefined); } res.sendStatus(200); }); }; }; module.exports = fixPredecessor;