badger/api
2023-03-08 17:17:28 -06:00
..
abis fix: gas report 2023-03-05 01:36:25 +00:00
api feat: openapi + api url kwargs + requirements 2023-03-07 23:55:35 -06:00
badge fix: badge form and generated images 2023-03-08 17:17:28 -06:00
balance fix: api + db + listener integration 2023-03-05 19:12:23 -06:00
indexer fix: remove comments 2023-03-07 22:28:50 -06:00
ipfs fix: FINALLY caught the image error 2022-11-07 16:20:10 -06:00
organization feat: lots of fixes 2023-03-06 19:48:24 -06:00
utils fix: chain localization 2023-03-05 22:06:56 -06:00
wallet fix: updated api 2023-03-05 18:21:58 -06:00
.gitignore fix: database socket 2022-10-14 15:29:06 -05:00
abis.py fix: parallel extractor 2023-03-01 23:27:01 -06:00
Dockerfile.dev fix: chain support for listeners 2023-03-05 20:11:59 -06:00
manage.py Base contract 2022-07-06 16:52:00 -05:00
Procfile feat: deploy Procfile 2022-10-14 14:49:30 -05:00
README.md fix: indexer docs 2023-03-04 15:42:24 -06:00
requirements.txt feat: openapi + api url kwargs + requirements 2023-03-07 23:55:35 -06:00
runtime.txt fix: granular runtime 2022-10-14 14:53:46 -05:00

Badger API

The interface backend of Badger is driven by Django, Redis and Postgres. The database is prepared to support simple HTTP requests and WebSockets.

The Indexer Checking The Chain

There are many types of EVM listeners available, each with their own purpose. Badger includes 2 key types of listeners:

  • backfill - A one-time listener that will backfill the database with all events of a given type.
  • listen_for - A listener that will listen for new events of a given type.

A backfill is used to populate/seed the database with all events of a given type. For Badger, in the local configuration this is not required as the node will always start at block 0. In a production environment, backfill should be ran on a regular basis to ensure that even when blocks are missed, the database will be up to date.

Given a long horizon, a backfill can take a long time to complete. To mitigate this, the backfill command is designed to be run in parallel. The backfill command will spawn a number of processes equal to the number of cores on the machine. Each process will listen for events of a given type and write them to the database. The backfill command will not exit until all processes have completed.

The listen_for command is designed to be run in a long-running process. It will listen for new events of a given type and write them to the database. The listen_for command will not exit until the process is killed and if it crashes, it will be restarted by Docker.

By default, everything is configured for you in the docker-compose.yml file.

When using management commands, the available types are:

  • organization
  • badge

in place of the <type>

docker-compose run --rm badger_server python manage.py backfill_<type>
docker-compose run --rm badger_server python manage.py listen_for_<type>