# Open Source TrueChain Mining Pool <br/> ![Miner's stats page](https://user-images.githubusercontent.com/7374093/31591180-43c72364-b236-11e7-8d47-726cd66b876a.png) [![Join the chat at https://gitter.im/sammy007/open-ethereum-pool](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sammy007/open-ethereum-pool?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/sammy007/open-ethereum-pool.svg?branch=develop)](https://travis-ci.org/sammy007/open-ethereum-pool) [![Go Report Card](https://goreportcard.com/badge/github.com/sammy007/open-ethereum-pool)](https://goreportcard.com/report/github.com/sammy007/open-ethereum-pool) <br/> ## Features **This pool is being further developed to provide an easy to use pool for TrueChain miners. This software is functional however an optimised release of the pool is expected soon. Testing and bug submissions are welcome!** * Support for HTTP and Stratum mining * Detailed block stats with luck percentage and full reward * Failover getrue instances: getrue high availability built in * Modern beautiful Ember.js frontend * Separate stats for workers: can highlight timed-out workers so miners can perform maintenance of rigs * JSON-API for stats #### <br/> * [Ether-Proxy](https://github.com/sammy007/ether-proxy) HTTP proxy with web interface * [Stratum Proxy](https://github.com/Atrides/eth-proxy) for TrueChain <br/> ### Building on Linux Dependencies: * go >= 1.9 * etrue * redis-server >= 2.8.0 * nodejs >= 4 LTS * nginx **I highly recommend to use Ubuntu 16.04 LTS.** <br/> First install [getrue](https://github.com/truechain/truechain-engineering-code/releases/download/v1.0.1/getrue-linux-amd64-1.0.1-c617168.tar.gz). You can install the latest getrue on truechain git hub <br/> ## Clone & compile: git clone https://github.com/truechain/open-truechain-pool.git cd open-truechain-pool go build main.go Also Install redis-server. <br/> ## Running Pool ./build/bin/open-ethereum-pool config.json You can use Ubuntu upstart - check for sample config in <code>upstart.conf</code>. <br/> ## Building Frontend Install nodejs. I suggest using LTS version >= 4.x from https://github.com/nodesource/distributions or from your Linux distribution or simply install nodejs on Ubuntu Xenial 16.04. The frontend is a single-page Ember.js application that polls the pool API to render miner stats. cd www <br/> Change <code>ApiUrl: '//example.net/'</code> in <code>www/config/environment.js</code> to match your domain name. Also don't forget to adjust other options. npm install -g ember-cli@2.9.1 npm install -g bower npm install bower install ./build.sh <br/> Configure nginx to serve API on <code>/api</code> subdirectory. Configure nginx to serve <code>www/dist</code> as static website. <br/> ### Serving API using nginx Create an upstream for API: upstream api { server; } and add this setting after <code>location /</code>: location /api { proxy_pass http://api; } <br/> ### Customization You can customize the layout using built-in web server with live reload: ember server --port 8082 --environment development **Don't use built-in web server in production**. <br/> Check out <code>www/app/templates</code> directory and edit these templates in order to customise the frontend. <br/> ### Configuration Configuration is actually simple, just read it twice and think twice before changing defaults. <br/> **Don't copy config directly from this manual. Use the example config from the package, otherwise you will get errors on start because of JSON comments.** ```javascript { // Set to the number of CPU cores of your server "threads": 2, // Prefix for keys in redis store "coin": "eth", // Give unique name to each instance "name": "main", "proxy": { "enabled": true, // Bind HTTP mining endpoint to this IP:PORT "listen": "", // Allow only this header and body size of HTTP request from miners "limitHeadersSize": 1024, "limitBodySize": 256, /* Set to true if you are behind CloudFlare (not recommended) or behind http-reverse proxy to enable IP detection from X-Forwarded-For header. Advanced users only. It's tricky to make it right and secure. */ "behindReverseProxy": false, // Stratum mining endpoint "stratum": { "enabled": true, // Bind stratum mining socket to this IP:PORT "listen": "", "timeout": "120s", "maxConn": 8192 }, // Try to get new job from geth in this interval "blockRefreshInterval": "120ms", "stateUpdateInterval": "3s", // Require this share difficulty from miners "difficulty": 2000000000, /* Reply error to miner instead of job if redis is unavailable. Should save electricity to miners if pool is sick and they didn't set up failovers. */ "healthCheck": true, // Mark pool sick after this number of redis failures. "maxFails": 100, // TTL for workers stats, usually should be equal to large hashrate window from API section "hashrateExpiration": "3h", "policy": { "workers": 8, "resetInterval": "60m", "refreshInterval": "1m", "banning": { "enabled": false, /* Name of ipset for banning. Check http://ipset.netfilter.org/ documentation. */ "ipset": "blacklist", // Remove ban after this amount of time "timeout": 1800, // Percent of invalid shares from all shares to ban miner "invalidPercent": 30, // Check after after miner submitted this number of shares "checkThreshold": 30, // Bad miner after this number of malformed requests "malformedLimit": 5 }, // Connection rate limit "limits": { "enabled": false, // Number of initial connections "limit": 30, "grace": "5m", // Increase allowed number of connections on each valid share "limitJump": 10 } } }, // Provides JSON data for frontend which is static website "api": { "enabled": true, "listen": "", // Collect miners stats (hashrate, ...) in this interval "statsCollectInterval": "5s", // Purge stale stats interval "purgeInterval": "10m", // Fast hashrate estimation window for each miner from it's shares "hashrateWindow": "30m", // Long and precise hashrate from shares, 3h is cool, keep it "hashrateLargeWindow": "3h", // Collect stats for shares/diff ratio for this number of blocks "luckWindow": [64, 128, 256], // Max number of payments to display in frontend "payments": 50, // Max numbers of blocks to display in frontend "blocks": 50, /* If you are running API node on a different server where this module is reading data from redis writeable slave, you must run an api instance with this option enabled in order to purge hashrate stats from main redis node. Only redis writeable slave will work properly if you are distributing using redis slaves. Very advanced. Usually all modules should share same redis instance. */ "purgeOnly": false }, // Check health of each geth node in this interval "upstreamCheckInterval": "5s", /* List of geth nodes to poll for new jobs. Pool will try to get work from first alive one and check in background for failed to back up. Current block template of the pool is always cached in RAM indeed. */ "upstream": [ { "name": "main", "url": "", "timeout": "10s" }, { "name": "backup", "url": "", "timeout": "10s" } ], // This is standard redis connection options "redis": { // Where your redis instance is listening for commands "endpoint": "", "poolSize": 10, "database": 0, "password": "" }, // This module periodically remits ether to miners "unlocker": { "enabled": false, // Pool fee percentage "poolFee": 1.0, // Pool fees beneficiary address (leave it blank to disable fee withdrawals) "poolFeeAddress": "", // Donate 10% from pool fees to developers "donate": true, // Unlock only if this number of blocks mined back "depth": 120, // Simply don't touch this option "immatureDepth": 20, // Keep mined transaction fees as pool fees "keepTxFees": false, // Run unlocker in this interval "interval": "10m", // Geth instance node rpc endpoint for unlocking blocks "daemon": "", // Rise error if can't reach geth in this amount of time "timeout": "10s" }, // Pay out miners using this module "payouts": { "enabled": false, // Require minimum number of peers on node "requirePeers": 25, // Run payouts in this interval "interval": "12h", // Geth instance node rpc endpoint for payouts processing "daemon": "", // Rise error if can't reach geth in this amount of time "timeout": "10s", // Address with pool balance "address": "0x0", // Let geth to determine gas and gasPrice "autoGas": true, // Gas amount and price for payout tx (advanced users only) "gas": "21000", "gasPrice": "50000000000", // Send payment only if miner's balance is >= 0.5 Ether "threshold": 500000000, // Perform BGSAVE on Redis after successful payouts session "bgsave": false } } ``` If you are distributing your pool deployment to several servers or processes, create several configs and disable unneeded modules on each server. (Advanced users) <br/> I recommend this deployment strategy: * Mining instance * Unlocker and payouts instance - 1x each (strict!) * API instance - 1x <br/> ### Notes * Unlocking and payouts are sequential, 1st tx go, 2nd waiting for 1st to confirm and so on. You can disable that in code. Carefully read `docs/PAYOUTS.md`. * Also, keep in mind that **unlocking and payouts will halt in case of backend or node RPC errors**. In that case check everything and restart. * You must restart module if you see errors with the word *suspended*. * Don't run payouts and unlocker modules as part of mining node. Create separate configs for both, launch independently and make sure you have a single instance of each module running. * If `poolFeeAddress` is not specified all pool profit will remain on coinbase address. If it specified, make sure to periodically send some dust back required for payments. <br/> ### Credits Made by sammy007. Licensed under GPLv3. <br/> ### Contributors [Alex Leverington](https://github.com/subtly) Highly appreciated.