使用全节点的 RPC 命令来获取模板和提交新块。使用中间件做服务。 基于 primecoin-core 0.16.1 版本。
需要修改一个地方就是,primecoin 限制每笔交易的 vout 数额不能小于 0.01xpm Primecoin: minimul txout value. static const CAmount MIN_TXOUT_AMOUNT = 1000000;
支持 segwit 不能有这个限制。看代码 segwit 会在 coinbase 里面创建一个 0 value 的 txout 交易输出。 具体原因和作用暂时没看。先弄 pool 实现。
tyler@ubuntu16:~/Documents/primecoin-core-desktop-src$ ./src/primecoin-cli -rpcuser=user -rpcpassword=password getblocktemplate '{"capabilities":["longpoll", "coinbasetxn", "coinbasevalue"]}' { "capabilities": [ "proposal" ], "version": 536870912, "rules": [ ], "vbavailable": { }, "vbrequired": 0, "previousblockhash": "47124348127fb1d00daf5f1a62c1115fe8fc8a6226f91c042211834459d06567", "transactions": [ ], "coinbaseaux": { "flags": "" }, "coinbasevalue": 734000000, "longpollid": "47124348127fb1d00daf5f1a62c1115fe8fc8a6226f91c042211834459d06567230", "target": "0000000000000000000000000000000000000000002937b40000000000000000", "mintime": 1539164867, "mutable": [ "time", "transactions", "prevblock" ], "noncerange": "00000000ffffffff", "sigoplimit": 20000, "sizelimit": 1000000, "curtime": 1539224387, "bits": "0ba937b4", "height": 2875236 }
下面的作废,使用新思路
说明 参考 madMax 的代码实现,引用库的升级,primecoin 版本使用 0.16.1。
后面需要使用 bitcoin 的 depends 里面的 make 来编译。目前先手动操作。
Dependency boost 1.64 WT 4.0.4 postgresql 10.5
zmq 4.2.2 czmq 4.1.1 lz4 1.8.3
Boost 1.64 requires CMake 3.8 or newer.
Compile cmake 3.12.2 default directory: /usr/local/bin/
./bootstrap make sudo make install
need close current console and open another one, type cmake -version check result
lz4 default directory: /usr/local/lib
export CPPFLAGS=-fPIC export CFLAGS=-fPIC export CXXFLAGS=-fPIC export LDFLAGS=-fPIC make sudo make install
compile zmq 4.2.2 sudo apt install libunwind-dev sudo apt install libsystemd-dev 这个可能不需要了,上面已经编译安装了,这个缺少库和 cpp 文件 sudo apt install liblz4-dev ./autogen.sh # do not specify "--with-libsodium" if you prefer to use internal tweetnacl security implementation (recommended for development) ./configure --with-libsodium CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC --disable-shared --enable-static ./configure CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC --disable-shared --enable-static make sudo make install sudo ldconfig installed directory /usr/local/bin /usr/local/include /usr/local/lib
czmq 4.1.1 /home/tyler/Documents/primecoin-core-desktop-src/depends/x86_64-pc-linux-gnu
export CFLAGS=-I/home/tyler/Documents/primecoin-core-desktop-src/depends/x86_64-pc-linux-gnu/include export LDFLAGS=-L/home/tyler/Documents/primecoin-core-desktop-src/depends/x86_64-pc-linux-gnu/lib export PKG_CONFIG_PATH=$/home/tyler/Documents/primecoin-core-desktop-src/depends/x86_64-pc-linux-gnu/lib/pkgconfig
./configure CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC –disable-shared –enable-static –with-uuid=no –prefix=/home/tyler/Documents/primecoin-core-desktop-src/depends/x86_64-pc-linux-gnu
git clone git://github.com/zeromq/czmq.git cd czmq ./autogen.sh ./configure CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC --disable-shared --enable-static --with-uuid=no make make check sudo make install sudo ldconfig After building, you can run the CZMQ selftests: cd src ./czmq_selftest
compile boost 1.64 // 这里的东西可能需要,目前还没需要,这里为什么会有 libboost-all-dev 不确定 sudo apt-get update sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev libboost-all-dev cat /usr/include/boost/version.hpp | grep "BOOST_LIB_VERSION" Download source file from: http://www.boost.org/users/history/version_1_64_0.html tar -xzvf boost_1_64_0.tar.gz cd boost_1_64_0 ./bootstrap.sh --prefix=/usr/local ./b2 ./b2 install
postgresql 10.5 sudo apt-get install libreadline-dev ./configure make sudo make install sudo adduser postgres sudo mkdir /usr/local/pgsql/data sudo chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql test
compile WT 4.0.4 CMake (>= 3.1)boost (version >= 1.50)
cd wt-x.y.z mkdir build; cd build cmake .. -DPOSTGRES_PREFIX=/usr/local/pgsql/ -DBOOST_ROOT=/usr/local/lib // need check boost version and postgresql is enabled make make -C examples // To install wt in /usr/local sudo make install sudo ldconfig
primecoin-pool 0.16.1 cd depends make cd .. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/ export LDFLAGS="-L/usr/local/lib -Wl,R/usr/local/lib" // 这个暂时保留,看看下面是否有效 export CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC --disable-shared --enable-static ./autogen.sh ./configure --prefix=`pwd`/depends/x86_64-pc-linux-gnu LDFLAGS="-static-libstdc++" CPPFLAGS=-DPIC CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC --disable-shared --enable-static --enable-debug // 需要调试就加上,注意先 make clean --enable-debug make STATIC=all r -printtoconsole -rpcuser=user -rpcpassword=password -txindex=1 -addrindex=1 -gen