Kadence plugins are a simple way to package additional features. A plugin is just a function that receives an instance of KademliaNode. This function can then apply any decorations desired.
Included Plugins
- module:kadence/eclipse~EclipsePlugin
- module:kadence/hashcash~HashCashPlugin
- module:kadence/hibernate~HibernatePlugin
- module:kadence/onion~OnionPlugin
- module:kadence/permission~PermissionPlugin
- module:kadence/quasar~QuasarPlugin
- module:kadence/rolodex~RolodexPlugin
- module:kadence/spartacus~SpartacusPlugin
- module:kadence/traverse~TraversePlugin
Example: "Howdy, Neighbor" Plugin
/**
* Example "howdy, neighbor" plugin
* @function
* @param {KademliaNode} node
*/
module.exports = function(node) {
const { identity } = node;
/**
* Respond to HOWDY messages
*/
node.use('HOWDY', (req, res) => {
res.send(['howdy, neighbor']);
});
/**
* Say howdy to our nearest neighbor
*/
node.sayHowdy = function(callback) {
let neighbor = [
...node.router.getClosestContactsToKey(identity).entries()
].shift();
node.send('HOWDY', ['howdy, neighbor'], neighbor, callback);
};
};