Merge pull request #659 from shocknet/fix-merge-err

fix merge err
This commit is contained in:
boufni95 2024-03-26 20:46:42 +01:00 committed by GitHub
commit e52cc39cec
2 changed files with 8 additions and 1 deletions

View file

@ -15,6 +15,7 @@ export class Watchdog {
lnd: LightningHandler; lnd: LightningHandler;
settings: WatchdogSettings; settings: WatchdogSettings;
log = getLogger({ appName: "watchdog" }) log = getLogger({ appName: "watchdog" })
enabled = false
constructor(settings: WatchdogSettings, lnd: LightningHandler) { constructor(settings: WatchdogSettings, lnd: LightningHandler) {
this.lnd = lnd; this.lnd = lnd;
this.settings = settings; this.settings = settings;
@ -23,6 +24,7 @@ export class Watchdog {
SeedLndBalance = async (totalUsersBalance: number) => { SeedLndBalance = async (totalUsersBalance: number) => {
this.initialLndBalance = await this.getTotalLndBalance() this.initialLndBalance = await this.getTotalLndBalance()
this.initialUsersBalance = totalUsersBalance this.initialUsersBalance = totalUsersBalance
this.enabled = true
} }
getTotalLndBalance = async () => { getTotalLndBalance = async () => {
@ -77,6 +79,10 @@ export class Watchdog {
PaymentRequested = async (totalUsersBalance: number) => { PaymentRequested = async (totalUsersBalance: number) => {
this.log("Payment requested, checking balance") this.log("Payment requested, checking balance")
if (!this.enabled) {
this.log("WARNING! Watchdog not enabled, skipping balance check")
return
}
const totalLndBalance = await this.getTotalLndBalance() const totalLndBalance = await this.getTotalLndBalance()
const deltaLnd = totalLndBalance - this.initialLndBalance const deltaLnd = totalLndBalance - this.initialLndBalance
const deltaUsers = totalUsersBalance - this.initialUsersBalance const deltaUsers = totalUsersBalance - this.initialUsersBalance

View file

@ -18,7 +18,8 @@ export const initMainHandler = async (log: PubLogger, mainSettings: MainSettings
const mainHandler = new Main(mainSettings, storageManager) const mainHandler = new Main(mainSettings, storageManager)
await mainHandler.lnd.Warmup() await mainHandler.lnd.Warmup()
if (!mainSettings.skipSanityCheck) { if (!mainSettings.skipSanityCheck) {
await mainHandler.VerifyEventsLog() const totalUsersBalance = await mainHandler.VerifyEventsLog()
await mainHandler.paymentManager.watchDog.SeedLndBalance(totalUsersBalance)
} }
const appsData = await mainHandler.storage.applicationStorage.GetApplications() const appsData = await mainHandler.storage.applicationStorage.GetApplications()
const existingWalletApp = await appsData.find(app => app.name === 'wallet' || app.name === 'wallet-test') const existingWalletApp = await appsData.find(app => app.name === 'wallet' || app.name === 'wallet-test')