mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-11-19 19:25:52 +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())
|
process.env.NODES.split(',').map(h => h.trim())
|
||||||
.map(h => new XrplClient(h)).map(async c => {
|
.map(h => new XrplClient(h)).map(async c => {
|
||||||
await c.ready()
|
|
||||||
|
|
||||||
/**
|
const subscribe = async () => {
|
||||||
* TODO: Auto disconnect if no messages for X
|
await c.ready()
|
||||||
* TODO: Generate xPOPs for matching transactions
|
|
||||||
*/
|
|
||||||
|
|
||||||
c.send({ command: "subscribe", streams: [
|
/**
|
||||||
"validations",
|
* TODO: Auto disconnect if no messages for X
|
||||||
"ledger",
|
* TODO: Generate xPOPs for matching transactions
|
||||||
// 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({
|
c.send({ command: "subscribe", streams: [
|
||||||
connectionUrl: c.getState()?.server?.uri,
|
"validations",
|
||||||
networkId: c.getState()?.server?.networkId,
|
"ledger",
|
||||||
validation,
|
// 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("ledger", ledger => onLedger({
|
c.on("validation", validation => onValidation({
|
||||||
connectionUrl: c.getState()?.server?.uri,
|
connectionUrl: c.getState()?.server?.uri,
|
||||||
networkId: c.getState()?.server?.networkId,
|
networkId: c.getState()?.server?.networkId,
|
||||||
ledger,
|
validation,
|
||||||
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