GithubHelp home page GithubHelp logo

unbanksytv / bountiesapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bounties-network/bountiesapi

0.0 1.0 0.0 47.57 MB

The caching layer of the Bounties Network

Python 48.65% HTML 41.78% Shell 0.58% JavaScript 0.84% Dockerfile 0.11% CSS 0.51% Smarty 0.11% TypeScript 7.42%

bountiesapi's Introduction

Bounties-API

CircleCI codecov

Deployed Production API - Mainnet Contract Deployed Rinkeby API - Rinkeby Contract great for testing

Setup

Download Docker stable version Install hasura cli, script in ./graphql/install-hasura-cli.sh

docker volume create --name redis_bounties
docker volume create --name psql_bounties
docker-compose up

Locally, you will now be syncing directly from the contract. You may access the api at:

http://locahost:8000

The API will automatically restart if you make code changes. To turn off the services, run docker-compose down. Keep in mind, the volumes make it so your DB and redis cache will be in the same state if you start the services again with docker-compose up. If you would like to wipe out your databases and start again, then run:

docker-compose down
docker volume rm redis_bounties
docker volume rm psql_bounties
docker volume create --name redis_bounties
docker volume create --name psql_bounties
docker-compose up
cd graphql/hasura
hasura migrate apply

If you add additional packages to a package.json or to the requirements.txt file, you'll need to rebuild the individual service. To rebuild all services, you may run:

docker-compose down
docker-compose build
docker-compose up

By default, the sync will connect to mainNet. To change to a rinkeby sync or other, you will need to adjust the eth_network key in the environment file. As an example, it can be changed to eth_network=rinkeby.

API Schema and Documentation

Visit the production or rinkeby endpoint. Both default to the swagger documentation ui. The local version also serves the documentation.

Architecture

Architecture Diagram

The frontend or client can be any third party service or collaborator that integrates with the standard bounties ethereum contract. This API works as a caching and storage layer for what is input into the standard bounties contract. Due to storage costs, the contract puts the majority of the data into IPFS. To understand further, read the documentation on the standard bounties contract.

The contract subscriber listens for events from the contract. In the case a resync is occurring, it will listen to all historical events, starting from the genesis block. In order for the subscriber to know what it has already accessed, the redis cache stores a currentBlock key. Additionally, the redis cache stores the hashes for all transactions that have already been evaluated and stored to the db. The contract subscriber will ignore transactions that have already been written, and will not search through blocks prior to the currentBlock key. When the subscriber picks up on a new event, it looks up the original transaction via web3 and passes the event data along with the original contract function inputs to SQS. An SQS fifo queue is used. This means we will never have duplication on keys and all events will be handled in the order they come through.

The bounties subscriber listens to events that have been passed into SQS by the contract subscriber. The bounties subscriber uses the data from the event, the inputs to the original contract function, and the IPFS stored data to write the appropriate values to the DB via django.

The bounties api is a django API that serves the data that has been written by the bounties subscriber and other running jobs.

sql_jobs are scheduled jobs to help enrich the data. category_ranks.sql produces a table that ranks the most commonly used categories and converges duplicated names.

Other Jobs include:

Extra

Local JWT

- Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWFsbG93ZWQtcm9sZXMiOlsidXNlciJdLCJ4LWhhc3VyYS1kZWZhdWx0LXJvbGUiOiJ1c2VyIiwieC1oYXN1cmEtdXNlci1pZCI6IjEifX0.vmBpGhlIyPKyUvs6symo8BvViR--VDX_6EmGMoSoTgg

- JWT|Django Secret dnf5mn4NmYhqO8eaxU5RZy3yC9ogzHSKO4iTWuubqUnJyAzjEbRPzH9KCf2w3p5cu0exQ9TV1LVuXv-yOf8

bountiesapi's People

Contributors

villanuevawill avatar codeluggage avatar mbeylin avatar rej156 avatar heycorwin avatar zoek1 avatar lightclient avatar hshar7 avatar mrbrianhobo avatar pfilippi24 avatar pgrzesik avatar gillichu avatar subramanianv avatar leonprou avatar

Watchers

 avatar

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.