removed old audit code
This commit is contained in:
parent
4ba24bba25
commit
5f7e2b7613
@ -9,10 +9,8 @@ logger.log('debug',
|
|||||||
|
|
||||||
db.connect(config.mongodb.uri, config.mongodb.options);
|
db.connect(config.mongodb.uri, config.mongodb.options);
|
||||||
|
|
||||||
|
|
||||||
db.connection.once('open', () => {
|
db.connection.once('open', () => {
|
||||||
// DB Audit returns best height to node
|
db.blocks.getBestBlockHeight((err, bestBlockHeight) => {
|
||||||
db.blocks.findMissingBlocks((err, bestBlockHeight) => {
|
|
||||||
// Pass height to node to start Sync
|
// Pass height to node to start Sync
|
||||||
logger.log('debug',
|
logger.log('debug',
|
||||||
`Starting Bcoin from best height: ${bestBlockHeight}`);
|
`Starting Bcoin from best height: ${bestBlockHeight}`);
|
||||||
|
|||||||
@ -39,8 +39,8 @@ function getLastBlock(cb) {
|
|||||||
.limit(1);
|
.limit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the missing block if it exists. Otherwise, return tip.
|
// Returns highest consecutive block height
|
||||||
function findMissingBlocks(cb) {
|
function getBestBlockHeight(cb) {
|
||||||
logger.log('debug',
|
logger.log('debug',
|
||||||
'Verifying Mongo Blockchain');
|
'Verifying Mongo Blockchain');
|
||||||
return Block.getHeights((err, blocks) => {
|
return Block.getHeights((err, blocks) => {
|
||||||
@ -59,7 +59,7 @@ function findMissingBlocks(cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findMissingBlocks,
|
getBestBlockHeight,
|
||||||
getRawBlock,
|
getRawBlock,
|
||||||
getTopBlocks,
|
getTopBlocks,
|
||||||
getLastBlock,
|
getLastBlock,
|
||||||
|
|||||||
@ -36,39 +36,8 @@ function getTxCountByAddress(address, cb) {
|
|||||||
return Transactions.countByAddress(address, cb);
|
return Transactions.countByAddress(address, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInput(txid, inputid, value, address) {
|
|
||||||
return Transactions.updateInput(txid, inputid, value, address);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Updates empty inputs with prevout addr & value
|
|
||||||
function auditInputs() {
|
|
||||||
getEmptyInputs(
|
|
||||||
(err, txs) => {
|
|
||||||
if (err) {
|
|
||||||
return logger.log('warn',
|
|
||||||
`No Empty Inputs found: ${err.err}`);
|
|
||||||
}
|
|
||||||
// For each tx with unmarked inputs
|
|
||||||
return txs.forEach((inputTx) => {
|
|
||||||
inputTx.inputs.forEach((input) => {
|
|
||||||
const txHash = input.prevout.hash;
|
|
||||||
const outIdx = input.prevout.index;
|
|
||||||
|
|
||||||
return getTxById(txHash, (error, tx) => {
|
|
||||||
if (error || !tx) {
|
|
||||||
// Mongo save is async. Bcoin is kinda sync... Does not mean the tx will not be found
|
|
||||||
return logger.log('warn',
|
|
||||||
`No Tx found: ${txHash} ${error}`);
|
|
||||||
}
|
|
||||||
return updateInput(inputTx._id, input._id, tx.outputs[outIdx].value, tx.outputs[outIdx].address);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
auditInputs,
|
|
||||||
getEmptyInputs,
|
getEmptyInputs,
|
||||||
getTopTransactions,
|
getTopTransactions,
|
||||||
getTxById,
|
getTxById,
|
||||||
@ -76,5 +45,4 @@ module.exports = {
|
|||||||
getTxCountByBlock,
|
getTxCountByBlock,
|
||||||
getTxByAddress,
|
getTxByAddress,
|
||||||
getTxCountByAddress,
|
getTxCountByAddress,
|
||||||
updateInput,
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user