Trigger xPOP generation (WIP)

This commit is contained in:
Wietse Wind
2023-10-03 00:56:19 +02:00
parent 096e76a14e
commit b8283b3887

View File

@@ -1,6 +1,7 @@
import { writeFile } from 'fs'
import { dirExists } from './dirExists.mjs'
import { ledgerIndexToFolders } from './ledgerIndexToFolders.mjs'
import { generateV1 as xpop } from '../xpop/generateV1.mjs'
import 'dotenv/config'
const lastSeenTransactions = []
@@ -42,6 +43,16 @@ const onTransaction = async ({
writeFile(storeDir + '/tx_' + tx.hash + '.json', Buffer.from(JSON.stringify(transaction), 'utf8'), err => {
if (err) {
console.log('Error writing file @ ' + storeDir)
} else {
/**
* TX all ready, written to filesystem, ...
* This is where we start a slight delay to give the `onLedger`
* routine some time to fetch & store and then we'll try to
* generate an xPOP.
*/
setTimeout(() => {
console.log(xpop(transaction.ledger_index, tx.hash))
}, 2000)
}
})
}