项目作者: deni64k

项目描述 :
Yet another BTC client
高级语言: C++
项目地址: git://github.com/deni64k/btc.git
创建时间: 2019-06-14T16:05:47Z
项目社区:https://github.com/deni64k/btc

开源协议:

下载


BTC

Yet another BTC and LTC client.

Why?

To figure out how cryptocurrencies work in general and research mining.

Hashrate

Device Where Hashrate, MiH/s
AMD Radeon Pro 455 MacBook Pro 15” 2016 180
GeForce RTX 2080 Ti My Gaming Beast PC 3360

The miner reaches 8-leading-zeros hash in a few seconds.

Unfortunately, such hash rate it is not practical nowadays, since the target has 18 leading zeroes.

Build

Unix-like

It’s a typical CMake project, but requires a few adjustments:

  • Latest gcc or cland supporing C++17 or later, and
  • OpenSSL from Homebrew (Linux is fine, probably).

I use:

  1. mkdir b && cd b
  2. cmake -DCMAKE_C_COMPILER=gcc-8 \
  3. -DCMAKE_CXX_COMPILER=g++-8 \
  4. -DCMAKE_BUILD_TYPE=Release \
  5. -DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2r \
  6. ..
  7. make

Windows

  • Use latest MSVC supporing /std:c++latest, and
  • CUDA SDK for OpenCL support.

Before you build the project, you need to prepare dependencies:

  1. git clone https://github.com/Microsoft/vcpkg.git
  2. cd vcpkg
  3. ./bootstrap-vcpkg.bat
  4. ./vcpkg.exe integrate install
  5. ./vcpkg.exe integrate boost:x64-windows

Then, open the project in MSVC and enjoy compiling.

Running

Before you run the client, you need to find a peer. Run host -a dnsseed.bluematt.me and choose any of them you like, for instance 2406:da18:f7c:4351:ba7c:6da8:da59:b1b6 (this peer may not be available by the time you read this).

Then, simply run:

  1. src/btc 2406:da18:f7c:4351:ba7c:6da8:da59:b1b6

It will download the whole blockhain (no integrity checks are implemented) and start to mine using the mempool.
Once it reaches the target, it exit(0); the new block won’t be propogated.

GPU mining

To select a GPU as the miner, run src/btc --opencl-info and find your device in the list.
Then, use its number (counting from 0) as the value in --device-id.

For instance, my AMD Radeon Pro 455 is the third in the list, so I pass --device-id 2.

Bugs

The implementation doesn’t count protocol differences, misbehaving peers, and proper sharing GPU with other applications. For instance, once a peer disconnected, the client exits with an exception.

So, if you are brave enough to run this, be aware that:

  • Heavy-on-GPU applications should be closed, like Chrome (otherwise all hangs and a hard reboot is required), and
  • You may have to run the client multiple times if a peer drops the connection, and you see an error Operation not permitted.

Roadmap

  • Mining on CPU (commented out)
  • Mining on GPU
  • Mining on FPGA
  • Integration with ASICs
  • Distributed mining
  • Integration with mining pools
  • Better design of the event loop including support multiple peers and error handling
  • Integrity checks for the blockchain
  • Integrity guaranties for the local copy of the blockchain