fix: digest auth request queue remake
This commit is contained in:
parent
c8f5e471be
commit
35a0512ab5
4 changed files with 46 additions and 22 deletions
|
|
@ -4,7 +4,6 @@ const uuid = require('uuid')
|
|||
const fs = require('fs')
|
||||
const _ = require('lodash/fp')
|
||||
const request = require('request-promise')
|
||||
const Queue = require('queue-promise')
|
||||
const { utils: coinUtils } = require('@lamassu/coins')
|
||||
|
||||
const options = require('../../options')
|
||||
|
|
@ -12,7 +11,7 @@ const options = require('../../options')
|
|||
const blockchainDir = options.blockchainDir
|
||||
|
||||
module.exports = {
|
||||
fetch, fetchDigest, createDigestRequest, parseConf, rpcConfig
|
||||
fetch, fetchDigest, parseConf, rpcConfig
|
||||
}
|
||||
|
||||
function fetch (account = {}, method, params) {
|
||||
|
|
@ -50,17 +49,6 @@ function fetch (account = {}, method, params) {
|
|||
})
|
||||
}
|
||||
|
||||
const DIGEST_QUEUE = new Queue({
|
||||
concurrent: 1,
|
||||
interval: 100,
|
||||
start: false
|
||||
})
|
||||
|
||||
function createDigestRequest (account = {}, method, params = []) {
|
||||
DIGEST_QUEUE.enqueue(() => fetchDigest(account, method, params))
|
||||
return DIGEST_QUEUE.dequeue()
|
||||
}
|
||||
|
||||
function generateDigestOptions (account = {}, method, params) {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json'
|
||||
|
|
@ -93,11 +81,6 @@ function fetchDigest(account = {}, method, params = []) {
|
|||
const options = generateDigestOptions(account, method, params)
|
||||
return request(options)
|
||||
})
|
||||
.then((res) => {
|
||||
const r = JSON.parse(res)
|
||||
if (r.error) throw r.error
|
||||
return r.result
|
||||
})
|
||||
}
|
||||
|
||||
function split (str) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue