Skip to content

Instantly share code, notes, and snippets.

@tyler-smith
Last active November 6, 2018 17:13
Show Gist options
  • Save tyler-smith/e4fd62b665d231df1da3dcb452848f49 to your computer and use it in GitHub Desktop.
Save tyler-smith/e4fd62b665d231df1da3dcb452848f49 to your computer and use it in GitHub Desktop.
Bitprim Cluster Guide

TODO:

  • Add config to put blockchain data on EBS

Overview

Steps to create a Bitprim cluster. The architecture will be 2 tiered: a BCH node tier and an API server tier. Both tiers are instances of a Bitprim server but with different configuration files.

Installation

For each server in the cluster create a .net environment and install Bitprim:

# Some .net libs
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb

# Install .net and dependencies
apt-get update
apt-get install -y dotnet-sdk-2.1 unzip python3 python3-pip

# Install Conan build tool
pip3 install conan

# Download source
cd ~
wget https://github.com/bitprim/bitprim-insight/archive/v1.6.4.zip
unzip v1.6.4.zip
cd ~/bitprim-insight-1.6.4/bitprim.insight

# Build
dotnet build /p:BCH=true -c Release -v normal

Configure

Copy the relevant config to ~/bitprim-insight-1.6.4/bitprim.insight/appsettings.json.

BCH node config

API config

For API config, change "ForwardUrl": "http://localhost:1549", to point to the BCH node address or load balancer address.

Start server

Start BCH node tier instance:

dotnet bin/Release/netcoreapp2.0/bitprim.insight.dll --server.port=1549 --server.address=0.0.0.0

Start API tier instance:

dotnet bin/Release/netcoreapp2.0/bitprim.insight.dll --server.port=3000 --server.address=0.0.0.0

Test

~> curl http://<API load balancer IP>:3000/api/block-index/0
{"blockHash":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"}
{
"ApiPrefix": "api",
"AcceptStaleRequests": true,
"AllowedOrigins": "http://localhost:1549",
"BlockchainHeightServiceUrl": "https://api.blockchair.com/bitcoin",
"BlockchainHeightParsingExpression": "[\"data\", \"blocks\"]",
"BlockchainStalenessThreshold": 43200,
"Connections": 8,
"DateInputFormat": "yyyy-MM-dd",
"EstimateFeeDefault": "0.00001000",
"ForwardUrl": "http://localhost:1549",
"ForwarderFirstRetryDelayInMillis": 500,
"ForwarderMaxRetries": 3,
"ForwarderMaxRetryDelayInSeconds": 10,
"HttpClientTimeoutInSeconds": 5,
"InitializeNode": false,
"LongResponseCacheDurationInSeconds": 86400,
"MaxAddressesPerQuery": 10,
"MaxBlockSummarySize": 500,
"MaxCacheSize": 50000,
"MaxCoinPriceAgeInSeconds": 300,
"MaxSocketPublishRetries": 3,
"NodeConfigFile": "",
"NodeType": "bitprim node",
"PoolsFile": "pools.json",
"ProtocolVersion": "70015",
"Proxy": "",
"RelayFee": "0.00001",
"ShortResponseCacheDurationInSeconds": 30,
"SocketPublishRetryIntervalInSeconds": 1,
"TimeOffset": "0",
"TransactionsByAddressPageSize": 10,
"Version": "170000",
"WebsocketsEnabled": true,
"WebsocketsMsgBlockEnabled": true,
"WebsocketsMsgTxEnabled": true,
"WebsocketsMsgTxIncludeVout": false,
"WebsocketsMsgAddressTxEnabled": true,
"WebsocketsForwarderClientRetryDelay": 10,
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {TimeZone}] {Level:u3} {SourceIP} {RequestId} {HttpMethod} {RequestPath} {HttpProtocol} {HttpResponseStatusCode} {HttpResponseLength} {ElapsedMs} {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "log-.txt",
"rollingInterval": "Day",
"fileSizeLimitBytes": null,
"retainedFileCountLimit": 5,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {TimeZone}] {Level:u3} {SourceIP} {RequestId} {HttpMethod} {HttpRequestUrl} {HttpProtocol} {HttpResponseStatusCode} {HttpResponseLength} {ElapsedMs} {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext" ]
}
}
{
"ApiPrefix": "api",
"AcceptStaleRequests": true,
"AllowedOrigins": "http://localhost:1549",
"BlockchainHeightServiceUrl": "https://api.blockchair.com/bitcoin",
"BlockchainHeightParsingExpression": "[\"data\", \"blocks\"]",
"BlockchainStalenessThreshold": 43200,
"Connections": 8,
"DateInputFormat": "yyyy-MM-dd",
"EstimateFeeDefault": "0.00001000",
"ForwardUrl": "",
"ForwarderFirstRetryDelayInMillis": 500,
"ForwarderMaxRetries": 3,
"ForwarderMaxRetryDelayInSeconds": 10,
"HttpClientTimeoutInSeconds": 5,
"InitializeNode": true,
"LongResponseCacheDurationInSeconds": 86400,
"MaxAddressesPerQuery": 10,
"MaxBlockSummarySize": 500,
"MaxCacheSize": 50000,
"MaxCoinPriceAgeInSeconds": 300,
"MaxSocketPublishRetries": 3,
"NodeConfigFile": "",
"NodeType": "bitprim node",
"PoolsFile": "pools.json",
"ProtocolVersion": "70015",
"Proxy": "",
"RelayFee": "0.00001",
"ShortResponseCacheDurationInSeconds": 30,
"SocketPublishRetryIntervalInSeconds": 1,
"TimeOffset": "0",
"TransactionsByAddressPageSize": 10,
"Version": "170000",
"WebsocketsEnabled": true,
"WebsocketsMsgBlockEnabled": true,
"WebsocketsMsgTxEnabled": true,
"WebsocketsMsgTxIncludeVout": false,
"WebsocketsMsgAddressTxEnabled": true,
"WebsocketsForwarderClientRetryDelay": 10,
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {TimeZone}] {Level:u3} {SourceIP} {RequestId} {HttpMethod} {RequestPath} {HttpProtocol} {HttpResponseStatusCode} {HttpResponseLength} {ElapsedMs} {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "log-.txt",
"rollingInterval": "Day",
"fileSizeLimitBytes": null,
"retainedFileCountLimit": 5,
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {TimeZone}] {Level:u3} {SourceIP} {RequestId} {HttpMethod} {HttpRequestUrl} {HttpProtocol} {HttpResponseStatusCode} {HttpResponseLength} {ElapsedMs} {Message:lj}{NewLine}{Exception}"
}
}
],
"Enrich": [ "FromLogContext" ]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment