-
Notifications
You must be signed in to change notification settings - Fork 10
Coding guidelines
- main: The main branch in which releases are derived from
neroshop/
└── src/
├── console/ # Neroshop command line interface (neroshop-console)
├── core/ # Core functionality of Neroshop
│ ├── crypto/ # Cryptographic algorithms (SHA-256, RSA, etc.)
│ ├── database/ # Database-specific code (sqlite3, lmdb)
│ ├── market/ # Marketplace-specific code (listings, cart, orders)
│ ├── network/ # Privacy networks (Tor, I2P)
│ ├── price/ # Cryptocurrency price APIs and exchanges
│ ├── protocol/ # Protocol implementations
│ ├── tools/ # Helper and utility code
│ ├── wallet/ # Blockchain wallet implementations
│ └── (root files) # Core root directory files
├── daemon/ # Neroshop daemon executable (neroshopd)
└── gui/ # GUI code interfacing with QML and C++ (neroshop)
└── qml/ # User interface code (QML files)
└── external/ # Third-party libraries A.K.A "dependencies"
└── assets/ # Resources (app icons, images, fonts, shaders, etc.)
└── tests/ # Unit tests (usually broken due to having low priority)
└── qml.qrc # QML Resource file embedded in the GUI
└── proto/ # Protobuf (.proto) files
-
camelCaseis only allowed in theguiandqmlcode. - Function and variable names should always be in
snake_caseform in theconsole,core, anddaemoncode, excluding theguiandqmlcode, which will usecamelCasefor both functions and variables. - Class, struct, and enum names must always be in
PascalCaseform.
-
File names should be
lowercaseand file names containing separate words should be separated using an underscore_. -
All
cppfiles should have a header file, with files containing aint main()function being the exception to the rule. Headers do not need their owncppfiles.
-
Place the minimum necessary includes into a header file, as anyone else who uses that header will be forced to
#includeall of them too. In larger projects, this leads towards slower builds, dependency issues, and all sorts of other nastiness. -
Any includes not used in the header file, but used in the source file should be added to the source file instead.
-
Use forward declaration when necessary.
Header files should be included in the particular order (This won't be enforced though so ignore if you want):
1. hpp file corresponding to this cpp file (if applicable)
1.1. A blank line
2. headers from the same component,
2.1. A blank line
3. headers from other components (third party)
3.1. A blank line
4. system headers (with C system headers being first and C++ system headers being last)
- Never use
using namespace std;as naming conflictions could occur. Usestd::instead. This applies to all namespaces. - Namespaces must be
lowercaseand namespaces containing separate words should be separated using an underscore_.
4 spaces for each line of code. No tabs allowed.
version changes:
only change these parts of a version under the following circumstances:
major - when there are many breaking changes that may not be backwards compatible
minor - when a new feature (e.g. new function) is added
patch - when a bug is fixed in existing function(s)
- src/core/version.hpp
- CMakeLists.txt:
line 7,8,9 - meson.build:
line 1
wallet network type changes:
- src/core/wallet/wallet.cpp:
line 19 - src/core/protocol/p2p/node.cpp: @
verify()function
default restore height changes:
- src/core/wallet/wallet.cpp
- qml/pages/MainPage.qml
settings changes:
- src/core/settings.{cpp,hpp}
- src/gui/settings_manager.{cpp,hpp}
- qml/components/SettingsDialog.qml
Pretty much all configuration parameters (e.g. macros, constants, etc.) are defined in src/neroshop_config.hpp.
Files from console, daemon, and gui can all depend on files from core but core must never depend on either of them.
Most importantly, core MUST NOT depend on Qt as Qt is intended to be solely used within the user interface code (gui) and the GUI library can be replaced at anytime.