check height
This commit is contained in:
parent
203069227f
commit
6eca15020e
6 changed files with 53 additions and 4 deletions
|
|
@ -179,14 +179,22 @@ export default class {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log("checking for missed confirmed chain transactions...")
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { transactions } = await this.lnd.GetTransactions(0)
|
const lndInfo = await this.lnd.GetInfo()
|
||||||
|
const lndPubkey = lndInfo.identityPubkey
|
||||||
|
|
||||||
|
const startHeight = await this.storage.liquidityStorage.GetLatestCheckedHeight('lnd', lndPubkey)
|
||||||
|
log(`checking for missed confirmed chain transactions from height ${startHeight}...`)
|
||||||
|
|
||||||
|
const { transactions } = await this.lnd.GetTransactions(startHeight)
|
||||||
log(`retrieved ${transactions.length} transactions from LND`)
|
log(`retrieved ${transactions.length} transactions from LND`)
|
||||||
|
|
||||||
const recoveredCount = await this.processMissedChainTransactions(transactions, log)
|
const recoveredCount = await this.processMissedChainTransactions(transactions, log)
|
||||||
|
|
||||||
|
// Update latest checked height to current block height
|
||||||
|
const currentHeight = lndInfo.blockHeight
|
||||||
|
await this.storage.liquidityStorage.UpdateLatestCheckedHeight('lnd', lndPubkey, currentHeight)
|
||||||
|
|
||||||
if (recoveredCount > 0) {
|
if (recoveredCount > 0) {
|
||||||
log(`processed ${recoveredCount} missed chain tx(s)`)
|
log(`processed ${recoveredCount} missed chain tx(s)`)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ export class TrackedProvider {
|
||||||
@Column({ default: 0 })
|
@Column({ default: 0 })
|
||||||
latest_distruption_at_unix: number
|
latest_distruption_at_unix: number
|
||||||
|
|
||||||
|
@Column({ default: 0 })
|
||||||
|
latest_checked_height: number
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
created_at: Date
|
created_at: Date
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,4 +64,13 @@ export class LiquidityStorage {
|
||||||
async UpdateTrackedProviderDisruption(providerType: 'lnd' | 'lnPub', pub: string, latestDisruptionAtUnix: number) {
|
async UpdateTrackedProviderDisruption(providerType: 'lnd' | 'lnPub', pub: string, latestDisruptionAtUnix: number) {
|
||||||
return this.dbs.Update<TrackedProvider>('TrackedProvider', { provider_pubkey: pub, provider_type: providerType }, { latest_distruption_at_unix: latestDisruptionAtUnix })
|
return this.dbs.Update<TrackedProvider>('TrackedProvider', { provider_pubkey: pub, provider_type: providerType }, { latest_distruption_at_unix: latestDisruptionAtUnix })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async GetLatestCheckedHeight(providerType: 'lnd' | 'lnPub', pub: string): Promise<number> {
|
||||||
|
const provider = await this.GetTrackedProvider(providerType, pub)
|
||||||
|
return provider?.latest_checked_height || 0
|
||||||
|
}
|
||||||
|
|
||||||
|
async UpdateLatestCheckedHeight(providerType: 'lnd' | 'lnPub', pub: string, height: number) {
|
||||||
|
return this.dbs.Update<TrackedProvider>('TrackedProvider', { provider_pubkey: pub, provider_type: providerType }, { latest_checked_height: height })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class TrackedProviderHeight1766504040000 implements MigrationInterface {
|
||||||
|
name = 'TrackedProviderHeight1766504040000'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "tracked_provider" ADD "latest_checked_height" integer NOT NULL DEFAULT (0)`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "tracked_provider" DROP COLUMN "latest_checked_height"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class TrackedProviderHeight1766504040000 implements MigrationInterface {
|
||||||
|
name = 'TrackedProviderHeight1766504040000'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "tracked_provider" ADD "latest_checked_height" integer NOT NULL DEFAULT (0)`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "tracked_provider" DROP COLUMN "latest_checked_height"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -30,13 +30,14 @@ import { AdminSettings1761683639419 } from './1761683639419-admin_settings.js'
|
||||||
import { TxSwap1762890527098 } from './1762890527098-tx_swap.js'
|
import { TxSwap1762890527098 } from './1762890527098-tx_swap.js'
|
||||||
import { TxSwapAddress1764779178945 } from './1764779178945-tx_swap_address.js'
|
import { TxSwapAddress1764779178945 } from './1764779178945-tx_swap_address.js'
|
||||||
import { ClinkRequester1765497600000 } from './1765497600000-clink_requester.js'
|
import { ClinkRequester1765497600000 } from './1765497600000-clink_requester.js'
|
||||||
|
import { TrackedProviderHeight1766504040000 } from './1766504040000-tracked_provider_height.js'
|
||||||
|
|
||||||
|
|
||||||
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189,
|
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189,
|
||||||
TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264,
|
TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264,
|
||||||
DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042, ManagementGrant1751307732346, ManagementGrantBanned1751989251513,
|
DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042, ManagementGrant1751307732346, ManagementGrantBanned1751989251513,
|
||||||
InvoiceCallbackUrls1752425992291, OldSomethingLeftover1753106599604, UserReceivingInvoiceIdx1753109184611, AppUserDevice1753285173175,
|
InvoiceCallbackUrls1752425992291, OldSomethingLeftover1753106599604, UserReceivingInvoiceIdx1753109184611, AppUserDevice1753285173175,
|
||||||
UserAccess1759426050669, AddBlindToUserOffer1760000000000, ApplicationAvatarUrl1761000001000, AdminSettings1761683639419, TxSwap1762890527098, TxSwapAddress1764779178945, ClinkRequester1765497600000]
|
UserAccess1759426050669, AddBlindToUserOffer1760000000000, ApplicationAvatarUrl1761000001000, AdminSettings1761683639419, TxSwap1762890527098, TxSwapAddress1764779178945, ClinkRequester1765497600000, TrackedProviderHeight1766504040000]
|
||||||
|
|
||||||
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825, RootOps1732566440447, RootOpsTime1745428134124, ChannelEvents1750777346411]
|
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825, RootOps1732566440447, RootOpsTime1745428134124, ChannelEvents1750777346411]
|
||||||
/* export const TypeOrmMigrationRunner = async (log: PubLogger, storageManager: Storage, settings: DbSettings, arg: string | undefined): Promise<boolean> => {
|
/* export const TypeOrmMigrationRunner = async (log: PubLogger, storageManager: Storage, settings: DbSettings, arg: string | undefined): Promise<boolean> => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue