removed old audit code

This commit is contained in:
tenthirtyone 2017-08-27 22:30:41 -04:00
parent 4ba24bba25
commit 5f7e2b7613
3 changed files with 4 additions and 38 deletions

View File

@ -9,10 +9,8 @@ logger.log('debug',
db.connect(config.mongodb.uri, config.mongodb.options);
db.connection.once('open', () => {
// DB Audit returns best height to node
db.blocks.findMissingBlocks((err, bestBlockHeight) => {
db.blocks.getBestBlockHeight((err, bestBlockHeight) => {
// Pass height to node to start Sync
logger.log('debug',
`Starting Bcoin from best height: ${bestBlockHeight}`);

View File

@ -39,8 +39,8 @@ function getLastBlock(cb) {
.limit(1);
}
// Returns the missing block if it exists. Otherwise, return tip.
function findMissingBlocks(cb) {
// Returns highest consecutive block height
function getBestBlockHeight(cb) {
logger.log('debug',
'Verifying Mongo Blockchain');
return Block.getHeights((err, blocks) => {
@ -59,7 +59,7 @@ function findMissingBlocks(cb) {
}
module.exports = {
findMissingBlocks,
getBestBlockHeight,
getRawBlock,
getTopBlocks,
getLastBlock,

View File

@ -36,39 +36,8 @@ function getTxCountByAddress(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 = {
auditInputs,
getEmptyInputs,
getTopTransactions,
getTxById,
@ -76,5 +45,4 @@ module.exports = {
getTxCountByBlock,
getTxByAddress,
getTxCountByAddress,
updateInput,
};