mirror of
https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP.git
synced 2025-11-20 11:45:51 +00:00
Store xPOPs
This commit is contained in:
@@ -51,13 +51,11 @@ const onTransaction = async ({
|
||||
* generate an xPOP.
|
||||
*/
|
||||
setTimeout(async () => {
|
||||
console.log(
|
||||
await xpop({
|
||||
ledgerIndex: transaction.ledger_index,
|
||||
networkId,
|
||||
txHash: tx.hash,
|
||||
})
|
||||
)
|
||||
await xpop({
|
||||
ledgerIndex: transaction.ledger_index,
|
||||
networkId,
|
||||
txHash: tx.hash,
|
||||
})
|
||||
}, 500)
|
||||
// ^^ To check: is this enough? If e.g. retrieving the ledger info
|
||||
// would take longer this may not be enough. Best solution:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import assert from 'assert'
|
||||
import { xpop } from './xpopV1.mjs'
|
||||
import { readFile, readdir } from 'fs'
|
||||
import { writeFile, readFile, readdir } from 'fs'
|
||||
import { ledgerIndexToFolders } from '../lib/ledgerIndexToFolders.mjs'
|
||||
import { dirExists } from '../lib/dirExists.mjs'
|
||||
|
||||
@@ -60,8 +60,19 @@ const generateV1 = async ({
|
||||
Promise.all(validationFiles.map(f => catjson(relativeStorDir + '/' + f))),
|
||||
catjson(relativeStorDir + '/tx_' + txHash + '.json'),
|
||||
])
|
||||
|
||||
const xpopJson = await xpop({ vl, ledger: { json, binary, }, validations, tx, })
|
||||
const xpopFilename = 'xpop_' + txHash + '.json'
|
||||
|
||||
writeFile(storeDir + '/' + xpopFilename, Buffer.from(xpopJson, 'utf8'), err => {
|
||||
if (err) {
|
||||
console.log(' !!!->> Error writing xpop-file @ ' + storeDir)
|
||||
} else {
|
||||
console.log(' ---->> xPOP stored @ ' + relativeStorDir + '/' + xpopFilename + ', strlen: ' + xpopJson.length)
|
||||
}
|
||||
})
|
||||
|
||||
return await xpop({ vl, ledger: { json, binary, }, validations, tx, })
|
||||
return Buffer.from(xpopJson, 'utf-8').toString('hex')
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
throw new Error('Not all files required for xPOP generation found')
|
||||
|
||||
@@ -10,13 +10,6 @@ const xpop = async ({
|
||||
validations,
|
||||
tx,
|
||||
}) => {
|
||||
// console.log(vl, json, binary, validations, tx)
|
||||
|
||||
// console.log(json)
|
||||
// console.log(tx)
|
||||
|
||||
const x = {}
|
||||
|
||||
const proof = create_proof(binary?.transactions, tx?.transaction?.hash)
|
||||
const computed_transactions_root = hash_proof(proof)
|
||||
|
||||
@@ -61,12 +54,7 @@ const xpop = async ({
|
||||
}
|
||||
}
|
||||
|
||||
const xpopJson = JSON.stringify(xpopObj)
|
||||
const xpopHex = Buffer.from(xpopJson, 'utf-8').toString('hex')
|
||||
|
||||
// TODO: STORE
|
||||
|
||||
return xpopHex
|
||||
return JSON.stringify(xpopObj)
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user