Create working template for the new blocks page

This commit is contained in:
nymkappa
2022-03-10 18:35:37 +01:00
parent 77334e130d
commit 0e0331d8ab
8 changed files with 248 additions and 4 deletions

View File

@@ -339,7 +339,7 @@ class Blocks {
return blockExtended;
}
public async $getBlocksExtras(fromHeight: number): Promise<BlockExtended[]> {
public async $getBlocksExtras(fromHeight: number, limit: number = 15): Promise<BlockExtended[]> {
try {
loadingIndicators.setProgress('blocks', 0);
@@ -360,7 +360,7 @@ class Blocks {
}
let nextHash = startFromHash;
for (let i = 0; i < 10 && currentHeight >= 0; i++) {
for (let i = 0; i < limit && currentHeight >= 0; i++) {
let block = this.getBlocks().find((b) => b.height === currentHeight);
if (!block && Common.indexingEnabled()) {
block = this.prepareBlock(await this.$indexBlock(currentHeight));

View File

@@ -658,7 +658,7 @@ class Routes {
public async getBlocksExtras(req: Request, res: Response) {
try {
res.json(await blocks.$getBlocksExtras(parseInt(req.params.height, 10)))
res.json(await blocks.$getBlocksExtras(parseInt(req.params.height, 10), 15));
} catch (e) {
res.status(500).send(e instanceof Error ? e.message : e);
}