This commit is contained in:
einhornimmond 2026-02-27 16:32:58 +01:00
parent b94d6ae89a
commit 94436bfc54
4 changed files with 15 additions and 18 deletions

View File

@ -21,11 +21,7 @@ export class Context {
public cache: KeyPairCacheManager
private timeUsed: Profiler
constructor(
logger: Logger,
db: MySql2Database,
cache: KeyPairCacheManager
) {
constructor(logger: Logger, db: MySql2Database, cache: KeyPairCacheManager) {
this.logger = logger
this.db = db
this.cache = cache

View File

@ -54,10 +54,8 @@ export async function loadCommunities(db: MySql2Database): Promise<CommunityDb[]
.from(communitiesTable)
.innerJoin(usersTable, eq(communitiesTable.communityUuid, usersTable.communityUuid))
.where(
and(
isNotNull(communitiesTable.communityUuid),
sql`${usersTable.createdAt} > '2000-01-01'`),
)
and(isNotNull(communitiesTable.communityUuid), sql`${usersTable.createdAt} > '2000-01-01'`),
)
.orderBy(asc(communitiesTable.id))
.groupBy(communitiesTable.communityUuid)

View File

@ -125,7 +125,7 @@ export class RemoteTransactionsSyncRole extends AbstractSyncRole<TransactionDb>
publicKey: MemoryBlockPtr,
): AccountBalances {
this.accountBalances.clear()
// try to use same coins from this community
let lastBalance = this.getLastBalanceForUser(
publicKey,
@ -133,11 +133,10 @@ export class RemoteTransactionsSyncRole extends AbstractSyncRole<TransactionDb>
coinCommunityId,
)
if (
coinCommunityId != communityContext.communityId &&
(
lastBalance.getBalance().equal(GradidoUnit.zero()) ||
coinCommunityId !== communityContext.communityId &&
(lastBalance.getBalance().equal(GradidoUnit.zero()) ||
lastBalance.getBalance().calculateDecay(lastBalance.getDate(), item.balanceDate).lt(amount))
) {
) {
// don't work, so we use or own coins
lastBalance = this.getLastBalanceForUser(
publicKey,
@ -146,8 +145,12 @@ export class RemoteTransactionsSyncRole extends AbstractSyncRole<TransactionDb>
)
}
if (
lastBalance.getBalance().calculateDecay(lastBalance.getDate(), item.balanceDate).add(amount).lt(GradidoUnit.zero())
&& communityContext.foreign
lastBalance
.getBalance()
.calculateDecay(lastBalance.getDate(), item.balanceDate)
.add(amount)
.lt(GradidoUnit.zero()) &&
communityContext.foreign
) {
this.accountBalances.add(new AccountBalance(publicKey, GradidoUnit.zero(), coinCommunityId))
return this.accountBalances
@ -156,7 +159,7 @@ export class RemoteTransactionsSyncRole extends AbstractSyncRole<TransactionDb>
try {
lastBalance.updateLegacyDecay(amount, item.balanceDate)
} catch (e) {
if (e instanceof NegativeBalanceError) {
if (e instanceof NegativeBalanceError) {
this.logLastBalanceChangingTransactions(publicKey, communityContext.blockchain, 1)
throw e
}

View File

@ -51,7 +51,7 @@ export class UsersSyncRole extends AbstractSyncRole<UserDb> {
gt(usersTable.id, lastIndex.id),
),
),
isNotNull(usersTable.communityUuid)
isNotNull(usersTable.communityUuid),
),
)
.orderBy(asc(usersTable.createdAt), asc(usersTable.id))