Defer db access to fix failing tests

This commit is contained in:
Mononaut committed 2024-06-04 20:57:40 +00:00
1 parent 9a838c7269
commit 42c60fd991
3 files changed
+11 -11

No files matched your search

+8 -9
View File
@@ -24,15 +24,6 @@ class MempoolBlocks {
private pools: { [id: number]: PoolTag } = {};
constructor() {
PoolsRepository.$getPools().then(allPools => {
this.pools = {};
for (const pool of allPools) {
this.pools[pool.uniqueId] = pool;
}
});
}
public getMempoolBlocks(): MempoolBlock[] {
return this.mempoolBlocks.map((block) => {
return {
@@ -54,6 +45,14 @@ class MempoolBlocks {
return this.mempoolBlockDeltas;
}
public async updatePools$(): Promise<void> {
const allPools = await PoolsRepository.$getPools();
this.pools = {};
for (const pool of allPools) {
this.pools[pool.uniqueId] = pool;
}
}
private calculateMempoolDeltas(prevBlocks: MempoolBlockWithTransactions[], mempoolBlocks: MempoolBlockWithTransactions[]): MempoolBlockDelta[] {
const mempoolBlockDeltas: MempoolBlockDelta[] = [];
for (let i = 0; i < Math.max(mempoolBlocks.length, prevBlocks.length); i++) {