mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-11-20 03:35:52 +00:00
Fix counter stuck & not gen pregen xpop
This commit is contained in:
@@ -58,7 +58,7 @@ services:
|
||||
healthcheck:
|
||||
test: TTL_MINUTES_PREGEN_XPOP=${TTL_MINUTES_PREGEN_XPOP:-60} TTL_DAYS_XPOP_SOURCE_FILES=${TTL_DAYS_XPOP_SOURCE_FILES:-30} sh /cleanup.sh
|
||||
interval: ${TTL_MINUTES_CLEANUP_INTERVAL:-60}m
|
||||
retries: 0
|
||||
retries: 10
|
||||
timeout: 55m
|
||||
volumes:
|
||||
nginxcache:
|
||||
|
||||
@@ -2,6 +2,7 @@ import { writeFile } from 'fs'
|
||||
import { dirExists } from './dirExists.mjs'
|
||||
import { ledgerIndexToFolders } from './ledgerIndexToFolders.mjs'
|
||||
import { xpopGenerate } from './xpopGenerate.mjs'
|
||||
import { createDirectory } from './createDirectory.mjs'
|
||||
import { waitForLedgerReady } from './events/ledgerReady.mjs'
|
||||
import { emit } from '../bin/webserver.mjs'
|
||||
import 'dotenv/config'
|
||||
@@ -68,48 +69,53 @@ const onTransaction = async ({
|
||||
networkId,
|
||||
txHash: tx.hash,
|
||||
})
|
||||
if (await dirExists(xpopBinaryDir)) {
|
||||
const xpopWritten = await new Promise(resolve => {
|
||||
writeFile(xpopBinaryDir + '/' + tx.hash, Buffer.from(xpopBinary, 'utf8'), err => {
|
||||
if (err) {
|
||||
console.log('Error writing binary XPOP', err)
|
||||
resolve(false)
|
||||
} else {
|
||||
console.log('Wrote binary xPOP: ' + xpopBinaryDir + '/' + tx.hash)
|
||||
resolve(true)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
if (!(await dirExists(xpopBinaryDir))) {
|
||||
console.log('(Re-) creating /store/xpop directory')
|
||||
await createDirectory('store/xpop')
|
||||
}
|
||||
|
||||
const xpopWritten = await new Promise(resolve => {
|
||||
writeFile(xpopBinaryDir + '/' + tx.hash, Buffer.from(xpopBinary, 'utf8'), err => {
|
||||
if (err) {
|
||||
console.log('Error writing binary XPOP', err)
|
||||
resolve(false)
|
||||
} else {
|
||||
console.log('Wrote binary xPOP: ' + xpopBinaryDir + '/' + tx.hash)
|
||||
resolve(true)
|
||||
}
|
||||
})
|
||||
if (xpopWritten) {
|
||||
console.log(' ### EMIT XPOP READY FOR', tx?.Account, Number(tx.Sequence), tx.hash)
|
||||
})
|
||||
if (xpopWritten) {
|
||||
console.log(' ### EMIT XPOP READY FOR', tx?.Account, Number(tx.Sequence), tx.hash)
|
||||
|
||||
txCount++
|
||||
txCount++
|
||||
|
||||
return await emit({
|
||||
account: tx?.Account,
|
||||
sequence: tx.Sequence,
|
||||
origin: {
|
||||
tx: tx.hash,
|
||||
networkId: networkId,
|
||||
ledgerIndex: transaction.ledger_index,
|
||||
burn: tx?.Fee,
|
||||
},
|
||||
destination: {
|
||||
networkId: tx?.OperationLimit,
|
||||
},
|
||||
...(
|
||||
process.env?.URL_PREFIX
|
||||
? {
|
||||
xpop: {
|
||||
binary: `${process.env.URL_PREFIX}/xpop/${tx.hash}`,
|
||||
source: `${process.env.URL_PREFIX}/${networkId}/${ledgerIndexToFolders(transaction.ledger_index)}/`,
|
||||
blob: xpopBinary,
|
||||
}
|
||||
return await emit({
|
||||
account: tx?.Account,
|
||||
sequence: tx.Sequence,
|
||||
origin: {
|
||||
tx: tx.hash,
|
||||
networkId: networkId,
|
||||
ledgerIndex: transaction.ledger_index,
|
||||
burn: tx?.Fee,
|
||||
},
|
||||
destination: {
|
||||
networkId: tx?.OperationLimit,
|
||||
},
|
||||
...(
|
||||
process.env?.URL_PREFIX
|
||||
? {
|
||||
xpop: {
|
||||
binary: `${process.env.URL_PREFIX}/xpop/${tx.hash}`,
|
||||
source: `${process.env.URL_PREFIX}/${networkId}/${ledgerIndexToFolders(transaction.ledger_index)}/`,
|
||||
blob: xpopBinary,
|
||||
}
|
||||
: {}
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
: {}
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user