filecoin-indexer

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2021 License: Apache-2.0, MIT Imports: 1 Imported by: 0

README

filecoin-indexer

Data indexer and API service for the Filecoin network

Requirements

  • Go 1.14+
  • PostgreSQL 10+

Installation

$ go get -u github.com/figment-networks/filecoin-indexer

Usage

$ ./filecoin-indexer --help

Usage of ./filecoin-indexer:
  -cmd string
    	Command to run
  -config string
    	Path to a config file

Executing commands:

$ filecoin-indexer -config path/to/config.json -cmd=COMMAND

Available commands:

Name Description
migrate Migrates the database
rollback Rolls the schema back to the previous version
sync Runs a one-time synchronization job
worker Starts the synchronization worker
server Starts the API server

Configuration

You can configure the indexer using a config file or environment variables.

Config file

Example:

{
  "rpc_endpoint": "5.6.7.8:1234",
  "rpc_timeout": "30s",
  "database_dsn": "dbname=filecoin-indexer",
  "server_addr": "localhost",
  "server_port": 8080,
  "initial_height": 0,
  "batch_size": 100,
  "sync_interval": "1s",
  "metrics_addr": "127.0.0.1",
  "metrics_port": "8090",
  "metrics_path": "/metrics",
  "rollbar_token": "a672d00ae7967e33e6f07a9cbdbefb2a",
  "rollbar_server_root": "/home/deploy/filecoin-indexer",
  "debug": true
}
Environment variables
Name Description Default Value Required
APP_ENV Application environment development Yes
RPC_ENDPOINT Lotus RPC endpoint Yes
RPC_TIMEOUT RPC client timeout 30s No
DATABASE_DSN PostgreSQL database URL Yes
SERVER_ADDR HTTP server address 0.0.0.0 No
SERVER_PORT HTTP server port 8080 No
INITIAL_HEIGHT Initial sync height 0 No
BATCH_SIZE Limit of heights per sync No
SYNC_INTERVAL Interval between sync jobs 1s No
METRICS_ADDR Metrics server address 127.0.0.1 No
METRICS_PORT Metrics server port 8090 No
METRICS_PATH Metrics endpoint path /metrics No
ROLLBAR_TOKEN Rollbar token No
ROLLBAR_SERVER_ROOT Rollbar server root No
DEBUG Debug mode false No

Running Application

Once you have created a database and specified all configuration options, you need to migrate the database:

$ filecoin-indexer -config config.json -cmd=migrate

The synchronization process can be initiated with the command below:

$ filecoin-indexer -config config.json -cmd=sync

To start the API server, you have to run the following command:

$ filecoin-indexer -config config.json -cmd=server

API Reference

Method Path Description
GET /miners List of all storage miners
GET /miners/:address Storage miner details
GET /miners/:address/events List of storage miner events
GET /top_miners List of top 100 storage miners
GET /transactions List of all transactions
GET /accounts/:address Account details
GET /accounts/:address/transactions List of account transactions
GET /events List of all events
GET /health Health check
GET /status Synchronization status

For more information see the Miner Reputation System API on Figment Learn.

Score Calculation

The reputation of storage miners is calculated with the following formula:

Score formula

Where:

Symbol description

Variables
Name Description Weight
Slashes Reciprocal of the number of slashed deals squared 100
Faults Reciprocal of the total number of faults 100
Power Quality-adjusted power divided by network power 100
Sector Size Sector size divided by 32 GiB 10

License

This application is dual-licensed under:

  • MIT License
  • Apache License 2.0

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL