-
Notifications
You must be signed in to change notification settings - Fork 87
Internals
Logan Saether edited this page Jan 25, 2021
·
2 revisions
This page documents the components of the Thousand Validators backend and aims to provide something of a map for how it all works under the surface.
The main entry point of the backend is the src/index.ts
file which handles the initialization of the various components.
In overview these components are:
- Loads the configuration.
- Establishes a connection to the chain via the
ApiHandler
. - Establishes a connection to the Mongo database.
- Clears the stale data from previous runs.
- Establishes a connection to the private Telemetry.
- Starts a cronjob for the node version
Monitor
. - Starts a cronjob to routinely clear the
offlineAccumulated
(the accumulated time that a node was offline). - Creates the
Scorekeeper
which is the main process for starting and ending nomination rounds. - Initializes the candidate data from the configuration.
- Starts the
Scorekeeper
. - Starts the server.
The scorekeeper is the main process which is responsible for beginning and ending rounds. Inside of the scorekeeper there is an addition 3 crons that routinely run to make checks for various actions.
-
validityCron
- the validity cron runs every 7 minutes and checks whether the validator candidate is currently valid or not. It caches these values (which will be served via the server endpoints). -
executionCron
- the execution cron will run every 15 minutes and checks whether there is a delayed transaction that is ready to be executed. If the transaction can be executed, it will execute it. -
mainCron
- the main cron will run every 10 minutes and it end and begin new rounds. It checks whether the next era should have new nominations, and if it does it initiates the nomination transactions.