queued status
This commit is contained in:
parent
f011b6f9c5
commit
1af36c8475
@ -1,6 +1,6 @@
|
|||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
|
|
||||||
const jobType = require('./jobTypes')
|
const { jobType } = require('./constants')
|
||||||
const tornConfig = require('torn-token')
|
const tornConfig = require('torn-token')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
netId: Number(process.env.NET_ID) || 42,
|
netId: Number(process.env.NET_ID) || 42,
|
||||||
|
20
src/constants.js
Normal file
20
src/constants.js
Normal 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,
|
||||||
|
}
|
@ -4,7 +4,7 @@ const {
|
|||||||
getMiningWithdrawInputError,
|
getMiningWithdrawInputError,
|
||||||
} = require('./validator')
|
} = require('./validator')
|
||||||
const { postJob } = require('./queue')
|
const { postJob } = require('./queue')
|
||||||
const jobType = require('./jobTypes')
|
const { jobType } = require('./constants')
|
||||||
|
|
||||||
async function tornadoWithdraw(req, res) {
|
async function tornadoWithdraw(req, res) {
|
||||||
const inputError = getTornadoWithdrawInputError(req.body)
|
const inputError = getTornadoWithdrawInputError(req.body)
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
module.exports = Object.freeze({
|
|
||||||
TORNADO_WITHDRAW: 'TORNADO_WITHDRAW',
|
|
||||||
MINING_REWARD: 'MINING_REWARD',
|
|
||||||
MINING_WITHDRAW: 'MINING_WITHDRAW',
|
|
||||||
})
|
|
@ -2,6 +2,7 @@ const { v4: uuid } = require('uuid')
|
|||||||
const Queue = require('bull')
|
const Queue = require('bull')
|
||||||
const Redis = require('ioredis')
|
const Redis = require('ioredis')
|
||||||
const { redisUrl } = require('./config')
|
const { redisUrl } = require('./config')
|
||||||
|
const { status } = require('./constants')
|
||||||
const redis = new Redis(redisUrl)
|
const redis = new Redis(redisUrl)
|
||||||
|
|
||||||
const queue = new Queue('proofs', redisUrl)
|
const queue = new Queue('proofs', redisUrl)
|
||||||
@ -13,6 +14,7 @@ async function postJob({ type, request }) {
|
|||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
|
status: status.QUEUED,
|
||||||
...request, // proof, args, ?contract
|
...request, // proof, args, ?contract
|
||||||
},
|
},
|
||||||
// { removeOnComplete: true },
|
// { removeOnComplete: true },
|
||||||
|
@ -12,7 +12,7 @@ const miningABI = require('../abis/mining.abi.json')
|
|||||||
const swapABI = require('../abis/swap.abi.json')
|
const swapABI = require('../abis/swap.abi.json')
|
||||||
const { queue } = require('./queue')
|
const { queue } = require('./queue')
|
||||||
const { poseidonHash2, getInstance, fromDecimals } = require('./utils')
|
const { poseidonHash2, getInstance, fromDecimals } = require('./utils')
|
||||||
const jobType = require('./jobTypes')
|
const { jobType, status } = require('./constants')
|
||||||
const {
|
const {
|
||||||
netId,
|
netId,
|
||||||
torn,
|
torn,
|
||||||
@ -42,15 +42,6 @@ const redis = new Redis(redisUrl)
|
|||||||
const redisSubscribe = new Redis(redisUrl)
|
const redisSubscribe = new Redis(redisUrl)
|
||||||
const gasPriceOracle = new GasPriceOracle({ defaultRpc: httpRpcUrl })
|
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() {
|
async function fetchTree() {
|
||||||
const elements = await redis.get('tree:elements')
|
const elements = await redis.get('tree:elements')
|
||||||
const convert = (_, val) => (typeof val === 'string' ? toBN(val) : val)
|
const convert = (_, val) => (typeof val === 'string' ? toBN(val) : val)
|
||||||
|
Loading…
Reference in New Issue
Block a user