From 36abb6806dfe49dc12ca574bb5edc93d2f464c13 Mon Sep 17 00:00:00 2001 From: Shahana Farooqui Date: Thu, 13 Feb 2020 19:53:43 -0500 Subject: [PATCH] Multinode Routing bug fix 2 Multinode Routing bug fix 2 --- controllers/lnd/invoices.js | 2 +- controllers/lnd/switch.js | 2 +- src/app/lnd/routing/routing.component.ts | 4 +++- src/app/lnd/store/lnd.effects.ts | 2 +- src/app/shared/models/RTLconfig.ts | 1 + src/app/store/rtl.effects.ts | 4 ++-- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/controllers/lnd/invoices.js b/controllers/lnd/invoices.js index 45044ebb..42867b79 100644 --- a/controllers/lnd/invoices.js +++ b/controllers/lnd/invoices.js @@ -38,7 +38,7 @@ exports.listInvoices = (req, res, next) => { error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error }); } else { - if (undefined !== body.invoices && body.invoices.length > 0) { + if (body.invoices && body.invoices.length > 0) { body.invoices.forEach(invoice => { invoice.creation_date_str = (undefined === invoice.creation_date) ? '' : common.convertTimestampToDate(invoice.creation_date); invoice.settle_date_str = (undefined === invoice.settle_date) ? '' : common.convertTimestampToDate(invoice.settle_date); diff --git a/controllers/lnd/switch.js b/controllers/lnd/switch.js index 6c262c82..5eaa4278 100644 --- a/controllers/lnd/switch.js +++ b/controllers/lnd/switch.js @@ -7,7 +7,6 @@ var num_max_events = 100; var responseData = { forwarding_events: [], last_offset_index: 0 }; exports.forwardingHistory = (req, res, next) => { - responseData = { forwarding_events: [], last_offset_index: 0 }; this.getAllForwardingEvents(req.body.start_time, req.body.end_time, 0, (eventsResponse) => { if (eventsResponse.error) { res.status(500).json(eventsResponse); @@ -18,6 +17,7 @@ exports.forwardingHistory = (req, res, next) => { }; exports.getAllForwardingEvents = (start, end, offset, callback) => { + if (offset === 0) { responseData = { forwarding_events: [], last_offset_index: 0 }; } options = common.getOptions(); options.url = common.getSelLNServerUrl() + '/switch'; options.form = {}; diff --git a/src/app/lnd/routing/routing.component.ts b/src/app/lnd/routing/routing.component.ts index 754accc4..57cd1bef 100644 --- a/src/app/lnd/routing/routing.component.ts +++ b/src/app/lnd/routing/routing.component.ts @@ -37,7 +37,9 @@ export class RoutingComponent implements OnInit, OnDestroy { ngOnInit() { this.actions$.pipe(takeUntil(this.unSubs[1]), filter((action) => action.type === RTLActions.RESET_LND_STORE || action.type === RTLActions.SET_ALL_CHANNELS)) .subscribe((action: RTLActions.ResetLNDStore | RTLActions.SetAllChannels) => { - this.onEventsFetch(); + if (action.type === RTLActions.RESET_LND_STORE && action.payload.lnImplementation === 'LND') { + this.onEventsFetch(); + } }); this.store.select('lnd') .pipe(takeUntil(this.unSubs[0])) diff --git a/src/app/lnd/store/lnd.effects.ts b/src/app/lnd/store/lnd.effects.ts index 55b161b6..7d9913eb 100644 --- a/src/app/lnd/store/lnd.effects.ts +++ b/src/app/lnd/store/lnd.effects.ts @@ -1131,7 +1131,6 @@ export class LNDEffects implements OnDestroy { smaller_currency_unit: info.smaller_currency_unit }; this.store.dispatch(new RTLActions.SetNodeData(node_data)); - this.store.dispatch(new RTLActions.FetchFees()); //Fetches monthly forwarding history as well, to count total number of events this.store.dispatch(new RTLActions.FetchPeers()); this.store.dispatch(new RTLActions.FetchBalance('channels')); this.store.dispatch(new RTLActions.FetchNetwork()); @@ -1140,6 +1139,7 @@ export class LNDEffects implements OnDestroy { this.store.dispatch(new RTLActions.FetchClosedChannels()); this.store.dispatch(new RTLActions.FetchInvoices({num_max_invoices: 10, reversed: true})); this.store.dispatch(new RTLActions.FetchPayments()); + this.store.dispatch(new RTLActions.FetchFees()); //Fetches monthly forwarding history as well, to count total number of events let newRoute = this.location.path(); if(newRoute.includes('/cl/')) { newRoute = newRoute.replace('/cl/', '/lnd/'); diff --git a/src/app/shared/models/RTLconfig.ts b/src/app/shared/models/RTLconfig.ts index cadd8f17..80dde0c1 100644 --- a/src/app/shared/models/RTLconfig.ts +++ b/src/app/shared/models/RTLconfig.ts @@ -64,6 +64,7 @@ export interface SelNodeChild { selCurrencyUnit?: string; currencyUnits?: string[]; fiatConversion?: boolean; + lnImplementation?: string; } export class HelpTopic { diff --git a/src/app/store/rtl.effects.ts b/src/app/store/rtl.effects.ts index bb537ef8..1fdeef34 100644 --- a/src/app/store/rtl.effects.ts +++ b/src/app/store/rtl.effects.ts @@ -376,9 +376,9 @@ export class RTLEffects implements OnDestroy { const landingPage = isInitialSetup ? '' : 'HOME'; let selNode = {}; if(node.settings.fiatConversion && node.settings.currencyUnit) { - selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: [...CURRENCY_UNITS, node.settings.currencyUnit], fiatConversion: node.settings.fiatConversion }; + selNode = { lnImplementation: node.lnImplementation, userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: [...CURRENCY_UNITS, node.settings.currencyUnit], fiatConversion: node.settings.fiatConversion }; } else { - selNode = { userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: CURRENCY_UNITS, fiatConversion: node.settings.fiatConversion }; + selNode = { lnImplementation: node.lnImplementation, userPersona: node.settings.userPersona, channelBackupPath: node.settings.channelBackupPath, selCurrencyUnit: node.settings.currencyUnit, currencyUnits: CURRENCY_UNITS, fiatConversion: node.settings.fiatConversion }; } this.store.dispatch(new RTLActions.ResetRootStore(node)); this.store.dispatch(new RTLActions.ResetLNDStore(selNode));