FIX: adjusted fees; cache invalidation

This commit is contained in:
Overtorment
2019-03-13 23:51:28 +00:00
parent 7c71c5e775
commit a74f1e9ff2
4 changed files with 409 additions and 359 deletions

View File

@@ -12,6 +12,10 @@ export class Paym {
this._isPaid = null;
}
get fee() {
return 0.003;
}
setInvoice(bolt11) {
this._bolt11 = bolt11;
}
@@ -69,7 +73,7 @@ export class Paym {
if (payment && payment.payment_route && payment.payment_route.total_amt_msat) {
// paid just now
this._isPaid = true;
payment.payment_route.total_fees = +payment.payment_route.total_fees + Math.floor(+payment.payment_route.total_amt * 0.01);
payment.payment_route.total_fees = +payment.payment_route.total_fees + Math.floor(+payment.payment_route.total_amt * Paym.fee);
if (this._bolt11) payment.pay_req = this._bolt11;
if (this._decoded) payment.decoded = this._decoded;
}

View File

@@ -173,7 +173,12 @@ export class User {
async saveBalance(balance) {
const key = 'balance_for_' + this._userid;
await this._redis.set(key, balance);
await this._redis.expire(key, 3600 * 24);
await this._redis.expire(key, 3600);
}
async clearBalanceCache() {
const key = 'balance_for_' + this._userid;
return this._redis.del(key);
}
async savePaidLndInvoice(doc) {