Skip to content

Commit

Permalink
chore(webapp): add env variable for block sync tolerance time
Browse files Browse the repository at this point in the history
  • Loading branch information
Torresmorah committed Oct 13, 2022
1 parent 40ef9c1 commit aa5bd78
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ARG react_app_tag
ARG react_app_state_history_enabled
ARG react_app_google_analitic_page_id
ARG react_app_public_re_captcha_key
ARG react_app_sync_tolerance_interval

ENV WORK_DIR /usr/src/app
ENV PATH $WORK_DIR/node_modules/.bin:$PATH
Expand Down Expand Up @@ -63,6 +64,7 @@ ENV REACT_APP_VERSION $react_app_tag
ENV REACT_APP_STATE_HISTORY_ENABLED $react_app_state_history_enabled
ENV REACT_APP_GOOGLE_ANALITIC_PAGE_ID $react_app_google_analitic_page_id
ENV REACT_APP_PUBLIC_RE_CAPTCHA_KEY $react_app_public_re_captcha_key
ENV REACT_APP_SYNC_TOLERANCE_INTERVAL $react_app_sync_tolerance_interval

RUN mkdir -p $WORK_DIR
WORKDIR $WORK_DIR
Expand Down
1 change: 1 addition & 0 deletions webapp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ build-docker: ./Dockerfile
--build-arg react_app_state_history_enabled='$(REACT_APP_STATE_HISTORY_ENABLED)' \
--build-arg react_app_google_analitic_page_id='$(REACT_APP_GOOGLE_ANALITIC_PAGE_ID)' \
--build-arg react_app_public_re_captcha_key='$(REACT_APP_PUBLIC_RE_CAPTCHA_KEY)' \
--build-arg react_app_sync_tolerance_interval='$(REACT_APP_SYNC_TOLERANCE_INTERVAL)' \
.

pull-image: ##@devops Pull the latest image from registry for caching
Expand Down
6 changes: 5 additions & 1 deletion webapp/src/components/EndpointsTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import TableRow from '@mui/material/TableRow'
import Typography from '@mui/material/Typography'

import HealthCheck from '../HealthCheck'
import { eosConfig } from '../../config'

import styles from './styles'
import EndpointInfo from './EndpointInfo'
Expand All @@ -20,11 +21,14 @@ const useStyles = makeStyles(styles)
const EndpointsTable = ({ producers }) => {
const classes = useStyles()
const { t } = useTranslation('endpointsListRoute')
const syncToleranceInterval = eosConfig.syncToleranceInterval

const getStatus = (endpoint) => {
if (endpoint.response.status === undefined) return

if ((new Date() - new Date(endpoint.head_block_time)) / 60000 <= 3) {
const diffBlockTimems = new Date() - new Date(endpoint.head_block_time)

if (diffBlockTimems <= syncToleranceInterval) {
return 'greenLight'
} else {
switch (Math.floor(endpoint.response?.status / 100)) {
Expand Down
1 change: 1 addition & 0 deletions webapp/src/config/eos.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ export const includeDefaultTransaction = process.env
? JSON.parse(process.env.REACT_APP_EOS_INCLUDE_TRANSACTION)
: null
export const blockExplorerUrl = process.env.REACT_APP_BLOCK_EXPLORER_URL
export const syncToleranceInterval = process.env.REACT_APP_SYNC_TOLERANCE_INTERVAL || 180000

0 comments on commit aa5bd78

Please sign in to comment.