Skip to content

psyraxaus/forkmonitor

 
 

Repository files navigation

Fork Monitor Build Status Coverage Status

Development

Install ZeroMQ (for Libbitcoin), e.g. on macOS: brew install zeromq

Install Postgres, e.g. on macOS: brew install postgresql

Install Redis, e.g. on macOS: brew install redis and see instructions.

To use Rails cache, install memcacher, e.g. on macOS: brew install memcached. To toggle cache, use rails dev:cache

Install Python. When using pyenv, use env PYTHON_CONFIGURE_OPTS='--enable-shared' pyenv install VERSION in order for PyCall to work.

Install Ruby 2.7.2 through a version manager such as RVM or rbenv. Install the bundler and foreman gems, then run bundler:

gem install bundler foreman
bundle install --without production

You also need Yarn, a package manager for NodeJS. Once installed, run:

yarn

Run rake secret and then edit .env to add it:

DEVISE_JWT_SECRET_KEY=the_generate_secret

Now run the server (this can take a while the first time, as well as each time you modify javascript):

foreman start -f Procfile.dev -p 3000

To check if nodes are reachable:

rake debug:node_info

To poll nodes:

rake nodes:poll
rake nodes:poll[BTC,TBTC]

Prefix rake command with debug or info to see more progress details:

rake debug nodes:poll[BTC]

To poll all nodes continuously, or filter by coin:

rake nodes:poll_repeat
rake nodes:poll_repeat[BTC,TBTC]

To check inflation, you need to run a mirror node and add it in the admin panel.

rake debug blocks:check_inflation[BTC]

To run inflation checks continuously, filtered by coin:

rake debug nodes:inflation_check_repeat[BTC]

The other long running heavy work tasks:

rake debug nodes:heavy_checks_repeat[BTC]

To manually query a node:

rails c
info = Node.first.client.getblockchaininfo
info["blocks"]
=> 548121

To get the list of RPC commands and execute an arbitrary command:

puts Node.first.client.help
Node.first.client.request("getblock", ...)

To communicate with the first Bitcoin Core mirror node:

Node.where(coin:"BTC").where.not(mirror_rpchost: nil).first.mirror_client.getchaintips

Test suite

Some of the tests require (a specific version of) Bitcoin Core. To install:

cd vendor/bitcoin
cp ../bitcoin-config.ini test/config.ini
contrib/devtools/previous_release.sh -b -t .. v0.19.0.1

Currently the tests require a custom compiled version of Bitcoin Core, so instead:

TRAVIS_BUILD_DIR=$PWD ./bitcoind.sh

Edit bitcoin/test/config.ini and replace $TRAVIS_BUILD_DIR with the root path of this project.

To run Rails tests and monitor for changes:

guard
<hit enter>

To run Rails tests in parallel (optionally set PARALLEL_TEST_PROCESSORS):

rake parallel:create
rake parallel:prepare
rake parallel:spec

To run Javascript tests and monitor for changes:

yarn test --watch

Tools

To get a list of chaintips for all nodes run:

rake blocks:get_chaintips
Node 1: Bitcoin Core 0.17.99:
HEIGHT | BRANCHLEN | STATUS        | HASH
-------|-----------|---------------|-----------------------------------------------------------------
572319 | 0         | active        | 0000000000000000002671de2c0d7966398eef6c36e5c23706e36f2b6ba34633
525890 | 1         | valid-headers | 0000000000000000003d068ec400b1042b8d1ed867cf3c380b64ca074c6d12c7

Push notifications

Generate a VAPID_PUBLIC_KEY and VAPID_PRIVATEY_KEY for push notifications:

npm install -g web-push
web-push generate-vapid-keys

Also provide a contact email via VAPID_CONTACT_EMAIL=.

To test notifications, open the site in Chrome and give permission, and then:

@subscription = Subscription.last
Webpush.payload_send(endpoint: @subscription.endpoint, message: "tag|title|body", p256dh: @subscription.p256dh, auth: @subscription.auth, vapid: { subject: "mailto:" + ENV['VAPID_CONTACT_EMAIL'], public_key: ENV['VAPID_PUBLIC_KEY'] , private_key: ENV['VAPID_PRIVATE_KEY'] }, ttl: 60 * 60)

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 79.7%
  • JavaScript 17.9%
  • HTML 1.6%
  • Other 0.8%