Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.19 KB

vector_clock.md

File metadata and controls

53 lines (38 loc) · 1.19 KB

VectorClock

The vector clock is used to keep track of the logical time of the node.

The vector clock is useful when updating a remote node's contact informations in the router.

Contents

Constructor

new VectorClock(options)

  • options:
    • start: Integer (Default: 0) Starting time of the clock.


Creates a new Vector Clock.

const plexus = require("plexus");

//  Creating a new Vector Clock
const clock = new plexus.VectorClock();

Getters

vector_clock.time


Returns the current logical time of the node.

const time = clock.time;
console.log(time);  //  15

Methods

vector_clock.update(id)

  • id: String (Optional, Default: null) The ID of the node that caused the update.


Updates the logical time of the node.

//  Node 0xa6564bce963cbfb2e841d2c94d450368c1463b235fb70fb27f2f69285cacf8ed caused an update
clock.update("0xa6564bce963cbfb2e841d2c94d450368c1463b235fb70fb27f2f69285cacf8ed");