-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d97f206
commit 45b8efa
Showing
7 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use strict"; | ||
var _dataSource = _interopRequireDefault(require("../lib/dataSource.js")); | ||
var _Block = require("../services/classes/Block"); | ||
var _BlocksBase = _interopRequireDefault(require("../lib/BlocksBase")); | ||
var _BlockSummary = require("../services/classes/BlockSummary");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} | ||
|
||
update().then(addresses => { | ||
if (addresses.length) { | ||
console.log('Addresses:'); | ||
console.log(JSON.stringify(addresses, null, 2)); | ||
} else { | ||
console.log('There are not invalid token data'); | ||
} | ||
process.exit(0); | ||
}); | ||
|
||
async function update() { | ||
try { | ||
const addresses = {}; | ||
const { collections, db, initConfig } = await (0, _dataSource.default)(); | ||
const collection = collections.Addrs; | ||
const q = { $type: 'object' }; | ||
const cursor = collection.find({ $or: [{ decimals: q }, { totalSupply: q }] }).project({ address: 1, name: 1, blockNumber: 1 }); | ||
while (await cursor.hasNext()) { | ||
let { address, name, blockNumber } = await cursor.next(); | ||
addresses[address] = { address, name }; | ||
console.log(`Address: ${address}, name:${name}`); | ||
let summaries = await (0, _BlockSummary.getBlockSummariesByNumber)(blockNumber, collections); | ||
summaries = summaries.map(({ hash }) => hash); | ||
console.log(`Removing block summaries for block ${blockNumber}`); | ||
await Promise.all([...summaries.map(hash => (0, _BlockSummary.deleteBlockSummaryFromDb)(hash, collections))]); | ||
console.log(`Deleting block ${blockNumber} from db`); | ||
await Promise.all([...summaries.map(hash => (0, _Block.deleteBlockDataFromDb)(hash, blockNumber, collections))]); | ||
console.log(`Getting block ${blockNumber}`); | ||
let block = new _Block.Block(blockNumber, new _BlocksBase.default(db, { initConfig })); | ||
await block.save(); | ||
} | ||
return Object.values(addresses); | ||
} catch (err) { | ||
console.error(err); | ||
process.exit(9); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters