Merge pull request #272 from shocknet/remove-unused-service

remove unused service
This commit is contained in:
Daniel Lugo 2020-12-10 17:40:13 -04:00 committed by GitHub
commit 3905565cf4
2 changed files with 4 additions and 85 deletions

View file

@ -1,80 +0,0 @@
// app/lnd.js
const logger = require("winston");
// TODO
module.exports = function(lightning) {
const module = {};
const invoiceListeners = [];
let lndInvoicesStream = null;
const openLndInvoicesStream = function() {
if (lndInvoicesStream) {
logger.debug("Lnd invoices subscription stream already opened.");
} else {
logger.debug("Opening lnd invoices subscription stream...");
lndInvoicesStream = lightning.subscribeInvoices({});
logger.debug("Lnd invoices subscription stream opened.");
lndInvoicesStream.on("data", function(data) {
logger.debug("SubscribeInvoices Data", data);
for (let i = 0; i < invoiceListeners.length; i++) {
try {
invoiceListeners[i].dataReceived(data);
} catch (err) {
logger.warn(err);
}
}
});
lndInvoicesStream.on("end", function() {
logger.debug("SubscribeInvoices End");
lndInvoicesStream = null;
openLndInvoicesStream(); // try opening stream again
});
lndInvoicesStream.on("error", function(err) {
logger.debug("SubscribeInvoices Error", err);
});
lndInvoicesStream.on("status", function(status) {
logger.debug("SubscribeInvoices Status", status);
if (status.code == 14) {
// Unavailable
lndInvoicesStream = null;
openLndInvoicesStream(); // try opening stream again
}
});
}
};
// register invoice listener
module.registerInvoiceListener = function(listener) {
invoiceListeners.push(listener);
logger.debug(
"New lnd invoice listener registered, " +
invoiceListeners.length +
" listening now"
);
};
// unregister invoice listener
module.unregisterInvoiceListener = function(listener) {
invoiceListeners.splice(invoiceListeners.indexOf(listener), 1);
logger.debug(
"Lnd invoice listener unregistered, " +
invoiceListeners.length +
" still listening"
);
};
// open lnd invoices stream on start
openLndInvoicesStream();
// check every minute that lnd invoices stream is still opened
setInterval(function() {
if (!lndInvoicesStream) {
openLndInvoicesStream();
}
}, 60 * 1000);
return module;
};

View file

@ -164,10 +164,6 @@ const server = program => {
await LightningServices.init()
}
// init lnd module =================
const lnd = require('../services/lnd/lnd')(
LightningServices.services.lightning
)
await new Promise((resolve, reject) => {
LightningServices.services.lightning.getInfo({}, (err, res) => {
if (err && err.code !== 12) {
@ -216,7 +212,10 @@ const server = program => {
next()
})
const storageDirectory = Path.resolve(rootFolder, `${program.rootPath ? '.' : '..'}/.storage`);
const storageDirectory = Path.resolve(
rootFolder,
`${program.rootPath ? '.' : '..'}/.storage`
)
await Storage.init({
dir: storageDirectory