|
|
利用bitcoind 及 eloipool( Python3)架设比特币矿池
Eloipool 是基于 Python3的矿池服务器程序(支持Stratum),更详细资料请看: https://bitcointalk.org/index.php?topic=61731.0
还可参考以下帖子:
https://bitcointalk.org/index.php?topic=61731.0;all
https://bitcointalk.org/index.php?topic=158105.0;all
教程基于Ubuntu (Precise). 根据你的具体环境不同,可能需要不同的安装包。
1. Add the bitcoin repository to your sources and update (ubuntu)
Code:
add-apt-repository ppa:bitcoin/bitcoin
Code:
apt-get update
2. Install bitcoind
Code:
apt-get install bitcoind
3. Run bitcoind
Code:
bitcoind -daemon
You should receive an error that says something like this:
Code:
lsError: To use the "-daemon" option, you must set a rpcpassword in the configuration file:
/home/user/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
rpcuser=bitcoinrpc
rpcpassword=*password redacted* &1 >/dev/null &
Make sure all the scripts are executable by issuing these commands:
Code:
chmod 0755 /bitcoin/run-bitcoind.sh
chmod 0755 /bitcoin/newblock.sh
chmod 0755 /bitcoin/eloipool/run-eloipool.sh
14. Run!
Bitcoind/bitcoin-qt MUST BE FULLY SYNC'd TO THE NETWORK.
Make sure you're firewalls and port forwarding allows port 3334 on TCP. For a better connection
to the bitcoin network, allow 8333 in as well (such as you notice only 8 connections max when synchronizing)
Make sure all related processes are not running.
I added the scripts and eloipool in case you tried a different setup first:
Code:
killall bitcoind
killall run-bitcoind.sh
killall eloipool.py
Run bitcoind from the script.
Code:
./run-bitcoind.sh
Wait a little bit for bitcoind to start up. Then run eloipool from the script.
Code:
./run-eloipool.sh
To verify that both processes are running, run the following commands. They should return
with a PID and the name of the process. Such as:
Code:
ps -e | grep bitcoin
should return something like:
Code:
26762 ? 03:27:37 bitcoind
Code:
ps -e | grep eloipool.py
should return something like:
Code:
26788 ? 03:30:00 eloipool.py
15. Check connection
Now test your connecton by pointing your miner at your server with the settings:
user: YourBitcoinAddress
pass: x (this doesnt matter, it is ignored with the allow all setting in config.py)
address: stratum+tcp://IpAddressOrDomainName:3334
An example for bfgminer:
Code:
bfgminer.exe --userpass 134dV6U7gQ6wCFbfHUz2CMh6Dth72oGpgH:snoogins --url stratum+tcp://192.168.0.22:3334
Port 3334 is the port used for the Stratum Protocol.
<font style="background-color:white">
Known Errors:
-----
If you have an error such as:
Code:
2013-05-12 23:08:19,014 merkleMaker CRITICAL Traceback (most recent call last):
File "/usr/local/lib/python3.2/json/decoder.py", line 361, in raw_decode
obj, end = self.scan_once(s, idx)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/eloipool/merklemaker.py", line 692, in run
self.merkleMaker_I()
File "/home/eloipool/merklemaker.py", line 682, in merkleMaker_I
self.merkleMaker_II()
File "/home/eloipool/merklemaker.py", line 648, in merkleMaker_II
return self._updateMerkleTree()
File "/home/eloipool/merklemaker.py", line 548, in _updateMerkleTree
self._updateMerkleTree_I()
File "/home/eloipool/merklemaker.py", line 512, in _updateMerkleTree_I
r = self._updateMerkleTree_fromTS(TS)
File "/home/eloipool/merklemaker.py", line 477, in _updateMerkleTree_fromTS
MP = self._CallGBT(TS)
File "/home/eloipool/merklemaker.py", line 327, in _CallGBT
MP = access.getblocktemplate(self.GBTReq)
File "/usr/local/lib/python3.2/site-packages/bitcoinrpc/authproxy.py", line 102, in __call__
response = self._get_response()
File "/usr/local/lib/python3.2/site-packages/bitcoinrpc/authproxy.py", line 128, in _get_response
parse_float=decimal.Decimal)
File "/usr/local/lib/python3.2/json/__init__.py", line 320, in loads
return cls(**kw).decode(s)
File "/usr/local/lib/python3.2/json/decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.2/json/decoder.py", line 363, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
A known fix is to change the line in python-bitcoinrpc/bitcoinrpc/authproxy.py
somewhere around line 72
Code:
self.__auth_header = "Basic %s" % base64.b64encode(authpair)
to read:
Code:
self.__auth_header = "Basic %s" % base64.b64encode(authpair).decode()
----------
An error reading:
Code:
TypeError: _stratum_mining_subscribe() takes exactly 1 positional argument (
Can be resolved by editing eloipool/stratumserver.py around lines 106-107 from
Code:
if not hasattr(e, 'StratumQuiet'):
self.logger.debug(fexc)
to read:
Code:
if not hasattr(e, 'StratumQuiet'):
if fexc.find('takes exactly 1 positional argument') == -1:
self.logger.debug(fexc)
Using MySql to log from Eloipool
This one took me a little bit.
Change directory to this location:
Code:
cd /usr/local/lib/python3.2/dist-packages/PyMySQL3-0.5-py3.2.egg/pymysql/
Locate the lines that look like this: (they should be together)
Code:
def unpack_int24(n):
return struct.unpack('B',n[0])[0] + (struct.unpack('B', n[1])[0] |
|