Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.23 KB

contact.md

File metadata and controls

52 lines (38 loc) · 1.23 KB

Contact

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.

Contents

Constructor

new Contact(options)

  • 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
});

Getters

contact.name


Returns full address of the contact as IP:PORT.

const address = contact.name;
console.log(address);   //  127.0.0.1:8080

Methods

contact.generate_id()


Generates a unique contact ID (should only be used for the local node when an ID is not provided).