mirror of
https://github.com/tornadocash/tornado-relayer.git
synced 2025-08-15 17:40:18 -04:00
one process method for all job types
This commit is contained in:
parent
9cd97feef0
commit
00e17b1687
5 changed files with 86 additions and 103 deletions
17
src/utils.js
17
src/utils.js
|
@ -2,6 +2,12 @@ const { instances, netId } = require('../config')
|
|||
const { poseidon } = require('circomlib')
|
||||
const { toBN, toChecksumAddress } = require('web3-utils')
|
||||
|
||||
const jobType = Object.freeze({
|
||||
TORNADO_WITHDRAW: 'TORNADO_WITHDRAW',
|
||||
MINING_REWARD: 'MINING_REWARD',
|
||||
MINING_WITHDRAW: 'MINING_WITHDRAW',
|
||||
})
|
||||
|
||||
const sleep = ms => new Promise(res => setTimeout(res, ms))
|
||||
|
||||
function getInstance(address) {
|
||||
|
@ -17,16 +23,6 @@ function getInstance(address) {
|
|||
return null
|
||||
}
|
||||
|
||||
// async function setSafeInterval(func, interval) {
|
||||
// try {
|
||||
// await func()
|
||||
// } catch (e) {
|
||||
// console.error('Unhandled promise error:', e)
|
||||
// } finally {
|
||||
// setTimeout(() => setSafeInterval(func, interval), interval)
|
||||
// }
|
||||
// }
|
||||
|
||||
const poseidonHash = items => toBN(poseidon(items).toString())
|
||||
const poseidonHash2 = (a, b) => poseidonHash([a, b])
|
||||
|
||||
|
@ -59,4 +55,5 @@ module.exports = {
|
|||
poseidonHash2,
|
||||
sleep,
|
||||
when,
|
||||
jobType,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue