mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-11-18 18:55:50 +00:00
Resubscribe on reconnect
This commit is contained in:
51
index.mjs
51
index.mjs
@@ -13,31 +13,36 @@ await createDirectory('store/xpop')
|
||||
|
||||
process.env.NODES.split(',').map(h => h.trim())
|
||||
.map(h => new XrplClient(h)).map(async c => {
|
||||
await c.ready()
|
||||
|
||||
const subscribe = async () => {
|
||||
await c.ready()
|
||||
|
||||
/**
|
||||
* TODO: Auto disconnect if no messages for X
|
||||
* TODO: Generate xPOPs for matching transactions
|
||||
*/
|
||||
|
||||
/**
|
||||
* TODO: Auto disconnect if no messages for X
|
||||
* TODO: Generate xPOPs for matching transactions
|
||||
*/
|
||||
c.send({ command: "subscribe", streams: [
|
||||
"validations",
|
||||
"ledger",
|
||||
// No transactions, to make it easier for clients transactions are
|
||||
// processed in order (sorted on sequence) and emitted in order
|
||||
// to clients to prevent async tx sequence problems.
|
||||
] })
|
||||
|
||||
c.send({ command: "subscribe", streams: [
|
||||
"validations",
|
||||
"ledger",
|
||||
// No transactions, to make it easier for clients transactions are
|
||||
// processed in order (sorted on sequence) and emitted in order
|
||||
// to clients to prevent async tx sequence problems.
|
||||
] })
|
||||
c.on("validation", validation => onValidation({
|
||||
connectionUrl: c.getState()?.server?.uri,
|
||||
networkId: c.getState()?.server?.networkId,
|
||||
validation,
|
||||
}))
|
||||
|
||||
c.on("validation", validation => onValidation({
|
||||
connectionUrl: c.getState()?.server?.uri,
|
||||
networkId: c.getState()?.server?.networkId,
|
||||
validation,
|
||||
}))
|
||||
c.on("ledger", ledger => onLedger({
|
||||
connectionUrl: c.getState()?.server?.uri,
|
||||
networkId: c.getState()?.server?.networkId,
|
||||
ledger,
|
||||
connection: c,
|
||||
}))
|
||||
}
|
||||
|
||||
c.on("ledger", ledger => onLedger({
|
||||
connectionUrl: c.getState()?.server?.uri,
|
||||
networkId: c.getState()?.server?.networkId,
|
||||
ledger,
|
||||
connection: c,
|
||||
}))
|
||||
c.on('online', () => subscribe())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user