diff options
| author | Adam Soltys <[email protected]> | 2022-09-02 15:06:43 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-02 15:06:43 -0700 |
| commit | d1cc66d1a02b75f90fbf0c05910777c76228259a (patch) | |
| tree | 7b93dc6a2fc0ec9d03676d6b4093fedf9733f128 /lib/sync.js | |
| parent | 3161dd7ee95b6c7d70f8341298dd4fab84cda8b0 (diff) | |
| download | coinos-server-d1cc66d1a02b75f90fbf0c05910777c76228259a.tar.gz coinos-server-d1cc66d1a02b75f90fbf0c05910777c76228259a.zip | |
es6 migration
Diffstat (limited to 'lib/sync.js')
| -rw-r--r-- | lib/sync.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/sync.js b/lib/sync.js index 1a98c121..6fcf8a10 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -4,12 +4,13 @@ import { differenceInDays } from "date-fns"; import fs from "fs"; import read from "../lib/read.js"; import { Op } from "@sequelize/core"; +import { addresses, exceptions } from "./store.js"; const init = async () => { try { read(fs.createReadStream("exceptions"), data => exceptions.push(data)); } catch (e) { - l.warn("couldn't read exceptions file", e.message); + warn("couldn't read exceptions file", e.message); } try { @@ -132,11 +133,11 @@ const sync = async () => { await account.increment({ balance: amount }); - l.info("lightning missing from account", account.id, amount); + l("lightning missing from account", account.id, amount); } } } catch (e) { - l.error( + err( "problem syncing lightning payment", JSON.stringify(missed[i]), e.message, @@ -194,9 +195,9 @@ const sync = async () => { emit(p.user.username, "account", p.account); emit(p.user.username, "payment", p); - l.info("unconfirmed tx", p.user_id, p.hash, p.address); + l("unconfirmed tx", p.user_id, p.hash, p.address); } catch (e) { - l.error("problem confirming payment", p, e.message, e.stack); + err("problem confirming payment", p, e.message, e.stack); } } @@ -214,7 +215,7 @@ const sync = async () => { }); if (unaccounted.length) - l.warn( + warn( "wallet transactions missing from database", unaccounted.map(tx => tx.txid) ); @@ -261,7 +262,7 @@ const sync = async () => { user_id } = invoices[i]; - l.info("unaccounted", address); + l("unaccounted", address); let pending = unaccounted.filter( tx => tx.address === address || tx.address === unconfidential @@ -274,7 +275,7 @@ const sync = async () => { try { await db.transaction(async transaction => { - l.info("found pending transaction", user.username, amount, hash); + l("found pending transaction", user.username, amount, hash); payments.push(hash); let p = await db.Payment.create( { @@ -300,7 +301,7 @@ const sync = async () => { emit(user.username, "payment", p); }); } catch (e) { - l.error( + err( "problem updating pending transaction", hash, e.message, @@ -310,7 +311,7 @@ const sync = async () => { } } } catch (e) { - l.error("sync check failed", e.message, e.stack); + err("sync check failed", e.message, e.stack); } setTimeout(sync, 300000); |
