Skip to content
Snippets Groups Projects
Select Git revision
  • master default protected
  • graph
  • timeserie
  • v0.0.4
4 results

duniter-indexer

  • Clone with SSH
  • Clone with HTTPS
  • duniter-indexer

    Usage for production

    Launch

    Start docker with prod profile:

    docker-compose -f docker-compose.yaml -f docker-compose.prod.yaml up -d

    It will start four services :

    The Duniter mirror will start syncing on the blockchain, you can check the current block with polkadotjs.

    Complete reset

    Shutdown all Indexer's containers and remove any data:

    docker-compose down --volumes --remove-orphans

    Then rebuild the full Indexer image:

    docker-compose -f docker-compose.yaml -f docker-compose.prod.yaml build

    The --volumes option erases any previous data from the stack (i.e. both indexed data and blockchain data).

    Restarting the stack will then engage a new full synchronization.

    Usage for development

    Requirements:

    • pnpm (which is a better version of npm, node package manager)

    Start the stack

    Start docker (hasura + postgresql + duniter-v2s stack):

    docker-compose -f docker-compose.yaml -f docker-compose.dev.yaml up -d

    It will start three services :

    Start the Indexer App

    1. Dependencies :
    pnpm install

    Start dev mode using Vite:

    To start the indexer in dev mode, run

    pnpm dev

    You will have to make a http request on port 3000 (or the one which is displayed) to start the indexation.

    Then you will see logs of the indexation happening. The full indexation should take ~30 min on the local node.

    Start test mode using Vitest:

    pnpm test

    Start test mode with coverage:

    pnpm coverage

    Compile typescript to javascript:

    pnpm build

    Start for production:

    pnpm start

    You should see the app indexing blocks in the output logs:

    [20:21:12.328] INFO: Server listening at http://0.0.0.0:3000
    [20:21:12.338] INFO: Indexing past blocks...
    [20:21:12.877] INFO: Has some blocks to index.
    [20:21:15.062] INFO: Indexing block#100
    ...

    Development for Hasura

    Initialize Hasura:

    First install Hasura command line interface

    Then in your duniter-indexer folder run

    hasura migrate apply
    hasura metadata apply

    Open hasura console:

    Read only : http://localhost:8080

    Dev mode at http://localhost:9695 : open new terminal and:

    pnpm hc

    Code

    • Main file: src/app.ts
    • Configure logger: src/logger.ts
    • Change port in .env

    Docs

    Ressources