Blockchain By Example
上QQ阅读APP看书,第一时间看更新

Cloning Bitcoin

Bitcoin is a highly active project frequently releasing new releases. The current version at the time of writing is 0.15—you can view a list of project releases at https://bitcoin.org/en/version-history. From one version to another, a lot of features get added or removed. Therefore, you must examine the changelog to see whether there is any special feature you are interested in. For example, internal mining got removed in version 0.13.

To build Readercoin, I've opted for using the last major version of Bitcoin, that is, version 0.15 (You can also use the newer version 0.16). Create a directory called readercoin and clone the Bitcoin 0.15 code as follows:

git clone -b 0.15 https://github.com/bitcoin/bitcoin.git readercoin && cd readercoin

git gives us access to all past and future versions; hence, you can choose different branches using the -b option.

Now, we have to remove Bitcoin's ties to the original Bitcoin repository. This can be done easily with the following command:

rm -­rf .git

To enable git versioning, you can initialize a new git repository on your newly created folder Readercoin, add the existing files, and commit them:

git init
git add ­-A
git commit -m "initial commit"

Besides being a good habit, maintaining a remote repository will help us to compile our Readercoin client on different machines without the need to copy the code each time.

Go to the GitHub website and create a new online repository, and then add your repository's git URL as the remote repository. Afterward, push your initial commit:

git remote add origin https://github.com/bellaj/Readercoin_.git(use instead YOUR NEW GITHUB REPO's url)
git push -f origin master

Remember, before you start editing the code, that you can compile the code at any level of the following guide using make to check whether the addition process has been executed successfully or not. It's advisable to commit and push working changes to your remote repository as it will help you to make rollbacks if there are any compilation issues, or if you want to compile code on other machines.