独立挖矿
独立挖矿是通过PAI币池之类的集体池进行开采的替代方法。当您独立挖矿时,您的设备或服务器会在本地构建有效的块,直到找到具有满足PAI区块链难度目标(即“幸运哈希”)的哈希值的块。一旦找到,它将把该块广播到其他对等点,以供整个网络接受。
独立挖矿的主要含义是,如果您的设备找到了网络接受的有效区块,则可以保留挖矿奖励的整个部分。另一方面,如果您的设备无法找到有效的难度目标,则您将无法从挖矿中获得任何收益。
单独挖矿与池挖矿相反,在池挖矿中,区块奖励在池的所有贡献者之间按比例分配,而不管哪个个体贡献者实际找到带有幸运哈希的有效区块。简而言之,独立挖矿是少次数多奖励,矿池是多次数,小奖励。对于总体网络哈希率非常高的区块链,矿工相对较低的计算能力将无法进行单独挖矿。
单独挖矿对PAI区块链有利,因为它通过从一个或几个大型挖矿池(例如PAI Coin Pool)中分配挖矿资源来进一步分散网络,去中心化。
目录
-
用钱包设置一个完整的节点
-
构建和安装单独采矿软件
-
运行独立矿工
-
参考资料
用钱包设置一个完整的节点
注意: 如果您希望将挖掘的奖励存储在执行挖掘的同一台计算机上的命令行钱包中,请按照以下步骤设置一个带有钱包的完整节点。如果您希望将采矿奖励存储在其他地方(例如,存储在PAI Up手机或网络钱包中),则应跳过此部分,并根据本指南设置完整的节点。
执行以下命令以使用钱包构建完整节点。
首先,安装一些必要的依赖项。
sudo apt update
sudo apt install autoconf autogen automake make gcc libcurl4-gnutls-dev build-essential libtool autotools-dev pkg-config libssl-dev libevent-dev bsdmainutils python3 libboost-all-dev
接下来,获取并编译钱包必需的Berkeley DB 4.8。
wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz
echo '12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef
db-4.8.30.NC.tar.gz' | sha256sum -c
tar -xvf db-4.8.30.NC.tar.gz
sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g'
db-4.8.30.NC/dbinc/atomic.h
cd db-4.8.30.NC/build_unix
mkdir -p build
BDB_PREFIX=$(pwd)/build
../dist/configure --disable-shared --enable-cxx --with-pic --prefix=$BDB_PREFIX
make install
现在,配置并构建PAI Coin Core。
cd
git clone https://github.com/projectpai/paicoin.git
cd paicoin
./autogen.sh
./configure CPPFLAGS="-I${BDB_PREFIX}/include/ -O2" LDFLAGS="-L${BDB_PREFIX}/lib/"
--disable-tests
你会看到:
Options used to compile and link:
with wallet = yes
with gui / qt = no
with zmq = no
with test = no
with bench = yes
with upnp = auto
use asm = yes
debug enabled = no
werror = no
target os = linux
build os =
CC = gcc
CFLAGS = -g -O2
CPPFLAGS = -I/home/ubuntu/db-4.8.30.NC/build_unix/build/include/ -O2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
CXX = g++ -std=c++11
CXXFLAGS = -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter -Wno-implicit-fallthrough
LDFLAGS = -L/home/ubuntu/db-4.8.30.NC/build_unix/build/lib/
ARFLAGS = cr
运行:
make
然后你会看到:
CXX stake/libpaicoinconsensus_la-votebits.lo
CXX libpaicoinconsensus_la-uint256.lo
CXX libpaicoinconsensus_la-utilstrencodings.lo
CXX support/libpaicoinconsensus_la-cleanse.lo
CXX libpaicoinconsensus_la-sync.lo
CXX libpaicoinconsensus_la-fs.lo
CXX libpaicoinconsensus_la-random.lo
CXX libpaicoinconsensus_la-utiltime.lo
CXX libpaicoinconsensus_la-util.lo
CXXLD libpaicoinconsensus.la
make[2]: Leaving directory '/home/ubuntu/paicoin/src'
make[1]: Leaving directory '/home/ubuntu/paicoin/src'
Making all in doc/man
make[1]: Entering directory '/home/ubuntu/paicoin/doc/man'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/ubuntu/paicoin/doc/man'
make[1]: Entering directory '/home/ubuntu/paicoin'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/home/ubuntu/paicoin'
成功运行后,创建 ~/.paicoin
目录,在里面创建一个叫 paicoin.conf
的TXT文件,
包含以下内容(将rpcuser
和rpcpassword
值设置为您喜欢的任何值):
daemon=1
rpcuser=user
rpcpassword=password
最后,通过运行paicoin / src
目录中的./paicoind
启动完整节点,并等待其同步。您可以通过运行paicoin-cli getmininginfo
或查看〜/ .paicoin / debug.log
并检查本地块高度来查看同步进度。当本地区块高度与区块链高度匹配时,同步完成,例如,在https://paichain.info上看到的那样。
您可以将PAI币钱包与paicoin-cli getbalance
,paicoin-cli sendtoaddress
和paicoin-cli getnewaddress
等命令一起使用。通过执行paicoin-cli help
,可以获得可使用的命令的完整列表。
构建和安装单独采矿软件
安装依赖项:
sudo apt install libcurl4-gnutls-dev
克隆cpuminer存储库并配置构建。
git clone https://github.com/projectpai/cpuminer.git
cd cpuminer
./autogen.sh
会看到
configure.ac:9: installing './compile'
configure.ac:4: installing './config.guess'
configure.ac:4: installing './config.sub'
configure.ac:6: installing './install-sh'
configure.ac:6: installing './missing'
Makefile.am: installing './INSTALL'
Makefile.am: installing './depcomp'
然后运行:
./nomacro.pl
最后运行:
./configure CFLAGS="-O3"
会显示:
Compilation............: make (or gmake)
CPPFLAGS.............:
CFLAGS...............: -O3
LDFLAGS..............: -pthread
LDADD................: -lcurl compat/jansson/libjansson.a -lpthread
Installation...........: make install (as root if needed, with 'su' or 'sudo')
prefix...............: /usr/local
最后,运行此软件.
make
运行独立矿工
在运行paicoind的情况下,在cpuminer目录中执行以下命令将启动cpuminer。
./minerd -a paicoin -o http://127.0.0.1:8566 -u user -p password --coinbase-addr=paiaddress --no-stratum &> ~/cpu-miner-output.log &
在上面的命令中,应该用在paicoin.conf
文件中指定的rpcuser
和rpcpassword
值替换用户和密码。 paiaddress
值应设置为等于您要用来收集从采矿中获得的任何区块奖励的PAI币地址。
您可以检查cpu-miner-output.log
文件以评估矿机的性能。
参考资料
在此处可找到一些安装Berkeley DB 4.8的技巧:https://gist.github.com/danieldk/5700533
请在以下链接下载PAI独立挖矿教程:
Solo Mining (Chinese).pdf (264.1 KB)