Git Product home page Git Product logo

farcaster-indexer's Introduction

Farcaster Indexer

This is an indexer that listens for messages from a Farcaster Hub and inserts relevant data into a postgres database.

The most performant way to run this is to co-locate everything (hub, node app, postgres, redis) on the same machine. I recommend Latitude (referral code for $200 of free credits).

How to run

Clone this repo

git clone -b hubs https://github.com/gskril/farcaster-indexer.git

Install dependencies

yarn install

Create a .env file with your hub, database, and redis connection details

cp .env.example .env

Run the latest database migrations

yarn kysely:migrate

Run the indexer

# Recommended to get the full state. You only need to run this once.
# Streaming will start after the backfill is complete.
yarn run backfill

# Ignores backfill and start streaming from the latest recorded event.
# You should run this after one initial backfill.
yarn start

How it works

  • Backfill and streaming are separate processes.
  • Every operation is run through BullMQ for better concurrency and error handling.
  • For backfill, the indexer adds all FIDs (in batches of 100) to a queue and processes them in parallel. The WORKER_CONCURRENCY environment variable controls how many workers are spawned.
  • Once backfill is complete, the indexer subscribes to a hub's event stream and processes messages as they arrive. BullMQ is used as middleware to ensure that hub events are getting handled fast enough, otherwise the stream will disconnect.

Extras

If you want to add search functionality, you can manually apply the SQL migration at src/db/search-migrations.sql

farcaster-indexer's People

Contributors

gskril avatar zachterrell57 avatar dependabot[bot] avatar alexpaden avatar davidfurlong avatar psatyajeet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Krungtep avatar Summer avatar ๐Ÿฅท๐ŸผJ๐ŸŽฉO๊™ฐK๊™ฐE๐Ÿ”„R๐Ÿฒ avatar Cryptopunk13(soon1) avatar  avatar Sviataslau avatar fotilab avatar Rosemary avatar Alinka avatar  avatar Anna avatar Angelina avatar Danu yaha avatar TrequanToten avatar ElsiemaeGosda avatar HoffMoustafa01 avatar Bobia avatar Alex avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Magic โˆž $ ๐Ÿคด King โˆž $ ๐Ÿคด avatar Straw Hat Luffy avatar

Forkers

degensaitama

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.