-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e14579b
Showing
28 changed files
with
4,603 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
1. Description | ||
|
||
This is ZCash mining pool. | ||
|
||
poolcore - common pool library for accounting and statistics handling | ||
pool_frontend_zcash - frontend, support native ZMQ and stratum protocols | ||
poolrestapi - standalone module for REST api support | ||
ngxrest - nginx module for REST api, fastcgi analogue | ||
|
||
2. Install dependencies | ||
|
||
sudo apt-get install cmake libssl-dev libsodium-dev libpcre3-dev libleveldb-dev libboost-all-dev libgmp-dev libprotobuf-dev protobuf-compiler | ||
|
||
3. Download sources | ||
|
||
cd YOUR_BUILD_DIRECTORY | ||
git clone https://github.com/zcash/zcash | ||
git clone https://github.com/google/flatbuffers | ||
git clone https://github.com/eXtremal-ik7/libp2p | ||
git clone https://github.com/eXtremal-ik7/poolcore | ||
git clone https://github.com/eXtremal-ik7/pool_frontend_zcash | ||
git clone https://github.com/eXtremal-ik7/poolrestapi | ||
git clone https://github.com/eXtremal-ik7/ngxrest | ||
git clone https://github.com/eXtremal-ik7/pooljs | ||
wget https://nginx.org/download/nginx-1.11.5.tar.gz | ||
tar -xzf nginx-1.11.5.tar.gz | ||
|
||
4. Build pool sources | ||
|
||
cd YOUR_BUILD_DIRECTORY/flatbuffers | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make -j5 | ||
sudo make install | ||
|
||
cd YOUR_BUILD_DIRECTORY/libp2p | ||
mkdir x86_64-Linux | ||
cd x86_64-Linux | ||
cmake ../src | ||
make -j5 | ||
|
||
cd YOUR_BUILD_DIRECTORY/poolcore | ||
mkdir x86_64-Linux | ||
cd x86_64-Linux | ||
cmake ../src -DROOT_SOURCE_DIR=YOUR_BUILD_DIRECTORY -DZCASH_ENABLED | ||
make -j5 | ||
|
||
cd YOUR_BUILD_DIRECTORY/pool_frontend_zcash | ||
mkdir x86_64-Linux | ||
cd x86_64-Linux | ||
cmake ../src -DROOT_SOURCE_DIR=YOUR_BUILD_DIRECTORY | ||
make -j5 | ||
|
||
cd YOUR_BUILD_DIRECTORY/poolrestapi | ||
mkdir x86_64-Linux | ||
cd x86_64-Linux | ||
cmake ../src -DROOT_SOURCE_DIR=YOUR_BUILD_DIRECTORY | ||
make -j5 | ||
|
||
cd YOUR_BUILD_DIRECTORY/nginx-1.11.5 | ||
./configure --prefix=NGINX_INSTALL_DIRECTORY --add-module=YOUR_BUILD_DIRECTORY/ngxrest | ||
make -j5 | ||
make install | ||
|
||
5. Setup ZCash daemon | ||
|
||
You can find setup instructions on ZCash github page: https://github.com/zcash/zcash/wiki/1.0-User-Guide | ||
After building by command ./zcutil/build.sh you must apply pool integration patch: | ||
|
||
patch -p0 < pool.diff | ||
|
||
|
||
Add path to pool libraries in Makefile: | ||
|
||
--- src/Makefile 2016-11-08 13:36:41.033699973 +0300 | ||
+++ src/Makefile 2016-11-08 13:37:20.889665298 +0300 | ||
@@ -1380,7 +1380,7 @@ | ||
LIBSNARK_LIBS = -lsnark | ||
LIBTOOL = $(SHELL) $(top_builddir)/libtool | ||
LIBTOOL_APP_LDFLAGS = | ||
-LIBZCASH_LIBS = -lsnark -lgmp -lgmpxx -lboost_system-mt -lcrypto -lsodium -fopenmp | ||
+LIBZCASH_LIBS = -lsnark -lgmp -lgmpxx -lboost_system-mt -lcrypto -lsodium -fopenmp -LYOUR_BUILD_DIRECTORY/poolcore/x86_64-Linux/zcash -lpoolrpczcash -LYOUR_BUILD_DIRECTORY/libp2p/x86_64-Linux/p2p -lp2p -LYOUR_BUILD_DIRECTORY/libp2p/x86_64-Linux/asyncio -lasyncio-0.3 -lrt | ||
LIPO = | ||
LN_S = ln -s | ||
LRELEASE = | ||
|
||
Build ZCash daemon again: | ||
|
||
make -j5 | ||
|
||
Launch command is src/zcashd -p2pport=12201. Port 12201 is used by internal pool protocol. Also, you can use poolrpccmd utility for interact with daemon by command line. | ||
|
||
6. Setup pool configuration file | ||
|
||
pool_frontend_zcash { | ||
isMaster = "true"; | ||
poolFee = "1"; | ||
poolFeeAddr = "t1ZsLopJKzyuaqmeC2Y6cx1351G13st2sWN"; | ||
walletAddrs = ["p2p://127.0.0.1:12201"]; | ||
localAddress = "p2p://127.0.0.1:13301"; | ||
walletAppName = "pool_rpc"; | ||
poolAppName = "pool_frontend_zcash"; | ||
requiredConfirmations = "10"; | ||
defaultMinimalPayout = "0.01"; | ||
dbPath = "/home/xpm/pool.zcash"; | ||
keepRoundTime = "3"; | ||
keepStatsTime = "2"; | ||
confirmationsCheckInterval = "7"; | ||
payoutInterval = "30"; | ||
balanceCheckInterval = "3"; | ||
statisticCheckInterval = "1"; | ||
|
||
zmqclientHost = "coinsforall.io"; | ||
zmqclientListenPort = "6668"; | ||
zmqclientWorkPort = "60200"; | ||
|
||
pool_zaddr = "zcWDMjkEyRPQAFjs5RWEzoqXG9BipLRWr4S9bC4A44g7eBv6ZhnqrWWc5M5MyNn4pt9vP2PEvK9NkUwerQbewEcEWz8ZL4f"; | ||
pool_taddr = "t1ZRsyK4pkBq7WD4gnF8r3nCYSQT19Zhh3C"; | ||
} | ||
|
||
isMaster - alltimes "true", slave mode for distribute share calculating not implemented | ||
poolFee - pool fee in percents | ||
poolFeeAddr - address for pool fee | ||
walletAddrs - list of zcash daemons in pool cluster. Now tested only with one daemon. Port 12201 must be taken from -p2pport command line argument of zcash daemon (see 4). | ||
localAddress - backend address and port. Used by poolrestapi module and poolrpccmd utility | ||
walletAppName - alltimer "pool_rpc" | ||
poolAppName - alltimes "pool_frontend_zcash" | ||
requiredConfirmations - minimal confirmations for block before payout (pool can't make payout for orphans) | ||
defaultMinimalPayout - default minimal payout for new accounts | ||
dbPath - path for pool database, must be exists | ||
keepRoundTime - how much days pool keep shares | ||
keepStatsTime - statistic (performance, number of GPUs, temperatures) keep time in minutes | ||
confirmationsCheckInterval - interval for check new mined blocks confirmations number | ||
payoutInterval - payout interval in minutes | ||
balanceCheckInterval - balance check interval in minutes | ||
statisticCheckInterval - statistic check interval in minutes (should be 1) | ||
|
||
zmqclientHost - native zeromq protocol host name | ||
zmqclientListenPort - navite protocol port | ||
zmqclientWorkPort - extra port for native protocol (pool uses port N and N+1) | ||
|
||
pool_zaddr - only for ZCash, pool Z-Address for receive coinbase funds. Must be created by zcash-cli z_getnewaddress | ||
pool_taddr - only for ZCash, address used for make payouts. Must be created by zcash-cli getnewaddress | ||
|
||
7. Setup poolrestapi module | ||
|
||
poolrestapi { | ||
listenAddress = "cxxrestapi://127.0.0.1:19999"; | ||
coins = ["xpm", "zcash"]; | ||
} | ||
|
||
xpm { | ||
frontends = ["p2p://127.0.0.1:13300"]; | ||
poolAppName = "pool_frontend_xpm"; | ||
} | ||
|
||
zcash { | ||
frontends = ["p2p://127.0.0.1:13301"]; | ||
poolAppName = "pool_frontend_zcash"; | ||
} | ||
|
||
listenAddress - address and port for poolrestapi. Used by nginx module for fast interaction (like fastcgi). | ||
coins - coin list. Name used as URL part for HTTP REST queries. | ||
|
||
frontends - pool frontend addresses, must be taken from 'localAddress' of pool frontend configuration file | ||
poolAppName - must be taken from 'poolAppName' of pool frontend configuration file | ||
|
||
8. Setup nginx | ||
|
||
This is fragment of nginx.conf file: | ||
|
||
upstream api_backend { | ||
server 127.0.0.1:19999; | ||
keepalive 32; | ||
} | ||
|
||
server { | ||
listen *:80 reuseport; | ||
server_name pool; | ||
|
||
location / { | ||
root html; | ||
index index.html index.htm; | ||
expires 5s; | ||
} | ||
|
||
location /api { | ||
cxxrest_pass api_backend; | ||
} | ||
|
||
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ { | ||
expires 3d; # 3 days | ||
} | ||
} | ||
|
||
upstream api_backend: | ||
server - poolrestapi address, must be taken from poolrestapi configuration file (see p.6) | ||
|
||
server/location /api: | ||
cxxrest_pass - module name and link to upstream api_backend | ||
|
||
Full nginx configuration file example you can find in poolrestapi repository | ||
|
||
9. Launch ZCash daemon | ||
|
||
src/zcashd -p2pport=12201 | ||
|
||
After launching you can test it with poolrpccmd utility (from poolcore repository) | ||
|
||
|
||
cd YOUR_BUILD_DIRECTORY/poolcore/x8664-Linux | ||
poolrpccmd/poolrpccmd p2p://127.0.0.1:12201 getInfo | ||
|
||
* coin: ZEC | ||
|
||
poolrpccmd/poolrpccmd p2p://127.0.0.1:12201 getBlockTemplate | ||
|
||
getBlockTemplate call duration 0.307ms | ||
* nbits: 486813521 | ||
* prevhash: 0000000122760d5a6e162e08e5b7f94b9d631081bc50cafd2e9e402c405eebed | ||
* hashreserved: 0000000000000000000000000000000000000000000000000000000000000000 | ||
* merkle: d803756fa90508f6e94d274236ebd158b35d79329997dbef6fa576d8830f5b58 | ||
* time: 1478536889 | ||
* extraNonce: 462 | ||
* equilHashK = 9 | ||
* equilHashN = 200 | ||
|
||
10. Launch pool | ||
|
||
cd YOUR_BUILD_DIRECTORY/pool_frontend_zcash/x86_64-Linux | ||
./pool_frontend_zcash ~/.poolcfg/zcash.cfg | ||
|
||
~/.poolcfg/zcash.cfg - pool configuration file (see p. 4) | ||
|
||
11. Launch poolrestapi and nginx | ||
|
||
cd YOUR_BUILD_DIRECTORY/poolrestapi/x86_64-Linux | ||
./poolrestapi ~/.poolcfg/poolrestapi.cfg | ||
|
||
12. Copy web client part and launch nginx | ||
|
||
cd YOUR_BUILD_DIRECTORY/pooljs/coins-for-all/webapp | ||
cp -r * NGINX_INSTALL_DIRECTORY/html | ||
sudo NGINX_INSTALL_DIRECTORY/sbin/nginx (you need sudo because port 80 is used) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
worker_processes 4; | ||
|
||
events { | ||
worker_connections 10240; | ||
multi_accept on; | ||
} | ||
|
||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
|
||
keepalive_timeout 65; | ||
|
||
upstream api_backend { | ||
server 127.0.0.1:19999; | ||
keepalive 32; | ||
} | ||
|
||
server { | ||
listen *:80 reuseport; | ||
server_name pool; | ||
|
||
location / { | ||
root html; | ||
index index.html index.htm; | ||
expires 5s; | ||
} | ||
|
||
location /api { | ||
cxxrest_pass api_backend; | ||
} | ||
|
||
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ { | ||
expires 3d; # 3 days | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
diff --git a/src/init.cpp b/src/init.cpp | ||
index 384a82b..5799c82 100644 | ||
--- src/init.cpp | ||
+++ src/init.cpp | ||
@@ -52,6 +52,8 @@ | ||
|
||
using namespace std; | ||
|
||
+void *poolRpcThread(void *arg); | ||
+ | ||
extern void ThreadSendAlert(); | ||
|
||
ZCJoinSplit* pzcashParams = NULL; | ||
@@ -1514,5 +1516,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) | ||
// SENDALERT | ||
threadGroup.create_thread(boost::bind(ThreadSendAlert)); | ||
|
||
+ pthread_t thread; | ||
+ pthread_create(&thread, 0, poolRpcThread, 0); | ||
return !fRequestShutdown; | ||
} | ||
diff --git a/src/main.cpp b/src/main.cpp | ||
index 1cad27f..24a0c46 100644 | ||
--- src/main.cpp | ||
+++ src/main.cpp | ||
@@ -46,6 +46,8 @@ using namespace std; | ||
* Global state | ||
*/ | ||
|
||
+void *newBlockNotify(void *block); | ||
+ | ||
CCriticalSection cs_main; | ||
|
||
BlockMap mapBlockIndex; | ||
@@ -2696,6 +2698,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { | ||
pnode->PushInventory(CInv(MSG_BLOCK, hashNewTip)); | ||
} | ||
// Notify external listeners about the new tip. | ||
+ newBlockNotify(pindexNewTip); | ||
uiInterface.NotifyBlockTip(hashNewTip); | ||
} | ||
} while(pindexMostWork != chainActive.Tip()); | ||
diff --git a/src/miner.cpp b/src/miner.cpp | ||
index bde9bab..2c385e6 100644 | ||
--- src/miner.cpp | ||
+++ src/miner.cpp | ||
@@ -412,7 +412,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) | ||
return CreateNewBlock(scriptPubKey); | ||
} | ||
|
||
-static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) | ||
+bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) | ||
{ | ||
LogPrintf("%s\n", pblock->ToString()); | ||
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
poolrestapi { | ||
listenAddress = "cxxrestapi://127.0.0.1:19999"; | ||
coins = ["xpm", "zcash"]; | ||
} | ||
|
||
xpm { | ||
frontends = ["p2p://127.0.0.1:13300"]; | ||
poolAppName = "pool_frontend_xpm"; | ||
} | ||
|
||
zcash { | ||
frontends = ["p2p://127.0.0.1:13301"]; | ||
poolAppName = "pool_frontend_zcash"; | ||
} |
Oops, something went wrong.