File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ import type { Block } from '@/types';
66import { hashTx } from '@/libs' ;
77import { fromBase64 } from '@cosmjs/encoding' ;
88
9+ const FETCH_ALL_BLOCKS = import . meta. env . VITE_FETCH_ALL_BLOCKS || false ;
10+ const RECENT_BLOCKS_LIMIT = import . meta. env . VITE_RECENT_BLOCK_LIMIT || 50 ;
11+
912export const useBaseStore = defineStore ( 'baseStore' , {
1013 state : ( ) => {
1114 return {
@@ -91,7 +94,7 @@ export const useBaseStore = defineStore('baseStore', {
9194 if ( this . recents . findIndex ( ( x ) => x ?. block_id ?. hash === this . latest ?. block_id ?. hash ) === - 1 ) {
9295 const newBlocks = await this . fetchNewBlocks ( ) ;
9396 const combined = [ ...this . recents , ...newBlocks ] ;
94- this . recents = combined . slice ( - 50 ) ;
97+ this . recents = combined . slice ( - RECENT_BLOCKS_LIMIT ) ;
9598 }
9699 return this . latest ;
97100 } ,
@@ -102,6 +105,7 @@ export const useBaseStore = defineStore('baseStore', {
102105 */
103106 async fetchNewBlocks ( ) {
104107 if ( ! this . latest ?. block ?. header ?. height ) return [ ] ;
108+ if ( ! FETCH_ALL_BLOCKS ) return [ this . latest ] ;
105109 const oldHeight = Number ( this . recents [ this . recents . length - 1 ] ?. block ?. header ?. height ) ;
106110 const newHeight = Number ( this . latest . block . header . height ) ;
107111 let newBlocks = [ ] ;
You can’t perform that action at this time.
0 commit comments