Skip to content

Commit 197929b

Browse files
committed
remove references to missing-ledgers table
1 parent 986698f commit 197929b

File tree

12 files changed

+3
-558
lines changed

12 files changed

+3
-558
lines changed

ARCHITECTURE.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,5 @@ This table keeps track of all validated ledgers received from streaming subscrip
211211
| `txn_count` | The number of transactions in this ledger. |
212212
| `received_at` | The time when this ledgerClosed message was received by the VHS. |
213213

214-
### `missing_ledgers`
215-
216-
This table keeps track of missing validated ledgers detected across different networks.
217-
218-
| Key | Definition |
219-
|------------------------------|-------------------------------------------------------------------------|
220-
| `network` | The network on which the ledger is missing. |
221-
| `ledger_index` | The index of the missing ledger. |
222-
| `previous_ledger_index` | The index of the previous ledger that was received. |
223-
| `previous_ledger_received_at`| The time when the previous ledger was received by the VHS. |
224-
225214
*Partial validations are not meant to vote for any particular ledger. A partial validation indicates that the validator is still online but not keeping up with consensus.
226215
**A chain is a group of validators validating the same set of ledgers. `main`, `test`, and `dev` represent the validated versions of mainnet, testnet, and devnet respectively. Validators on a fork/validating an alternate version of the ledger will have a different value, usually of the form `chain.[num]`.

src/connection-manager/connections.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { FeeVote, WsNode } from '../shared/types'
1818
import { getIPv4Address } from '../shared/utils'
1919
import logger from '../shared/utils/logger'
2020

21-
import checkForMissingLedgers from './scanMissingLedgers'
2221
import {
2322
backtrackAmendmentStatus,
2423
fetchAmendmentsFromLedgerEntry,
@@ -236,7 +235,6 @@ export default async function startConnections(): Promise<void> {
236235
}, BACKTRACK_INTERVAL)
237236

238237
setInterval(pruneValidatedLedgersTable, 1000 * 60 * 60 * 24)
239-
setInterval(checkForMissingLedgers, 1000 * 60)
240238
}
241239
}
242240

src/connection-manager/scanMissingLedgers.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/shared/database/setup.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export default async function setupTables(): Promise<void> {
2727
await addAmendmentsDataFromJSON()
2828
await setupConnectionHealthTable()
2929
await setupValidatedLedgersTable()
30-
await setupMissingLedgersTable()
3130
}
3231

3332
async function setupCrawlsTable(): Promise<void> {
@@ -300,16 +299,3 @@ export async function setupValidatedLedgersTable(): Promise<void> {
300299
})
301300
}
302301
}
303-
304-
async function setupMissingLedgersTable(): Promise<void> {
305-
const hasTable = await db().schema.hasTable('missing_ledgers')
306-
if (!hasTable) {
307-
await db().schema.createTable('missing_ledgers', (table) => {
308-
table.string('network').notNullable()
309-
table.bigInteger('ledger_index').notNullable()
310-
table.bigInteger('previous_ledger_index').notNullable()
311-
table.dateTime('previous_ledger_received_at').notNullable()
312-
table.primary(['network', 'ledger_index'])
313-
})
314-
}
315-
}

src/shared/database/validatedLedgers.ts

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { rippleTimeToUnixTime } from 'xrpl'
22

3-
import { StreamLedger, MissingLedger } from '../types'
3+
import { StreamLedger } from '../types'
44
import logger from '../utils/logger'
55

66
import { query } from './utils'
@@ -88,56 +88,3 @@ export async function insertValidations(
8888
)
8989
}
9090
}
91-
92-
/**
93-
* Retrieves the most recent validated ledgers for a network, up to a specified limit.
94-
*
95-
* @param network - The network identifier.
96-
* @param limit - Optional limit on the number of ledgers to return (default: 100).
97-
* @returns A promise resolving to an array of recent validated ledgers.
98-
*/
99-
export async function getRecentValidatedLedgers(
100-
network: string,
101-
limit?: number,
102-
): Promise<StreamLedger[]> {
103-
return query('validated_ledgers')
104-
.where('network', network)
105-
.orderBy('ledger_index', 'desc')
106-
.select('*')
107-
.limit(limit ?? 100)
108-
}
109-
110-
/**
111-
* Inserts a missing ledger record into the database, ignoring if it already exists.
112-
*
113-
* @param missedLedger - The missing ledger data to insert.
114-
* @returns A promise that resolves when the insertion is complete.
115-
*/
116-
export async function insertMissingLedger(
117-
missedLedger: MissingLedger,
118-
): Promise<void> {
119-
await query('missing_ledgers')
120-
.insert({
121-
network: missedLedger.network,
122-
ledger_index: missedLedger.ledger_index,
123-
previous_ledger_index: missedLedger.previous_ledger_index,
124-
previous_ledger_received_at: missedLedger.previous_ledger_received_at,
125-
})
126-
.onConflict(['network', 'ledger_index'])
127-
.ignore()
128-
}
129-
130-
/**
131-
* Retrieves all missing ledgers for a network, ordered by ledger index descending.
132-
*
133-
* @param network - The network identifier.
134-
* @returns A promise resolving to an array of missing ledgers.
135-
*/
136-
export async function getMissingLedgers(
137-
network: string,
138-
): Promise<MissingLedger[]> {
139-
return query('missing_ledgers')
140-
.where('network', network)
141-
.orderBy('ledger_index', 'desc')
142-
.select('*')
143-
}

src/shared/types/index.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,9 @@ interface StreamLedger {
2727
reserve_inc: number
2828
txn_id: number
2929
type: string
30-
// Note: The VHS code base needs to be updated to include this field in the LedgerStream response.
3130
validated_ledgers?: string
3231
}
3332

34-
interface MissingLedger {
35-
network: string
36-
ledger_index: number
37-
previous_ledger_index: number
38-
previous_ledger_received_at: Date
39-
}
40-
4133
interface AmendmentEnabled {
4234
amendment_id: string
4335
networks: string
@@ -279,5 +271,4 @@ export {
279271
AmendmentInfo,
280272
ConnectionHealth,
281273
WsNode,
282-
MissingLedger,
283274
}

test/connections/fixtures/two-missing-ledgers.json

Lines changed: 0 additions & 50 deletions
This file was deleted.

test/connections/fixtures/validated-ledgers-backup.json

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)