|
|
|
@ -73,17 +73,34 @@ COMMANDS.DETACHED = function (data, cb) {
|
|
|
|
|
cb();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
COMMANDS.HASH_CHANNEL_LIST = function (data, cb) {
|
|
|
|
|
var channels = data.channels;
|
|
|
|
|
if (!Array.isArray(channels)) { return void cb('INVALID_CHANNEL_LIST'); }
|
|
|
|
|
var uniques = [];
|
|
|
|
|
|
|
|
|
|
channels.forEach(function (a) {
|
|
|
|
|
if (uniques.indexOf(a) === -1) { uniques.push(a); }
|
|
|
|
|
});
|
|
|
|
|
uniques.sort();
|
|
|
|
|
|
|
|
|
|
var hash = Nacl.util.encodeBase64(Nacl.hash(Nacl
|
|
|
|
|
.util.decodeUTF8(JSON.stringify(uniques))));
|
|
|
|
|
|
|
|
|
|
cb(void 0, hash);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
process.on('message', function (data) {
|
|
|
|
|
if (!data || !data.key || !data.msg || !data.txid) {
|
|
|
|
|
if (!data || !data.txid) {
|
|
|
|
|
return void process.send({
|
|
|
|
|
error:'E_INVAL'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cb = function (err) {
|
|
|
|
|
const cb = function (err, value) {
|
|
|
|
|
process.send({
|
|
|
|
|
txid: data.txid,
|
|
|
|
|
error: err,
|
|
|
|
|
value: value,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|