2014-06-07 22:10:12 +00:00
|
|
|
/**
|
2014-07-13 01:44:41 +00:00
|
|
|
* Functions/constants needed by both the client and server.
|
2014-06-07 22:10:12 +00:00
|
|
|
*/
|
|
|
|
|
2016-05-30 06:12:23 +00:00
|
|
|
var Buffer = require('safe-buffer').Buffer
|
2015-03-24 08:52:21 +00:00
|
|
|
var extend = require('xtend/mutable')
|
2014-12-12 23:09:40 +00:00
|
|
|
|
2015-05-03 23:53:37 +00:00
|
|
|
exports.DEFAULT_ANNOUNCE_PEERS = 50
|
2014-12-09 23:44:45 +00:00
|
|
|
exports.MAX_ANNOUNCE_PEERS = 82
|
|
|
|
|
2014-12-12 10:02:11 +00:00
|
|
|
exports.binaryToHex = function (str) {
|
2016-05-30 06:12:23 +00:00
|
|
|
if (typeof str !== 'string') {
|
|
|
|
str = String(str)
|
|
|
|
}
|
|
|
|
return Buffer.from(str, 'binary').toString('hex')
|
2014-12-12 10:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.hexToBinary = function (str) {
|
2016-05-30 06:12:23 +00:00
|
|
|
if (typeof str !== 'string') {
|
|
|
|
str = String(str)
|
|
|
|
}
|
|
|
|
return Buffer.from(str, 'hex').toString('binary')
|
2014-07-13 01:44:41 +00:00
|
|
|
}
|
2014-07-11 04:28:37 +00:00
|
|
|
|
2015-03-24 08:52:21 +00:00
|
|
|
var config = require('./common-node')
|
|
|
|
extend(exports, config)
|