git clone [email protected]:8af1e7887515133208af.git hello-world
cd hello-world
npm install
npm start
Last active
November 8, 2015 13:57
-
-
Save shime/cc4b9d5737b9ada9baf8 to your computer and use it in GitHub Desktop.
Hello world over bittorrent DHT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DHT = require('bittorrent-dht') | |
var dht = new DHT() | |
var value = new Buffer(11).fill('hello world') | |
console.log('putting data, please wait...') | |
dht.on('ready', function () { | |
dht.put({ v: value }, function (errors, hash) { | |
console.error('errors=', errors) | |
console.log('hash=', hash) | |
console.log('getting data, please wait...') | |
dht.get(hash, function(errors, res){ | |
console.error('errors=', errors) | |
console.log(res.v.toString()) | |
}) | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "bittorrent-example", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node hello.js" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"bittorrent-dht": "^4.0.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment