diff options
| author | Adam Soltys <[email protected]> | 2020-12-02 01:17:53 -0500 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-12-02 01:17:53 -0500 |
| commit | 245e6afb0d855b7a45e790091c7a77719acf8c90 (patch) | |
| tree | 4326d5f9751932739550b84943e308b44d0a82f6 /routes/swaps.js | |
| parent | c8d888e09c9be64a116da2e4b5c2b1a4f8e10e71 (diff) | |
| download | coinos-server-245e6afb0d855b7a45e790091c7a77719acf8c90.tar.gz coinos-server-245e6afb0d855b7a45e790091c7a77719acf8c90.zip | |
quiet login errors
Diffstat (limited to 'routes/swaps.js')
| -rw-r--r-- | routes/swaps.js | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/routes/swaps.js b/routes/swaps.js index 21551f9e..5205d2ad 100644 --- a/routes/swaps.js +++ b/routes/swaps.js @@ -660,74 +660,6 @@ app.post( }) ); -checkQueue = async () => { - const ws = app.get("ws"); - const txs = []; - - leveldb - .createReadStream() - .on("data", async function(data) { - txs.push({ ...JSON.parse(data.value), key: data.key }); - }) - .on("end", async function(data) { - const rate = (a, b) => a.rate - b.rate; - const time = (a, b) => b.time - a.time; - - const pending = txs.filter(tx => !tx.id); - const completed = txs.filter(tx => tx.id).sort(time); - - const bitcoin = pending - .filter(tx => tx.asset === "bitcoin") - .sort(rate) - .reverse(); - const tether = pending - .filter(tx => tx.asset === "tether") - .sort(rate) - .reverse(); - - const strip = a => - a.map(({ id, key, info, rate, time }) => ({ - id, - key, - info, - rate, - time - })); - - ws && - ws.send( - JSON.stringify({ - completed: strip(completed.slice(0, 3)), - bitcoin: strip(bitcoin.slice(0, 3)), - tether: strip(tether.slice(0, 3)) - }) - ); - - let b, t, tx; - if (bitcoin[0]) b = bitcoin[0].rate - app.get("ask"); - if (tether[0]) t = tether[0].rate - 1 / app.get("bid"); - - if (b > 0 || t > 0) { - if ((b && !t) || b > t) tx = bitcoin[0]; - if ((t && !b) || t > b) tx = tether[0]; - } - - if (tx) { - try { - tx.id = JSON.parse(await finalize(tx.text)).txid; - tx.time = Date.now(); - delete tx.text; - leveldb.put(tx.key, JSON.stringify(tx)); - } catch (e) { - l.info(e); - if (e.includes("Unexpected fees")) leveldb.del(tx.key); - if (e.includes("unsigned inputs")) leveldb.del(tx.key); - if (e.includes("insufficient fee")) leveldb.del(tx.key); - } - } - }); -}; - const parse = info => { const fee = info.legs[0].fee; return [ |
