Contacts are used to store data about nodes such as their address and port needed for communication, their ID as well as their local logical clock.
- constructor
- getters
- methods
options
:host
: String IP address of the node.port
: Integer UDP port of the node.id
: String (Optional, if none is provided one will be generated) The node ID.clock
: VectorClock (Optional, if none is provided one will be created and start at time = 0) The node's Vector Clock.
Creates a new Contact.
const plexus = require("plexus");
// Creating a new Contact
const contact = new plexus.Contact({
host: "127.0.0.1",
port: 8080
});
Returns full address of the contact as IP:PORT
.
const address = contact.name;
console.log(address); // 127.0.0.1:8080
Generates a unique contact ID (should only be used for the local node when an ID is not provided).