aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sync.js
diff options
context:
space:
mode:
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,