🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/consensys/fc-latency-map/manager

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/consensys/fc-latency-map/manager

v0.0.0-20211026125257-336721c56835
Source
Go
Version published
Created
Source

FC Latency Map - Manager

Description

FC Latency Map - Manager allows to get latency measurements

Requirements

Packages

  • swagger
go get -u github.com/go-swagger/go-swagger/cmd/swagger

  • sqlite3
sudo apt install sqlite3

Configuration

Must have an ".env" file with the configurations to run.

Is available an example of configuration on .env.example

cp .env.example .env
KeyValue typeDescription
SERVICE_NAMEstringService name.
FILECOIN_NODE_URLstringLotus Filecoin node url.
FILECOIN_BLOCKS_OFFSETstringFilecoin blocks search offset.
DB_CONNECTIONstringSQLite file path.
RIPE_API_KEYstringRipe Atlas API Key
RIPE_ONE_OFFbooleanOn ping only to get latency. When is 'true' the RIPE_TRACEROUTE_INTERVAL and RIPE_TRACEROUTE_RUNNING_TIME are ignored.
RIPE_TRACEROUTE_INTERVALnumberInterval between ping to get miners latency.
RIPE_TRACEROUTE_RUNNING_TIMEnumberRunning period get latency.
RIPE_PACKETSnumberAmount of packets to ping miners.
RIPE_REQUESTED_PROBESnumberMax number of probes to call miners.
RIPE_PROBES_PER_AIRPORTnumberNumber of probes closest to airports.
NEAREST_AIRPORTSnumberNumber of airports closest to miner.
CONSTANT_AIRPORTSstringAirports JSON file path.
SQL_DEBUGbooleanDisplay SQL debug.
CRON_SCHEDULE_CREATE_MEASURESstringCron time to export measures.
CRON_SCHEDULE_IMPORT_MEASURESstringCron time to import measures.
WEBHOOK_NOTIFY_URLSstringWebhooks links.

Development

  • Run golangci
# run golint-ci
golangci-lint run ./... --fix
  • Install pre-commit hooks
# @ project root
pre-commit install
  • Execute pre-commit manually
# @ project root
pre-commit run --all-files

SQLite commands

  • Open database
sqlite3 data/database.db

SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite>
  • View tables
sqlite> .tables

>>> miners
  • Select miners
sqlite> select * from miners;

>>> 1|2021-09-07 17:04:53.41480159+02:00|2021-09-07 17:04:53.41480159+02:00||dummyAddress|dummyIp
  • Close database
sqlite> .quit

or

sqlite> ^C^C^C

Command-line Interface

Usage

  • Run CLI
go run cmd/cli/main.go
  • Update miners list without offset (it will apply by default the offset from the .env file)
>>> miners-update

or with an offset of 10 (latest block heights)

>>> miners-update 10
  • Parse miners from a given block height
>>> miners-parse 1107781
  • List miners
>>> miners-list
  • Load all the miner from MarketDeals
>>> miners-parse-state-market

Demo

rm data/database.db
go run cmd/cli/main.go miners-parse-state-market
go run cmd/cli/main.go locations-update large
go run cmd/cli/main.go probes-import
go run cmd/cli/main.go probes-update

go run cmd/cli/main.go measures-create
#   wait until have ripe results
go run cmd/cli/main.go measures-get
go run cmd/cli/main.go measures-export

API

The Manager exposes an API to allow health check and metrics request.

Health Check

Open http://localhost:3001/health-check

It should respond:

{
"success": true
}

Metrics

Open http://localhost:3001/metrics

It should respond:

{
"locations": "606",
"miners": "140",
"probes": "1890"
}

Swagger

./swagger.yml

FAQs

Package last updated on 26 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts