mirror of
https://github.com/mempool/mempool.git
synced 2024-11-20 10:21:52 +01:00
SSR: init latest replacements on server side
This commit is contained in:
parent
c5822b11a0
commit
1ae5f05316
@ -3,7 +3,7 @@ import { webSocket, WebSocketSubject } from 'rxjs/webSocket';
|
|||||||
import { WebsocketResponse } from '../interfaces/websocket.interface';
|
import { WebsocketResponse } from '../interfaces/websocket.interface';
|
||||||
import { StateService } from './state.service';
|
import { StateService } from './state.service';
|
||||||
import { Transaction } from '../interfaces/electrs.interface';
|
import { Transaction } from '../interfaces/electrs.interface';
|
||||||
import { Subscription } from 'rxjs';
|
import { firstValueFrom, Subscription } from 'rxjs';
|
||||||
import { ApiService } from './api.service';
|
import { ApiService } from './api.service';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { TransferState, makeStateKey } from '@angular/core';
|
import { TransferState, makeStateKey } from '@angular/core';
|
||||||
@ -224,6 +224,7 @@ export class WebsocketService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startTrackRbfSummary() {
|
startTrackRbfSummary() {
|
||||||
|
this.initRbfSummary();
|
||||||
this.websocketSubject.next({ 'track-rbf-summary': true });
|
this.websocketSubject.next({ 'track-rbf-summary': true });
|
||||||
this.isTrackingRbfSummary = true;
|
this.isTrackingRbfSummary = true;
|
||||||
}
|
}
|
||||||
@ -446,4 +447,30 @@ export class WebsocketService {
|
|||||||
this.websocketSubject.next({'refresh-blocks': true});
|
this.websocketSubject.next({'refresh-blocks': true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async initRbfSummary(): Promise<void> {
|
||||||
|
if (!this.stateService.isBrowser) {
|
||||||
|
const rbfList = await firstValueFrom(this.apiService.getRbfList$(false));
|
||||||
|
if (rbfList) {
|
||||||
|
const rbfSummary = rbfList.slice(0, 6).map(rbfTree => {
|
||||||
|
let oldFee = 0;
|
||||||
|
let oldVsize = 0;
|
||||||
|
for (const replaced of rbfTree.replaces) {
|
||||||
|
oldFee += replaced.tx.fee;
|
||||||
|
oldVsize += replaced.tx.vsize;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
txid: rbfTree.tx.txid,
|
||||||
|
mined: !!rbfTree.tx.mined,
|
||||||
|
fullRbf: !!rbfTree.tx.fullRbf,
|
||||||
|
oldFee,
|
||||||
|
oldVsize,
|
||||||
|
newFee: rbfTree.tx.fee,
|
||||||
|
newVsize: rbfTree.tx.vsize,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.stateService.rbfLatestSummary$.next(rbfSummary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user