UNPKG

decentralized-internet

Version:

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

1 lines 448 B
"use strict";const Endpoint=require("../Endpoint"),interval=require("../interval"),notify=function(e){if(!e)throw new Error("Peer is missing.");return(t,r)=>{const n=t.body.host,s=t.body.port;if(!n)return r.sendStatus(400);if(!s)return r.sendStatus(400);const o=new Endpoint({host:n,port:s});e.predecessor&&!interval({left:e.predecessor.id,right:e.self.id,type:"open"}).contains(o.id)||e.setPredecessor(o),r.sendStatus(200)}};module.exports=notify;