Skip to content
chmwang edited this page Oct 5, 2018 · 2 revisions

Nr-service

Nebulas rank offline service

Nebulas node dependency

Compile and install nebulas, tutorial here.

Install dependencies (>=Ubuntu16.04)

Development environment dependency

  • Cpp boost library, Boost version >= 1.67.0
  • Compiler, LLVM/Clang++ version >= 6.0.0
  • Python version 2.7
  • Python restful api framework, Flask version >= 1.0.2

Arangodb dependency

Install with script

$ git clone https://github.com/nebulasio/nr-service.git
$ git submodule update --init
$ cd nr-service/cpp
$ ./prepare.sh

When running with prepare.sh, it will take a long time to compile, build and install depencencies, just be patient.

Install arangodb

$ sudo dpkg -i 3rd_party/arangodb3-3.3.16-1_amd64.deb

Install arangodb python driver

$ sudo pip install python-arango

Install flask

$ sudo pip install Flask
$ sudo pip install flask-restful

Import environment variables

$ source env.set.sh

Build

$ cd /path/to/nr-service
$ mkdir build && cd build
$ cmake .. && make

Run

Run nebulas node

$ cd path/to/go-nebulas
$ ./neb -c mainnet/conf/config.conf

Wait until nebulas node syncs blocks from genesis block to the latest, it takes days or week.

Run arangodb

$ arangod --server.endpoint http+tcp://127.0.0.1:8529

Build transaction graph

$ cd path/to/nr-service
$ python python/arango/arango_graph.py
$ ./cpp/bin/transaction_writer

Running transaction_writer in directory $PATH_TO_NR-SERVICE/cpp/bin will build transaction graph to arangodb colelctions from nebulas node (genesis block to the latest), also takes days or week.

Build nr db collection

$ cd path/to/nr-servie
$ ./cpp/bin/nr --start_ts=xx --end_ts=xx

Build nr db collection from start timestamp to end timestamp with day interval.

Start REST API server

$ cd path/to/nr-service
$ python python/api/api.py

Query

Query transaction by block height or address

$ curl -s "http://localhost:6000/nebulas-transaction?start_block=400100&end_block=400200"
$ curl -s "http://localhost:6000/nebulas-transaction?address=n1Q6JhXKWXCkyvoqymN4LPd6J1tentyKRVF"

Query nebulas rank by date

$ curl -s "http://localhost:6000/nebulas-nr?date=20180620"