didhub-scheduler
v1.0.0
Published
This is the scheduler for DIDHub. It fetches data from the blockchain and store in mongoDB and Redis
Downloads
2
Readme
DIDhub Scheduler
This repo contains scheduler that periodically fetches data from the blockchain and send to the databases. It also contains scheduler that periodically computes statistics based on the nft marketplace data and the domain data.
Running the project in Development or Stage
Install
Install dependencies
yarn
Build and Start
yarn start
Troubleshoot
If you encounter installation error this may help
sudo apt-get install build-essential
Running the project in Production
Install dependencies
yarn
Build
yarn build:ts
Open different terminals with tmux
tmux
Or attach to running terminals with tmux
tmux attach -t {window_number}
Running the corresponding scheduling task in the window
schedule:{scheduler_number}
Project Structure
src/config
constants: Import constants from didhubCore package. These constants includes fields that describe the projects, collections, tokens, contracts used in our project
initData: Code inside this directory overwrites the database collection with the configuration from DIDhubCore. This method is temporary and should be replaced with admin input from the admin dashboard in the future. It is save to not use this code
src/plugins
The plugins defines the modules that will be shared by the schedulers
elasticsearch: The initialisation of elasticsearch cluster connection
mongo: The initialisation of mongoDB connections
redis: The initialisation of redis connections
statistics: The computation of domain statistics. This is set up for didhub website rankings, hotnames etc
web3: The initialisation of node providers. Please modify if you are integrating with new blockchains
support.ts: This file imports the plugins and expose for global usage
src/scheduler
This directory defines all the schedulars that are run at a pre-defined time period
activity: This directory contains schedule tasks that routinely fixes existing data
caching: This directory contains schedule tasks that compute and caches results for our didhub api
domain: This directory contains schedule tasks that fetches data from our supported project. Each sub-directory corresponds to a single project
marketplace: This directory contains schedule tasks that computes secondary market statistics, inlcuidng floor price, hotnames, and manages marketplace orders
meta: This directory contains schedule tasks that computes domain level statistics, including registration, collection, project statistics
misc: This directory contains unused code for fixing data
test: This directory contains schedule tasks for seting up testing database
utils: This directory contains supporting functions such as smart block scanner (helper for fetching events and storing results), evebtFetcher (function that fetchings event from corresponding node provider), and metadata fetching functions
index.ts: this page imports all schedulars can manages which to run on different environment. It also supports schduler groups configuration that group and run schedular of similar blockchain/characteristics.
Learn More
To learn Fastify, check out the Fastify documentation.