aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sync.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-02 22:12:24 -0700
committerAdam Soltys <[email protected]>2022-09-02 22:12:24 -0700
commit13352f9b30eed52d2e7d0970d3cbd76f401d6de0 (patch)
treee745685b2d7373ad391431323b0bdf5ff373b55a /lib/sync.js
parentd1cc66d1a02b75f90fbf0c05910777c76228259a (diff)
downloadcoinos-server-13352f9b30eed52d2e7d0970d3cbd76f401d6de0.tar.gz
coinos-server-13352f9b30eed52d2e7d0970d3cbd76f401d6de0.zip
es6 migration
Diffstat (limited to 'lib/sync.js')
-rw-r--r--lib/sync.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/sync.js b/lib/sync.js
index 6fcf8a10..f1d28421 100644
--- a/lib/sync.js
+++ b/lib/sync.js
@@ -4,11 +4,12 @@ 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";
+import store from "./store.js";
+import { err } from "./logging.js";
const init = async () => {
try {
- read(fs.createReadStream("exceptions"), data => exceptions.push(data));
+ read(fs.createReadStream("exceptions"), data => store.exceptions.push(data));
} catch (e) {
warn("couldn't read exceptions file", e.message);
}
@@ -29,14 +30,14 @@ const init = async () => {
}
})
).map(({ address, user, unconfidential }) => {
- if (address && user) addresses[address] = user.username;
- if (unconfidential && user) addresses[unconfidential] = user.username;
+ if (address && user) store.addresses[address] = user.username;
+ if (unconfidential && user) store.addresses[unconfidential] = user.username;
});
} catch (e) {
console.log(e);
}
- payments = (
+ store.payments = (
await db.Payment.findAll({
attributes: ["hash"]
})
@@ -206,7 +207,7 @@ const sync = async () => {
transactions.map(tx => {
if (
!payments.find(p => p.hash === tx.txid) &&
- !exceptions.includes(tx.txid) &&
+ !store.exceptions.includes(tx.txid) &&
!unaccounted.find(a => a.txid === tx.txid) &&
new Date(tx.blocktime * 1000) >= twoWeeksAgo
) {
@@ -276,7 +277,7 @@ const sync = async () => {
try {
await db.transaction(async transaction => {
l("found pending transaction", user.username, amount, hash);
- payments.push(hash);
+ store.payments.push(hash);
let p = await db.Payment.create(
{
account_id,