Eloipool for FreeBSD

This is my customized version of the Eloipool mining pool server (written in Python) for FreeBSD 9.x.

https://github.com/tuaris/eloipool

It has some minor modifications to allow the server to run in FreeBSD, plus the rc.d script. Hopefully I'll make a port one day. This is still a work in progress.

Here is the rc.d startup script:
NOTE: that the config file in /usr/local/etc/eloipool.conf is not the real config file at the moment.

#!/bin/sh

# $FreeBSD$
#
# PROVIDE: eloipool
# REQUIRE: LOGIN bitcoin
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# eloipool_enable (bool): Set to NO by default.
# Set it to YES to enable eloipool.
# eloipool_config (path): Set to /usr/local/etc/eloipool.conf
# by default.

. /etc/rc.subr

name=eloipool
rcvar=`set_rcvar`

load_rc_config $name

: ${eloipool_enable:="NO"}
: ${eloipool_config="/usr/local/etc/eloipool.conf"}

command=/usr/local/eloipool/eloipool.py
command_interpreter="/usr/local/bin/python3"
command_args="> /dev/null 2>&1 &"

run_rc_command "$1"

Some other changes include how you specify the IP's. In this version I forced everything to just IPv4 because I was having some issues with IPv6:

# Bitcoin p2p server for announcing blocks found
UpstreamBitcoindNode = ('127.0.0.1', 8333)  #

JSONRPCAddresses = (
('192.168.0.233', 8337),
)

# Addresses to listen on for Stratum mining server
StratumAddresses = (
('192.168.0.233', 3336),
)

# Addresses to listen on for Bitcoin node
# Note this will only be used to distribute blocks the pool finds, nothing else
BitcoinNodeAddresses = (
('192.168.0.233', 8338),
)

Once I get more familiarized with Python I would put back the IPv6 support. Something I could not get working was MySQL support.

Installing the Dependencies

You can install Python3 from the ports collection:

cd /usr/ports/lang/python3
make install

Then you can simply download and extract the additional Python modules in the eloipool root directory (I installed it in "/usr/local/eloipool"). Python will automatically pick those up.

python-bitcoinrpc https://github.com/jgarzik/python-bitcoinrpc
python-base58 https://gitorious.org/bitcoin/python-base58

To get the optional "midstate" library to compile,
midstate http://gitorious.org/midstate/midstate

You just have to adjust the first few lines of the Makefile:

CFLAGS = -march=native -Wall -funroll-all-loops -O3 -fstrict-aliasing -Wall -std=c99 -I/usr/local/include/python3.3m -L/usr/local/lib
LDFLAGS = -Wl,-O1 -Wl,--as-needed -lpython3.3m

Then just copy the "midstate.so" file into the eloipool root directory.