queued status

This commit is contained in:
Alexey 2020-11-27 17:21:56 +01:00
parent f011b6f9c5
commit 1af36c8475
6 changed files with 25 additions and 17 deletions

View File

@ -1,6 +1,6 @@
require('dotenv').config()
const jobType = require('./jobTypes')
const { jobType } = require('./constants')
const tornConfig = require('torn-token')
module.exports = {
netId: Number(process.env.NET_ID) || 42,

20
src/constants.js Normal file
View File

@ -0,0 +1,20 @@
const jobType = Object.freeze({
TORNADO_WITHDRAW: 'TORNADO_WITHDRAW',
MINING_REWARD: 'MINING_REWARD',
MINING_WITHDRAW: 'MINING_WITHDRAW',
})
const status = Object.freeze({
QUEUED: 'QUEUED',
ACCEPTED: 'ACCEPTED',
SENT: 'SENT',
MINED: 'MINED',
RESUBMITTED: 'RESUBMITTED',
CONFIRMED: 'CONFIRMED',
FAILED: 'FAILED',
})
module.exports = {
jobType,
status,
}

View File

@ -4,7 +4,7 @@ const {
getMiningWithdrawInputError,
} = require('./validator')
const { postJob } = require('./queue')
const jobType = require('./jobTypes')
const { jobType } = require('./constants')
async function tornadoWithdraw(req, res) {
const inputError = getTornadoWithdrawInputError(req.body)

View File

@ -1,5 +0,0 @@
module.exports = Object.freeze({
TORNADO_WITHDRAW: 'TORNADO_WITHDRAW',
MINING_REWARD: 'MINING_REWARD',
MINING_WITHDRAW: 'MINING_WITHDRAW',
})

View File

@ -2,6 +2,7 @@ const { v4: uuid } = require('uuid')
const Queue = require('bull')
const Redis = require('ioredis')
const { redisUrl } = require('./config')
const { status } = require('./constants')
const redis = new Redis(redisUrl)
const queue = new Queue('proofs', redisUrl)
@ -13,6 +14,7 @@ async function postJob({ type, request }) {
{
id,
type,
status: status.QUEUED,
...request, // proof, args, ?contract
},
// { removeOnComplete: true },

View File

@ -12,7 +12,7 @@ const miningABI = require('../abis/mining.abi.json')
const swapABI = require('../abis/swap.abi.json')
const { queue } = require('./queue')
const { poseidonHash2, getInstance, fromDecimals } = require('./utils')
const jobType = require('./jobTypes')
const { jobType, status } = require('./constants')
const {
netId,
torn,
@ -42,15 +42,6 @@ const redis = new Redis(redisUrl)
const redisSubscribe = new Redis(redisUrl)
const gasPriceOracle = new GasPriceOracle({ defaultRpc: httpRpcUrl })
const status = Object.freeze({
ACCEPTED: 'ACCEPTED',
SENT: 'SENT',
MINED: 'MINED',
CONFIRMED: 'CONFIRMED',
FAILED: 'FAILED',
RESUBMITTED: 'RESUBMITTED',
})
async function fetchTree() {
const elements = await redis.get('tree:elements')
const convert = (_, val) => (typeof val === 'string' ? toBN(val) : val)