Skip to content
This repository was archived by the owner on Jul 18, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1f80b16
Updated TODO and testing commit
generalfault Nov 10, 2012
229a118
updated config file to handle new features
generalfault Nov 10, 2012
ce58e8e
Allow the changing of the pool difficulty target
generalfault Nov 10, 2012
146d89b
Silence twisted.web and add Block check logging
generalfault Nov 11, 2012
91b951d
Update Documentation.
generalfault Nov 11, 2012
9288615
Added blocknotify instructions and generateAdminHash script
generalfault Nov 11, 2012
55ec0a8
Checking for Bitcoind connect and sanity..
generalfault Nov 11, 2012
5638eef
Initial Database Code
generalfault Nov 16, 2012
3107aad
Doc update
generalfault Nov 16, 2012
247158f
Reset speed to 0 on inactive miners
generalfault Nov 19, 2012
24b117a
Fixed speed not resetting to 0, Added a bunch of stats to the databas…
generalfault Dec 4, 2012
378b92b
Stats changes that (for some reason) did not get commited last time..…
generalfault Dec 7, 2012
5fa9adf
Fix of >10 worker section of basic stats
generalfault Dec 7, 2012
14a0013
Missed removal of a dep
generalfault Dec 8, 2012
aeca8a3
added "best_share" stat, indicate bitcoind prob on stats page, added …
generalfault Dec 8, 2012
7dd0a70
Fix share_diff on rejected share
generalfault Dec 8, 2012
42deb3a
Basic Share limiter ... i.e. Basic Variable Difficulty code
generalfault Dec 10, 2012
b52cbd9
A couple changes to eliminate rare div/0
generalfault Dec 15, 2012
b62e076
Variable diff changes, accept shares > prev diff after a retarget unt…
generalfault Dec 15, 2012
a858442
Important: Fixed errors when finding a block. There were a couple pro…
generalfault Dec 16, 2012
28503e2
Adding allowing of Non-Local Wallet address
generalfault Dec 16, 2012
73fca6c
Added getwork proxy into code... :)
generalfault Dec 18, 2012
e7a2d5a
Silence the log lines from the stats pages
generalfault Dec 18, 2012
7ead758
Added script to update the submodules
generalfault Dec 18, 2012
1894176
Fixed vardiff adjusting down too slow
generalfault Dec 19, 2012
9475884
Variable difficulty should finally be fixed
generalfault Dec 22, 2012
4f3afdd
Updated logging for variable diff
generalfault Dec 24, 2012
e51222b
Stats now show Variable difficulty, Share Archiving
generalfault Dec 27, 2012
deb93ca
fix of inital div/0 error, updating of indicies
generalfault Jan 4, 2013
27d25a8
Vardif should notify miner before db (in case db is misbehaving)
generalfault Jan 15, 2013
233d797
Basic E-Mail notifications.
generalfault Jan 21, 2013
3315f29
fix multi-recipient e-mails
generalfault Jan 21, 2013
622d485
Sqlite threading breaks things, so disable it. Archiving becomes stab…
generalfault Jan 27, 2013
d507a13
Merge branch 'master' of https://github.com/generalfault/stratum-mining
generalfault Jan 27, 2013
f8afd86
Merge in from parent... Luke sign fix
generalfault Feb 24, 2013
bf789ef
Added support for backup bitcoind backends (yes, I have had bitcoind …
generalfault Feb 24, 2013
54e3d1e
MySQL Optimisations and SHA1 passwords
wadewomersley Apr 22, 2013
a3211aa
Updated readme
wadewomersley Apr 22, 2013
b4a2f31
PostgreSQL Optimisation and SHA1 pass encryption
wadewomersley Apr 22, 2013
708e141
Ignore on .project and .pydevproject
wadewomersley Apr 22, 2013
fae3254
Raise ValueError if salt is missing from config
wadewomersley Apr 22, 2013
7f20560
MySQL foreign keys. Tokenized MySQL calls.
wadewomersley Apr 24, 2013
bdddd51
More debug output in DBInterface
wadewomersley Apr 24, 2013
2ddff0b
Reduced SQL queries in updateStats
wadewomersley Apr 24, 2013
9f16a03
get_worker_stats in MySQL ignores the 0 user
wadewomersley Apr 24, 2013
74929e9
Added `alive` index to pool_worker table
wadewomersley Apr 24, 2013
7c030bf
MySQL bug in share updates + extra debug info
wadewomersley Apr 25, 2013
9875dc0
Share/Pool MySQL DB Commit optimisations
wadewomersley Apr 25, 2013
c806448
Added DB_LOADER_FORCE_TIME config option
wadewomersley Apr 25, 2013
3213960
Reformatting
wadewomersley Apr 25, 2013
ad957bc
Prevent pool_speed being set to null in pool
wadewomersley Apr 25, 2013
61ebbc1
Detect SIGINT and flush share queue to DB
wadewomersley Apr 25, 2013
4ca7093
Removed some semi colons
wadewomersley Apr 25, 2013
2e45805
Update config_sample.py
wadewomersley Apr 26, 2013
d63e45b
Local JSON admin interface initial commit
wadewomersley Apr 26, 2013
5665ec7
Added DELETE /user/{id/username} to admin iface
wadewomersley Apr 26, 2013
0a89561
Added POST /user to add a user/pass
wadewomersley Apr 26, 2013
5e41a61
Readme update for JSON API
wadewomersley Apr 26, 2013
567b38a
Merge pull request #2 from wadewomersley/master
kcjones May 7, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
*.pyc
conf/config.py
NOTES
run
pooldb.sqlite
archives/*
twistd.pid
.project
.pydevproject
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "externals/stratum-mining-proxy"]
path = externals/stratum-mining-proxy
url = https://github.com/generalfault/stratum-mining-proxy.git
100 changes: 100 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Installation Instructions
=========================

Step 0: Install bitcoind
It MUST be a recent version of bitcoind that support getblocktemplate
Set it up and start it!
Downloading the blockchain can take a few hours to a couple days!

Step 1: Install the stratum core
git pull https://github.com/slush0/stratum.git
sudo easy_install stratum
(or if using alternate python: sudo /usr/local/bin/easy_install stratum)

Step 2: Pull a copy of the miner
git pull https://github.com/generalfault/stratum-mining.git

Step 3: Configure the Miner
cp conf/config_sample.py conf/config.py
make your changes to conf/config.py
Make sure you set the values in BASIC SETTINGS! These are how to connect to bitcoind
and where your money goes!

Step 4: Run the pool
twistd -ny launcher.tac -l -
OR - using alternate python
/usr/local/bin/twistd -ny launcher.tac -l -

You can now set the URL on your stratum proxy (or miner that supports stratum) to:
http://YOURHOSTNAME:3333

Bitcoind blocknotify Setup
=========================
Although scary (for me), this is actually pretty easy.

Step 1: Set Admin Password
Ensure that you have set the ADMIN_PASSWORD_SHA256 parameter in conf/config.py
To make life easy you can run the generateAdminHash script to make the hash
./scripts/generateAdminHash.sh <password>

Step 2: Test It
Restart the pool if it's already running
run ./scripts/blocknotify.sh --password <password> --host localhost --port 3333
Ensure everything is ok.

Step 3: Run bitcoind with blocknotify
Stop bitcoind if it's already running
bitcoind stop
Wait till it ends
bitcoind -blocknotify="/absolute/path/to/scripts/blocknotify.sh --password <password> --host localhost --port 3333"

Step 4: Adjust pool polling
Now you should be able to watch the pools debug messages for awhile and see the blocknotify come in
once you are sure it's working edit conf/config.py and set
PREVHASH_REFRESH_INTERVAL = to the same value as MERKLE_REFRESH_INTERVAL
restart the pool

Database Setup
=========================
Table Creation: Tables are auto-created if they don't exist

None:
Well, this doesn't do anything, so there is nothing to set up

Sqlite:
THIS IS THE DEFAULT!
Just set the file path in the config file (or keep the default.)
Support for sqlite3 is built into recent python versions.
A couple notes for Sqlite:
- Sqlite and threading/concurancy just doesn't work right for that reason it is disabled.
- Since threading is disabled, The server will "pause" when archiving happens, this will affect
your miners. However this will not happen often (24 hours after finding a share)

Postgresql:
1: Set up your parameters in the config file.
2: Install the postgresql libraries in your os:
Redhat and the like:
yum install postgresql-libs postgresql-devel
Ubuntu and the like:
apt-get install postgresql postgresql-devel
3: Install the python bindings
easy_install psycopg2

Mysql:
1: Set up your parameters in the config file.
2: Install the postgresql libraries in your os:
Redhat and the like:
yum install mysql mysql-devel
Ubuntu and the like:
apt-get install mysql mysql-devel
3: Install the python bindings
easy_install mysql-python

Problems????
=========================

Is your firewall off?
Is bitcoind running?

TODO: are there other problems?

42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
stratum-mining
==============

Demo implementation of bitcoin mining pool using Stratum mining protocol.
Basic implementation of bitcoin mining pool using Stratum mining protocol.

For Stratum mining protocol specification, please visit http://mining.bitcoin.cz/stratum-mining.
This fork includes database optimisations for MySQL and password hashing using a salt.

Contact
-------
JSON API
--------

This pool implementation is provided by http://mining.bitcoin.cz. You can contact
me by email info(at)bitcoin.cz or on IRC #stratum on freenode.
There is also a JSON API, currently just for users (db: pool_workers). Enabled if you set
ADMIN_PORT to a valid port rather than None. Once enabled, you can perform
the following on http://localhost:ADMIN_PORT/, provided you have a password set (see after commands).

GET /users - list all users
POST /users - create a user (JSON body: {"username": "username", "password": "password"}). Password will be encrypted using the salt.

GET /users/{id_or_username} - Get a JSON object of a specific user
DELETE /users/{id_or_username} - Remove a pool_worker. If using MySQL, any shares associated with that user will be associated with the global system account (ID: 0)
PUT /users/{id_or_username} - Update password for user, send as {"password": "password"}, as with POST /users, the password will be encrypted for you.

### Authentication

Access to the JSON API requires basic auth. The username does not matter; the password is the same as the ADMIN_PASSWORD_SHA256 password which
can generated using scripts/generateAdminHash.sh .

I would strongly suggested locking down the port as well using iptables or similar.

The Rest
--------

Basic worker stats are provided (and updated)

See the INSTALL file for install instructions.

For more info on Stratum:
http://mining.bitcoin.cz/stratum-mining.

Original version by Slush
Modified version by GeneralFault

This version by Wade Womersley (Media Skunk Works) ( Tips Welcome: 1FxBTbWR15WZp8vnru8N6zVsVBwigPAcdN )
17 changes: 17 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TODO File (in no particular order):

SQL Connection pooling: sqlalchemy

Add a "script" to add,list,disable users

Variable difficulty should not be able to go higher than current difficulty

Test NON-Local Coinbase with testnet in a box

verify settings

send e-mail on dead miner

send e-mail on dead bitcoind


Loading