1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { DBClient } from '../../singletons'
- import { InitiaClient } from '../../InitiaClient'
- import { forEachAsync } from 'useless-helpers'
- async function startCheck(concurrency) {
- const accountsRaw = await DBClient.instance.randomTask2.findMany({
- where: {
- finish: -2,
- },
- take: 10000,
- orderBy: {
- id: 'asc',
- },
- })
- await forEachAsync(
- accountsRaw,
- concurrency,
- async (account, index) => {
- console.log(
- `${index}/${accountsRaw.length}: processing ${account.address},account id: ${account.id}`,
- )
- // await faucetAccount(account.address)
- const client = new InitiaClient(account.mnemonic, true)
- try {
- const gasGot = await client.gasGot()
- if (gasGot) {
- await DBClient.instance.randomTask2.update({
- where: { id: account.id },
- data: { finish: 0 },
- })
- } else {
- // await DBClient.instance.randomTask2.update({
- // where: { id: account.id },
- // data: { finish: -2 },
- // })
- }
- } catch (e) {
- // console.log(e)
- }
- },
- { retries: 3 },
- )
- }
- startCheck(50)
|