dht-iot
Using the BitTorrent DHT to store IoT data
I am using my forked version of the bitTorrent-dht module : https://github.com/EtienneV/bittorrent-dht
install
npm install dht-iot
Initialisation
var DHT_IOT = var keypair = publicKey:Buffer secretKey:Buffervar dht_iot = keypair: keypair
Initiate a dht-iot instance with a specified keypair.
var DHT_IOT = var dht_iot =
Initiate a dht-iot instance with a random keypair.
Keypair generation
dht_iot
It will display a new random keypair.
Put data
Send data over the DHT at the hash corresponding to the specified keypair.
dht_iot
IN val : Value to publish on the DHT
OUT hash : the hash corresponding to the value published
Example
var DHT_IOT = var keypair = publicKey:Buffer secretKey:Buffervar dht_iot = keypair: keypair dht_iot
Get data
Get data at the hash corresponding to the specified keypair.
dht_iot
OUT val.v : the value val.t : the date of the value (UNIX timestamp in seconds)
Example
var DHT_IOT = var keypair = publicKey:Buffer secretKey:Buffervar dht_iot = keypair: keypair dht_iot
Get notified for new data
Get notified at every new message. The checking resolution is about 3 seconds.
dht_iot // Launch notification system
Everytime there is a new value an "new_value" event is fired
Example
var DHT_IOT = var keypair = publicKey:Buffer secretKey:Buffervar dht_iot = keypair: keypair var notif = dht_iot dht_iot