Commit 4687df7e authored by Volodymyr Shamray's avatar Volodymyr Shamray

Fix incorrectly merged documents

parent 97269460
......@@ -6,11 +6,6 @@ Use the autogen script to prepare the build environment.
./configure
make
Precompiled binaries are available at github, see
https://github.com/crownproject/crown-binaries
Precompiled binaries are available at https://crown.tech/wallet/. Always verify the signatures and checksums.
Always verify the signatures and checksums.
See doc/build-*.md for instructions on building crownd,
the intended-for-services, no-graphical-interface, reference
implementation of Crown.
See doc/build-\*.md for instructions on building crownd, the intended-for-services, no-graphical-interface, reference implementation of Crown.
Copyright © 2009-2018 Bitcoin Developers
Copyright © 2014-2016 Dash Developers
Copyright © 2014-2018 Crown Developers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
Crown Core staging tree 0.12
===============================
Travis:
`master:` [![Build Status](https://travis-ci.org/Crowndev/crowncoin.svg?branch=master)](https://travis-ci.org/crownpay/crown) `v0.12.0.x:` [![Build Status](https://travis-ci.org/Crowndev/crowncoin.svg?branch=0.12.0.x)](https://travis-ci.org/Crowndev/crowncoin/branches) `v0.12.1.x:` [![Build Status](https://travis-ci.org/Crowndev/crowncoin.svg?branch=0.12.1.x)](https://travis-ci.org/Crowndev/crowncoin/branches)
Gitlab:
`master:` [![pipeline status](http://gitlab.crown.tech/crown/crown-core/badges/master/pipeline.svg)](http://gitlab.crown.tech/crown/crown-core/commits/master)
# Crown Platform 0.12.5
[![pipeline status](http://gitlab.crown.tech/crown/crown-core/badges/master/pipeline.svg)](http://gitlab.crown.tech/crown/crown-core/commits/master)
http://www.crown.tech
Copyright (c) 2009-2015 Bitcoin Core Developers
## What is Crown?
Crown is both a leading digital token (known as CRW) and a self-sustainable blockchain platform for building and running economy applications. Our community uses the Crown Platform as a payment service, proof of data integrity and a support structure for projects ranging from cloud businesses to apps. As more users lend their talents and passion to the platform, Crown’s potential to promote innovation grows exponentially.
### A Digital Token
CRW tokens are a type of cryptocurrency. Like bitcoins, CRW can be used to pay for a wide variety of products and services. CRW can also be traded against other altcoins through an online exchange.
### Blockchain Application Platform
The Crown Platform utilizes two additional tiers of nodes that offer different roles: Masternodes process instant transactions while Systemnodes will host applications via the CrownPlatform. Members of the Crown Community can set up their own incentivized nodes to earn CRW while helping to maintain the network.
For more information, as well as an immediately useable, binary version Crown see http://crown.tech/wallet.
## Community
Crown is ultimately a community-driven platform. Its potential to bring social and echnological growth is contingent on the ideas and support its users provide. We invite you to lend your voice and imagination to this burgeoning platform and share in its success. Together, there’s no limit to what we can accomplish.
* Crown Forum: https://forum.crown.tech
* Mattermost: https://mm.crownlab.eu
* Discord: https://discord.gg/Tcrkazc
* Telegram: https://t.me/crownplatform
* Guides & How-to: https://forum.crown.tech/index.php?board=5.0
## Governance
Crown’s governance system has two core functions: choosing platform direction and funding. Unlike blockchain projects that rely on donations and pre-mined endowments, Crown uses 10% of each block reward to fund its own development. This allocation of funds allows us to reward miners and node operators for their contributions without compromising the platform’s coding and optimization efforts.
Copyright (c) 2014-2018 Crown Core Developers
Crown’s governance system also enables its community to vote on which changes (ranging from projects to network updates) will be implemented onto the blockchain. Any platform user can submit a proposal to grow or change the network.
* View proposals: http://crown.today/proposals
* How to create proposal:https://forum.crown.tech/index.php?topic=11.0
What is Crown?
----------------
## Server Nodes
Crown is an experimental new digital currency that enables anonymous, instant
payments to anyone, anywhere in the world. Crown uses peer-to-peer technology
to operate with no central authority: managing transactions and issuing money
are carried out collectively by the network. Crown Core is the name of open
source software which enables the use of this currency.
Crown uses two types of server nodes to build and protect its network — Systemnodes and Masternodes. Each of these dedicated servers are unique and provide vital infrastructure. By creating and running them, you can help our community grow while consistently earning CRW as a reward.
For more information, as well as an immediately useable, binary version of
the Crown Core software, see http://crown.tech/wallet.
### Masternodes
Masternodes supply substantial computing power to the Crown Platform, and have copies of the ledger stored and ready to distribute to the network if needed. Think of Masternodes as the stabilizing force behind Crown; they help us keep the network secure and running smoothly by tracking the ledger and confirming transactions at lightning speed with Instant Send. A Masternode requires 10,000 CRW collateral to run.
License
-------
See also: [Masternode Setup Guide](https://forum.crown.tech/index.php?topic=1241.0).
Crown Core is released under the terms of the MIT license. See [COPYING](COPYING) for more
### Systemnodes
Systemnodes are empty-shell servers that are tasked with hosting specific services for the Crown network. The Crown Platform will use Systemnodes to host new economy applications created by members of the community, connecting them to the Crown Platform through an API. A Systemnode requires 500 CRW collateral to run.
See also: [Systemnode Setup Guide](https://forum.crown.tech/index.php?topic=1240.0).
## Development
### Report a Bug
Bugs can be reported via the Gitlab issues page: https://gitlab.crown.tech/crown/crown-core/issues, tech support channel in [Mattermost](https://mm.crownlab.eu/crown/channels/tech-support) or emailing [support@crown.tech](email:support@crown.tech)
When describing a bug please include following information:
* **Issue summary** - an issue header which outlines the actual defect to be solved
* **Product** - for example *Desktop Wallet x64, Windows 10*
* **Build Found In** - for example *0.12.3.3*; this is very important as you may be using an old build and the issue may already have been resolved.
* **Steps to reproduce** - the steps to recreate exactly how the error occurred when you found the issue
* **Expected behavior** - what you would expect to see instead of the issue; this can be useful as it may trigger a conversation between yourself and the developer (or the team) about a better fix or possible solutions.
### Procedures for bounty development
Crown core developers are working hard on bug fixes, platform enhancements, and new product features.
Some of these tasks may be completed by talented community members through the bounty program.
Bounties are posted to the wiki and can be picked up by anyone who wants to submit new code to the project repository.
If you want to be directly notified of new bounties matching your specific skillset, fill out the short intake survey to get onto the [InSource Community Job Board](https://crown.link/insource).
If you have any questions regarding code submissions, please contact Josh 'fin' Wilcox (josh@crown.tech, or fin on mattermost) and ask about bounties.
## License
Crown Core is released under the terms of the MIT license. See [LICENSE](LICENSE) for more
information or see http://opensource.org/licenses/MIT.
- - -
Copyright © 2009-2018, Bitcoin Core Developers
Copyright © 2014-2016, Dash Core Developers
Development Process
-------------------
****************************************
**Bug Reporting**
****************************************
Bugs can be reported via the github issues page: https://github.com/Crowndev/crowncoin/issues
or emailing support@crown.tech
***************************************
**Merging and Updating**
***************************************
1. A Pull request is submitted.
2. It will then be reviewed and tested by the Crown development team.
3. After initial code inspection and internal testing the update will be deployed to the testnet for public testing.
4. A minimum of 15 days of testnet function per upgrade is required to fully validate and test the upgrade.
5. Once tested and validated, the pull request will be merged to master code and included in the next update.
******************************************
**Procedures for bounty development**
*****************************************
The Crown team will post a request for development and the requirements to receive the bounty reward and the size of the reward.
1.Developers at large can then post their interest in seeking the bounty on github and being developing on the change.
2. Once the at-large developer deems his code complete, they will submit a pull request via ionomy github with the label of the Bounty Feature.
3. It will then be reviewed and tested by the internal development team at ionomy.com.
4. After initial code inspection and internal testing the update will be deployed to the testnet.
5. A minimum of 15 days of testnet function per upgrade is required to fully validate and test the upgrade.
6. Once tested and validated, the pull request will be merged to master code and included in the next update.
7. When the version update is deployed Bounty funds will be released to the developer of the completed feature.
Copyright © 2014-2018, Crown Developers
Crown Core 0.12.0
=====================
# Crown Platform 0.12.4
Setup
---------------------
[Crown Core](http://crown.tech/wallet) is the original Crown client and it builds the backbone of the network. However, it downloads and stores the entire history of Crowncoin transactions (which is currently several GBs); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more. Thankfully you only have to do this once. If you would like the process to go faster you can [download the blockchain directly](http://txexplorer.infernopool.com/CRWbootstrap.zip).
[Crown software](http://crown.tech/wallet) is an implementation of a full Crown Platform node, which can be used both locally, as a wallet for CRW and for running Masternodes and Systemnodes. It is a full node: it downloads and stores the entire history of Crown transactions (which is currently several GBs); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more. If you would like the process to go faster you can _download the blockchain directly_ **(BOOSTRAP LINK NEEDED)**.
Running
---------------------
The following are some helpful notes on how to run Crown on your native platform.
## Install and Run Crown Wallet
Here are some helpful notes on how to run Crown on your native platform.
### Windows
Unpack the files into a directory, and then run `crown-qt.exe`.
### OSX
Drag Crown-Qt to your applications folder, and then run `Crown-Qt`.
### Unix
You need the Qt5 run-time libraries to run Crown-Qt. On Debian or Ubuntu:
Unpack the files into a directory and run: `bin/crown-qt` or `bin/crownd`. You need the Qt5 run-time libraries to run Crown-Qt. On Debian or Ubuntu:
sudo apt-get install libqtgui5
Unpack the files into a directory and run:
- bin/32/crown-qt (GUI, 32-bit) or bin/32/crownd (headless, 32-bit)
- bin/64/crown-qt (GUI, 64-bit) or bin/64/crownd (headless, 64-bit)
### Need Help?
* Ask for help on Mattermost: https://mm.crownlab.eu
* Or at Crown Forum: https://forum.crown.tech
* Or write a mail to [support@crown.tech](email:support@crown.tech)
## Run Masternode or Systemnode
### Windows
Here are some guides that will help you to setup and run an incentivized node:
* [Masternode Setup Guide](https://forum.crown.tech/index.php?topic=1241.0)
* [Systemnode Setup Guide](https://forum.crown.tech/index.php?topic=1240.0)
* [Masternode Configuration](masternode-config.md)
Unpack the files into a directory, and then run crown-qt.exe.
## Participate in Crown Decentralized Governance
### OSX
As a community member you can participate in the Governance by proposing projects that will advance Crown. You are also encouraged to discuss the poposals at [Crown Forum](https://forum.crown.tech/index.php?board=17.0).
Drag Crown-Qt to your applications folder, and then run Crown-Qt.
If you own one or several masternodes you can (and you should!) help to choose the direction in which Crown goes by carefuly studying the proposals and voting for those you consider worthy.
### Need Help?
* [Governance and Proposals](https://forum.crown.tech/index.php?topic=17.0) - some frequently asqued questions
* [Console Governance Interface](governance.md) - describes how to submit a proposal, how to vote for a proposal from the console and more
* [How To Submit a Proposal](https://forum.crown.tech/index.php?topic=11.0) - another proposal submission guide
* [Proposal Submission Template](https://forum.crown.tech/index.php?topic=9.0)
* [Active Proposals](https://crown.today/proposals)
* Ask for help on [#crowncoin](http://webchat.freenode.net?channels=crowncoin) on Freenode. If you don't have an IRC client use [webchat here](http://webchat.freenode.net?channels=crowncoin).
## Build Crown From Source
Building
---------------------
The following are developer notes on how to build Crown on your native platform. They are not complete guides, but include notes on the necessary libraries, compile flags, etc.
The following are developer notes on how to build Crown on your native platform. Right now Crown Core Development Team officially supports building only on [Unix](build-unix.md). Binaries for Windows and MacOS are generated via cross-compilation. Building under those systems natively is possible in theory - it's just not documented. If you have successful experience building Crown under those platforms, please contribute the instructions.
- [OSX Build Notes](build-osx.md)
- [Unix Build Notes](build-unix.md)
- [Windows build notes](build-msw.md)
## Development Documentation
Development
---------------------
The Crown repo's [root README](https://github.com/Crowndev/crowncoin/blob/master/README.md) contains relevant information on the development process and automated testing.
The Crown repo's [root README](../README.md) contains relevant information on the development process.
- [Coding Guidelines](coding.md)
- [Coding Style Guide](coding-style.md)
- [Multiwallet Qt Development](multiwallet-qt.md)
- [Release Notes](release-notes.md)
- [Release Process](release-process.md)
- [Unit Tests](unit-tests.md)
### Resources
* Discuss on [#crowncoin](http://webchat.freenode.net/?channels=crowncoin) on Freenode. If you don't have an IRC client use [webchat here](http://webchat.freenode.net/?channels=crowncoin).
### Miscellaneous
- [Assets Attribution](assets-attribution.md)
- [Files](files.md)
- [Tor Support](tor.md)
- [Init Scripts (systemd/upstart/openrc)](init.md)
License
---------------------
Distributed under the [MIT/X11 software license](http://www.opensource.org/licenses/mit-license.php).
This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](https://www.openssl.org/). This product includes
cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard.
* Crown Forum: https://forum.crown.tech
* Mattermost: https://mm.crownlab.eu
* Discord: https://discord.gg/Tcrkazc
* Telegram: https://t.me/crownplatform
* Guides & How-to: https://forum.crown.tech/index.php?board=5.0
## License
Crown is distributed under the terms of the [MIT/X11 software license](http://www.opensource.org/licenses/mit-license.php).
This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](https://www.openssl.org/). This product includes cryptographic software written by Eric Young ([eay@cryptsoft.com](mailto:eay@cryptsoft.com)), and UPnP software written by Thomas Bernard.
Also see [Assets Attribution](assets-attribution.md)
- - -
Copyright © 2009-2018, Bitcoin Core Developers
Copyright © 2014-2016, Dash Core Developers
Copyright © 2014-2018, Crown Developers
\ No newline at end of file
WINDOWS BUILD NOTES
===================
Compilers Supported
-------------------
TODO: What works?
Note: releases are cross-compiled using mingw running on Linux.
Dependencies
------------
Libraries you need to download separately and build:
name default path download
--------------------------------------------------------------------------------------------------------------------
OpenSSL \openssl-1.0.1c-mgw http://www.openssl.org/source/
Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html
Boost \boost-1.50.0-mgw http://www.boost.org/users/download/
miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/
Their licenses:
OpenSSL Old BSD license with the problematic advertising requirement
Berkeley DB New BSD license with additional requirement that linked software must be free open source
Boost MIT-like license
miniupnpc New (3-clause) BSD license
Versions used in this release:
OpenSSL 1.0.1c
Berkeley DB 4.8.30.NC
Boost 1.50.0
miniupnpc 1.6
OpenSSL
-------
MSYS shell:
un-tar sources with MSYS 'tar xfz' to avoid issue with symlinks (OpenSSL ticket 2377)
change 'MAKE' env. variable from 'C:\MinGW32\bin\mingw32-make.exe' to '/c/MinGW32/bin/mingw32-make.exe'
cd /c/openssl-1.0.1c-mgw
./config
make
Berkeley DB
-----------
MSYS shell:
cd /c/db-4.8.30.NC-mgw/build_unix
sh ../dist/configure --enable-mingw --enable-cxx
make
Boost
-----
MSYS shell:
downloaded boost jam 3.1.18
cd \boost-1.50.0-mgw
bjam toolset=gcc --build-type=complete stage
MiniUPnPc
---------
UPnP support is optional, make with `USE_UPNP=` to disable it.
MSYS shell:
cd /c/miniupnpc-1.6-mgw
make -f Makefile.mingw
mkdir miniupnpc
cp *.h miniupnpc/
Crowncoin
-------
MSYS shell:
cd \crowncoin
sh autogen.sh
sh configure
mingw32-make
strip crowncoind.exe
Mac OS X Build Instructions and Notes
====================================
This guide will show you how to build crownd (headless client) for OSX.
Notes
-----
* Tested on OS X 10.7 through 10.10 on 64-bit Intel processors only.
* All of the commands should be executed in a Terminal application. The
built-in one is located in `/Applications/Utilities`.
Preparation
-----------
You need to install XCode with all the options checked so that the compiler
and everything is available in /usr not just /Developer. XCode should be
available on your OS X installation media, but if not, you can get the
current version from https://developer.apple.com/xcode/. If you install
Xcode 4.3 or later, you'll need to install its command line tools. This can
be done in `Xcode > Preferences > Downloads > Components` and generally must
be re-done or updated every time Xcode is updated.
There's also an assumption that you already have `git` installed. If
not, it's the path of least resistance to install [Github for Mac](https://mac.github.com/)
(OS X 10.7+) or
[Git for OS X](https://code.google.com/p/git-osx-installer/). It is also
available via Homebrew.
You will also need to install [Homebrew](http://brew.sh) in order to install library
dependencies.
The installation of the actual dependencies is covered in the Instructions
sections below.
Instructions: Homebrew
----------------------
#### Install dependencies using Homebrew
brew install autoconf automake libtool boost miniupnpc openssl pkg-config protobuf qt
#### Installing berkeley-db4 using Homebrew
The homebrew package for berkeley-db4 has been broken for some time. It will install without Java though.
Running this command takes you into brew's interactive mode, which allows you to configure, make, and install by hand:
```
$ brew install https://raw.github.com/mxcl/homebrew/master/Library/Formula/berkeley-db4.rb -–without-java
```
The rest of these commands are run inside brew interactive mode:
```
/private/tmp/berkeley-db4-UGpd0O/db-4.8.30 $ cd ..
/private/tmp/berkeley-db4-UGpd0O $ db-4.8.30/dist/configure --prefix=/usr/local/Cellar/berkeley-db4/4.8.30 --mandir=/usr/local/Cellar/berkeley-db4/4.8.30/share/man --enable-cxx
/private/tmp/berkeley-db4-UGpd0O $ make
/private/tmp/berkeley-db4-UGpd0O $ make install
/private/tmp/berkeley-db4-UGpd0O $ exit
```
After exiting, you'll get a warning that the install is keg-only, which means it wasn't symlinked to `/usr/local`. You don't need it to link it to build crown, but if you want to, here's how:
$ brew link --force berkeley-db4
### Building `crownd`
1. Clone the github tree to get the source code and go into the directory.
git clone https://github.com/crownpay/crown.git
cd crown
2. Build crownd:
./autogen.sh
./configure
make
3. It is also a good idea to build and run the unit tests:
make check
4. (Optional) You can also install crownd to your path:
make install
Use Qt Creator as IDE
------------------------
You can use Qt Creator as IDE, for debugging and for manipulating forms, etc.
Download Qt Creator from http://www.qt.io/download/. Download the "community edition" and only install Qt Creator (uncheck the rest during the installation process).
1. Make sure you installed everything through homebrew mentioned above
2. Do a proper ./configure --with-gui=qt5 --enable-debug
3. In Qt Creator do "New Project" -> Import Project -> Import Existing Project
4. Enter "crown-qt" as project name, enter src/qt as location
5. Leave the file selection as it is
6. Confirm the "summary page"
7. In the "Projects" tab select "Manage Kits..."
8. Select the default "Desktop" kit and select "Clang (x86 64bit in /usr/bin)" as compiler
9. Select LLDB as debugger (you might need to set the path to your installtion)
10. Start debugging with Qt Creator
Creating a release build
------------------------
You can ignore this section if you are building `crownd` for your own use.
crownd/crown-cli binaries are not included in the Crown-Qt.app bundle.
If you are building `crownd` or `Crown-Qt` for others, your build machine should be set up
as follows for maximum compatibility:
All dependencies should be compiled with these flags:
-mmacosx-version-min=10.7
-arch x86_64
-isysroot $(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
Once dependencies are compiled, see release-process.md for how the Crown-Qt.app
bundle is packaged and signed to create the .dmg disk image that is distributed.
Running
-------
It's now available at `./crownd`, provided that you are still in the `src`
directory. We have to first create the RPC configuration file, though.
Run `./crownd` to get the filename where it should be put, or just try these
commands:
echo -e "rpcuser=crownrpc\nrpcpassword=$(xxd -l 16 -p /dev/urandom)" > "/Users/${USER}/Library/Application Support/Crown/crown.conf"
chmod 600 "/Users/${USER}/Library/Application Support/Crown/crown.conf"
The next time you run it, it will start downloading the blockchain, but it won't
output anything while it's doing this. This process may take several hours;
you can monitor its process by looking at the debug.log file, like this:
tail -f $HOME/Library/Application\ Support/Crown/debug.log
Other commands:
-------
./crownd -daemon # to start the crown daemon.
./crown-cli --help # for a list of command-line options.
./crown-cli help # When the daemon is running, to get a list of RPC commands
# Coding Style Guide
The rules and conventions described on this page must be followed in all new code. When modifying old code it's advisable to follow them within reason and with respect to style consistency.
# Style
## File organization
### Copyright header
Every file must have a typical copyright header. Files inherited from Bitcoin and Dash must include respective copyrights as well.
```c++
// Copyright (c) 2014-<this year> Crown developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php
```
### File Names
Filenames should be all lowercase and can include dashes (`-`). C++ files should end in `.cpp` and header files should end in `.h`.
### Header Guards
All header files should have `#define` guards to prevent multiple inclusion. The format of the symbol name should be `<PATH>_<FILE>_H`. To guarantee uniqueness, they should be based on the full path in a project's source tree.
```c++
#ifndef FOO_BAR_BAZ_H
#define FOO_BAR_BAZ_H
...
#endif
```
## Formatting
### Braces placement
Braces in namespaces, classes, functions, enums, unions, try-catch blocks, loops and if statements are always placed on the next line. When there is an if statement with a single line in the conditional branch, no braces are required. However, statements that follow the condition must be on a separate line.
In loops braces are always required.
```c++
namespace MyNamespace
{
class MyClass
{
};
void MyFunction()
{
if (...)
return;
for (auto element: container)
{
DoSomethingWith(element);
}
}
}
```
### Indentation
Indentation step is 4 spaces; spaces must be used instead of tabs.
### Class sections
Sections in class definition should be in the following order: `public` - `protected` - `private`. Make separate sections for member functions and data members. Within each section, generally prefer grouping similar kinds of declarations together, and generally prefer the following order: types (including `typedef`,
`using`, and nested structs and classes), constants, factory functions, constructors, assignment operators, destructor, all other methods, data members.
```c++
class MyClass
{
public:
void PublicMethod();
protected:
void ProtectedMethod();
private:
void PrivateMethod();
private:
std::string m_dataMember;
}
```
### Line length
Break long lines of code. Try to keep them inside reasonable bounds, say, 100-120 chars per line.
## Naming
Give as descriptive a name as possible, within reason.
Names of all identifiers are spelled in camel case (except for the cases where all capitals are used). Abbreviations are spelled with first upper case letter and the rest in lower case.
Prefixing conventions such as putting "C" in front of each class or using Hungarian notation are discouraged.
```c++
class XmlParser
{
...
};
void DisplayRtfmMessage();
```
### Variables
| Visibility | Variable | Constant | Compile-time constant (`constexpr`) |
| ------------------- | ------------- | ----------------------------- | ----------------------------------- |
| Local | `camelCase` | `camelCase` | `camelCase` |
| Static | `s_camelCase` | `camelCase` | `camelCase` |
| Class member | `m_camelCase` | `m_camelCase` | `m_camelCase` |
| Static class member | `m_camelCase` | `m_camelCase` | `m_camelCase` |
| Global | `g_camelCase` | `ALL_CAPITALS` or `camelCase` | `ALL_CAPITALS` or `camelCase` |
### Enums
Enum types are named in camel case with first capital letter. Enum values follow constant naming conventions: either camel case or all capitals in case of globally visible
```c++
class SystemnodeDb
{
enum ReadResult {
Ok,
...
};
};
enum Network
{
NET_UNROUTABLE = 0,
...
};
```
### Macros
Macros are named in all capitals with underscores.
```c++
#define DO_NOT_USE_ME true
```
### Functions
Both free functions and class member functions are named in camel case with first uppercase letter. The only exception is inheriting from a third-party class which follows a different naming convention, for example, when working with Qt
```c++
class SomeClass
{
void SomeMethod()
{
}
};
class ExceptionalCase: public QObject
{
virtual void redefinedQtMethod() override
{
}
void myBrandNewMethod()
{
}
}
```
### Classes and Structures
Classes are named in camel case with first uppercase letter.
### Namespaces
Namespaces are named in camel case with first uppercase letter. When declaring nested namespaces C++17-style nested namespace declaration is preferred.
```c++
namespace Crw::Net
{
class Node
{};
};
```
# Rules and Best Practices
More rules TBD
### Namespaces
Do not use *using-directives* (e.g.`using namespace foo`) in `.h` files. It's acceptable to use it in `.cpp` files, especially with `std::literals`, but try to keep those directives as local as possible.
### Unnamed Namespaces and StaticVariables
When definitions in a `.cpp` file do not need to be referenced outside that file, place them in an unnamed namespace. Prefere unnamed namespaces to declaring them `static`. Do not use either of these constructs in `.h` files
### Preprocessor Macros
Avoid using macros; prefer inline functions, enums, `const` and `constexpr` variables.
# Further Reading
These are books and resources that considered to be good advice on coding style and best practices. It's preferable to follow their advice when it's reasonable:
1. Herb Sutter, Andrei Alexandrescu "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices "
2. Scott Meyers "Effective Modern C++"
3. Bjarne Stroustrup, Herb Sutter ["C++ Core Guidelines"](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)
Coding
====================
Various coding styles have been used during the history of the codebase,
and the result is not very consistent. However, we're now trying to converge to
a single style, so please use it in new code. Old code will be converted
gradually.
- Basic rules specified in src/.clang-format. Use a recent clang-format-3.5 to format automatically.
- Braces on new lines for namespaces, classes, functions, methods.
- Braces on the same line for everything else.
- 4 space indentation (no tabs) for every block except namespaces.
- No indentation for public/protected/private or for namespaces.
- No extra spaces inside parenthesis; don't do ( this )
- No space after function names; one space after if, for and while.
Block style example:
```c++
namespace foo
{
class Class
{
bool Function(char* psz, int n)
{
// Comment summarising what this section of code does
for (int i = 0; i < n; i++) {
// When something fails, return early
if (!Something())
return false;
...
}
// Success return is usually at the end