Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] Hero Graph remove old block for new block #101

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const config = {
process.env.REACT_APP_EXPLORER_API_DOMAIN + '/ws'
),
tokenName: process.env.REACT_APP_TOKEN_NAME || 'tXTR',
initialBlockCount: +(process.env.REACT_APP_INITIAL_BLOCK_COUNT || 100)
initialBlockCount: +(process.env.REACT_APP_INITIAL_BLOCK_COUNT || 100),
maxBlocks: +(process.env.REACT_APP_MAX_BLOCKS || 100)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the env to the .env.sample file

};
export default config;
5 changes: 5 additions & 0 deletions src/helpers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export async function fetchBlocksData(limit = 30, sort = 'desc', page = 0): Prom
if (sort === 'desc') {
blocks.blocks.sort((a, b) => b.block.header.height - a.block.header.height);
}

if(blocks.blocks.length > config.maxBlocks) {
blocks.blocks.splice(-1,1);
}
Comment on lines +29 to +31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to the redux action. Also how do we know that we only need to reduce by 1? We could've fetched 200 blocks.


return blocks;
}

Expand Down