I decided to put together some compiling instructions that would help a Linux newbies to run memorycoin miner in no time. Credits go to mikaelh, because I have used his primecoind guide as base for this.
This should be the definitive guide on how to compile memorycoin on Linux. Commands need to be entered exactly as they appear, so copy and pasting is recommended.
Please note that if you are new to Linux, it's best to stick with one guide. Mixing the instructions from different guides may produce errors later.
Tested with the following Linux distributions:
- Ubuntu 13.xx
- Debian 6/7
- CentOS 6.x
- OpenSUSE 12.x/13.x
Step 1. Installing the required dependencies
Using apt-get with latest Ubuntu 13.xx or Debian:
sudo apt-get install -y build-essential m4 libssl-dev libdb++-dev libboost-all-dev libminiupnpc-dev git
The 'sudo' command requires you to type the password for the current user. If you don't have sudo working, you need to manually switch to root with 'su' before running those commands.
Warning: If you have installed a specific version such as libdb5.3++-dev before, then don't install the meta-package libdb++-dev which may pull a different version.
Alternative for CentOS users:
su -c 'yum install gcc-c++ m4 openssl-devel db4-devel boost-devel git'
Step 2. Compiling GMP
Latest version supports all the new CPUs.
cd
rm -rf gmp-5.1.3.tar.bz2 gmp-5.1.3
wget http://mirrors.kernel.org/gnu/gmp/gmp-5.1.3.tar.bz2
tar xjvf gmp-5.1.3.tar.bz2
cd gmp-5.1.3
./configure --enable-cxx
make
sudo make install
The configure script will attempt to automatically detect the host CPU and enable the best optimizations for it.
Step 2b. Compiling OpenSSL (for CentOS, Fedora and OpenSUSE users)
This step is only required if you're using CentOS. Red Hat has removed support for elliptic curve cryptography from the OpenSSL it supplies.
cd
rm -rf openssl-1.0.1e.tar.gz openssl-1.0.1e
wget ftp://ftp.pca.dfn.de/pub/tools/net/openssl/source/openssl-1.0.1e.tar.gz
tar xzvf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config shared --prefix=/usr/local --libdir=lib
make
sudo make install
Step 2c. Compiling miniupnpc (for CentOS, Fedora and OpenSUSE users)
cd
rm -rf miniupnpc-1.8.20131209.tar.gz
wget http://miniupnp.tuxfamily.org/files/download.php?file=miniupnpc-1.8.20131209.tar.gz
tar xzvf miniupnpc-1.8.20131209.tar.gz
cd miniupnpc-1.8.20131209
make
sudo INSTALLPREFIX=/usr/local make install
Step 3. Compiling memorycoind
cd
rm -rf memorycoin
git clone https://github.com/memorycoin/memorycoin
cd memorycoin/src
cp makefile.unix makefile.my
sed -i -e 's/$(OPENSSL_INCLUDE_PATH))/$(OPENSSL_INCLUDE_PATH) \/usr\/local\/include)/' makefile.my
sed -i -e 's/$(OPENSSL_LIB_PATH))/$(OPENSSL_LIB_PATH) \/usr\/local\/lib)/' makefile.my
sed -i -e 's/$(LDHARDENING) $(LDFLAGS)/$(LDHARDENING) -Wl,-rpath,\/usr\/local\/lib $(LDFLAGS)/' makefile.my
make -f makefile.my
strip bitcoind
mv bitcoind memorycoind
sudo cp -f memorycoind /usr/local/bin/
The last line will install the memorycoind binary to /usr/local/bin.
CentOS users: Use the following 'make' command instead:
make -f makefile.my BOOST_LIB_SUFFIX=-mt
Step 4. Configuration
Create a configuration file:
cd
mkdir -p .memorycoin
echo 'server=1
gen=1
logtimestamps=1
rpcallowip=127.0.0.1
rpcuser=memorycoinrpc
rpcpassword=SOME_SECURE_PASSWORD' > .memorycoin/memorycoin.conf
sed -i -e "s/SOME_SECURE_PASSWORD/`< /dev/urandom tr -cd '[:alnum:]' | head -c32`/" .memorycoin/memorycoin.conf
You may optinally customize the configuration file. The last line puts a random password in the configuration file automatically, so you don't need to change anything if you're only sending RPC commands from localhost.
I recommend to search other threads for a list of valid nodes and add them with "addnode=IP_ADDRESS". Also if you are having problem with damaged database try to add "checklevel=2".
Type these commands to create an auto-restart script:
cd
echo '#!/bin/bash
export PATH="/usr/local/bin:$PATH"
killall --older-than 10s -q run-memorycoind memorycoind
function background_loop
while :; do
memorycoind >/dev/null 2>&1
sleep 1
done
background_loop &' > run-memorycoind
chmod +x run-memorycoind
CentOS users may want to remove the 'killall' command from this script because the version that comes with CentOS does not support the --older-than option.
And for convenience, create a stopping script:
cd
echo '#!/bin/bash
killall -q run-memorycoind
memorycoind stop' > stop-memorycoind
chmod +x stop-memorycoind
You can also run miner with "memorycoind -daemon" and in some cases it can speed up the the blockchain sync. The monitoring script has to be adjusted if -daemon option is used.
Step 5. Starting mining
Simply type the following to start mining:
./run-memorycoind
It will take a while for it to sync up with the network. The script will continue running in the background, automatically restarting memorycoind if it crashes.
Step 6. Monitoring the progress
Checking that the memorycoind process is runnning:
ps xuf |grep memorycoind
RPC commands can be sent to the daemon like this:
memorycoind getbalance '' 0
memorycoind listtransactions
memorycoind getinfo
memorycoind getmininginfo
memorycoind getdifficulty
Any combination of these can be used with the 'watch' command like this:
watch 'memorycoind getinfo && memorycoind listtransactions'
Running RPC commands on miner can "hang" due to yet unknown reasons. It looks like some broken system threads magic causes this. Use Ctrl+C to terminate the request and verify debug.log to see what is miner doing. However in the beginning with no blockchain all commands are working nicely.
You can also look at the output in debug.log in real-time:
tail -f ~/.memorycoin/debug.log
Step 7. Stopping mining
Run the stop script:
./stop-memorycoind
As a last resort you can try to remove peers.dat and directories:
- chainstate
- blocks
- database
then restart the miner and run:
memorycoind listtransactions
If you see orphaned blocks, verify in blockchain explorer that these are not valid ones. If the transaction id shows a valid block then with you can dump private key to import into a working wallet:
memorycoind dumpprivkey ADDRESS
and the address from the transactions list. Import is done with "memorycoind importprivkey KEY".