blockstack-crawler

command module
v0.0.0-...-67d7764 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: MIT Imports: 2 Imported by: 0

README

Blockstack Crawler

Blockstack Crawler queries the Blockstack API and persists relevant data into database and storage.

It currently supports Badger or Bolt as the underlying database. Storage type is limited to local for now.

Note: Current functionality is limited, but the repository was designed with extensibility in mind. Additional commands, as well as different database and storage types are a WIP.

Commands

Below is a list of currently supported commands:

Global Flags
Flags:
      --api-host string     host api to query (default "core.blockstack.org")
  -p, --api-port uint16     Port to access API (default 443)
      --api-scheme string   URL scheme for API (default "https")
      --datadir string      data directory that stores embedded database and storage information (default "$HOME/.blockstack-crawler/data")
      --db string           type of database to store results in (default "bolt")
  -h, --help                help for blockstack-crawler
      --store string        type of storage to use for persisting file data (default "local")
Names
Usage:
  blockstack-crawler names [OPTIONS] [flags]

Flags:
  -b, --batch uint         number of concurrent requests to make to API (default 50)
  -f, --format string      output names in prettified json or text format (default "json")
  -h, --help               help for names
  -o, --outfile string     write results to file rather than printing to standard output
  -s, --since string       ISO 8601 formatted date [YYYY-MM-DD]
  -t, --timeout duration   timeout for API requests (default 2m0s)

Global Flags:
      --api-host string     host api to query (default "core.blockstack.org")
  -p, --api-port uint16     Port to access API (default 443)
      --api-scheme string   URL scheme for API (default "https")
      --datadir string      data directory that stores embedded database and storage information (default "$HOME/.blockstack-crawler/data")
      --db string           type of database to store results in (default "bolt")
      --store string        type of storage to use for persisting file data (default "local")
Users

./blockstack-crawler names

Note: Users are treated as names to conform to Blockstack API

  • Returns the set of users for each app at the current date. Database and storage are first queried for the data. If not found, a worker will query the remote Blockstack API for that information.

  • Multiple requests are made and processed concurrently to improve performance.

  • The aggregated data is then transformed, persisted in database and storage, and returned to the user.

New Users

./blockstack-crawler names --since YYYY-MM-DD

  -s, --since string    ISO 8601 formatted date [YYYY-MM-DD]

New users since a given date can be displayed and follows the general steps outlined below:

  • Retrieve set of users at current date. The database and storage will first be queried to check if the data already exists. If not, the remote Blockstack API is queried for the data.
  • Get set of users from database or storage at the date specified by the since flag. If no users exist at that date, the command will return an error and exit.
  • The set of new users can be printed to standard output, or written to file in text or JSON format.

Note: Fetching the latest users may take anywhere from 3 seconds to 1-2 minutes depending on API response times, network load, etc.

Example

./blockstack-crawler names --since 2018-06-13

2018/06/18 14:17:07 creating new name worker
2018/06/18 14:17:07 attempting to retrieve names
{
    "blockstack": [
        ""
    ],
    "graphite": [
        ""
    ],
    "helloworld": [
        ""
    ],
    "id": [
        "",
        "sportscenter.id",
        "drones.id",
        "brave.id",
        "boringcompany.id",
        "whatsapp.id",
        "dietze.id",
        "virgin.id",
        "russia.id",
        "danielfritsche.id",
        "norbert.id",
        "decred.id",
        "tassilo.id",
        "praveen_inaganti.id",
        "stripe.id",
        "uniqlo.id",
        "contact.id",
        "linemuller.id",
        "krisguy.id"
    ],
    "podcast": [
        ""
    ]
}
Daily New Users

It is recommended to use an external process manager such as systemd, init.d or upstart to run this program as a background daemon.

cron can be used with the program to query and report new users each day.

An example Dockerfile and scripts are provided in tools/docker and can be used to launch a container that reports daily new users.

To use the image:

# clone the repo to $GOPATH
git clone https://github.com/Wazzymandias/blockstack-crawler $GOPATH/src/github.com/Wazzymandias/blockstack-crawler

# build the docker image
cd $GOPATH/src/github.com/Wazzymandias/blockstack-crawler/tools/docker

./build-user-watcher.sh

# start the docker image
./watch-users.sh
Install
Requirements
# clone the repo
git clone https://github.com/Wazzymandias/blockstack-crawler $GOPATH/src/github.com/Wazzymandias/blockstack-crawler

# enter directory 
cd $GOPATH/src/github.com/Wazzymandias/blockstack-crawler/

# install glide if it doesn't exist
go get -u github.com/Masterminds/glide 

# install dependencies
glide install 

# build or install binary 
go build -v # OR 
go install -v

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package cmd implements CLI commands that perform Blockstack related operations
Package cmd implements CLI commands that perform Blockstack related operations
Package config stores all configuration related variables and constants, and stores any arguments passed by the user
Package config stores all configuration related variables and constants, and stores any arguments passed by the user
db
Package db implements interfaces to different database types and provides specification of BlockstackDB and DB operations, such that any new database can be used as long as it implements those methods.
Package db implements interfaces to different database types and provides specification of BlockstackDB and DB operations, such that any new database can be used as long as it implements those methods.
badger
package badger implements database operations for BadgerDB
package badger implements database operations for BadgerDB
bolt
package bolt implements operations using Bolt as the underlying database
package bolt implements operations using Bolt as the underlying database
Package routes contains Blockstack API related paths and functions to make HTTP requests using specified API configuration settings.
Package routes contains Blockstack API related paths and functions to make HTTP requests using specified API configuration settings.
Package storage provides interfaces to different storage types to persist data
Package storage provides interfaces to different storage types to persist data
Package worker implements various workers to process requests sent by the user
Package worker implements various workers to process requests sent by the user

Jump to

Keyboard shortcuts

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