replace client recent blocks on reorg

This commit is contained in:
Mononaut
2023-07-08 01:07:06 -04:00
parent 9cf961c667
commit e8c703fdbc
20 changed files with 153 additions and 99 deletions

View File

@@ -29,11 +29,12 @@ export class RewardStatsComponent implements OnInit {
// Or when we receive a newer block, newer than the latest reward stats api call
this.stateService.blocks$
.pipe(
switchMap((block) => {
if (block[0].height <= this.lastBlockHeight) {
switchMap((blocks) => {
const maxHeight = blocks.reduce((max, block) => Math.max(max, block.height), 0);
if (maxHeight <= this.lastBlockHeight) {
return []; // Return an empty stream so the last pipe is not executed
}
this.lastBlockHeight = block[0].height;
this.lastBlockHeight = maxHeight;
return this.apiService.getRewardStats$();
})
)