How nanocurrency/nano-node works
Main Components
• Nano Node Core: The heart of the project (found in directories like “nano/node”, “nano/nano_node”, “nano/nano_rpc”, etc.) that includes the node’s main functionality – transaction processing, consensus, block processing, and network communication.
• Network Layer & Transport: Components for peer-to-peer communication, handling TCP channels, in-process/inproc transport, IPC via flatbuffers, and other network-related operations (e.g., the “nano/node/transport” folder).
• Ledger & Storage: Subsystems responsible for storing blockchain data including blocks, accounts, confirmation heights, and caching (managed in the “nano/store” directory and its LMDB or RocksDB subcomponents).
• Consensus & Vote Processing: Modules handling elections, block confirmation, vote generation, and rebroadcasting (components in “nano/node” related to elections, votes, and the distributed work mechanism).
• RPC & API Services: An interface layer that serves as the public API (via RPC) for external clients and exchange integrations (evidenced by “nano/rpc”, “nano/nano_rpc”).
• Wallet & Security: Areas managing user wallets, private key security, and cryptographic operations (components in “nano/nano_wallet” and “nano/secure”).
• Cryptographic Libraries: Harnessing crypto routines for hashing (blake2) and signature verification (ed25519-donna) which are found in separate “crypto” directories.
• Auxiliary & Build/CI Infrastructure: The project includes comprehensive CI/CD pipelines (under “ci/”, “.github/”, “docker/”), build scripts (CMakeLists.txt, submodules for boost, flatbuffers, etc.), and test directories which are crucial for continuous integration and testing aspects but can be abstracted in the high-level overview.
Relationships and Interactions
• The Nano Node Core communicates with the network layer to exchange blocks, votes, and other messages with its peers.
• It also interacts directly with the ledger/storage sub-system to write or retrieve block and account data.
• The RPC/API layer serves as a gateway for external control and monitoring – passing commands between clients and the Nano Node Core.
• Wallet/security components connect to both the node core (for signing transactions) and to the secure storage (to manage wallet data).
• Cryptographic libraries are “called” by several modules (from consensus, vote processing, to signing) to offer secure hashing and signature functionality.
• The CI/CD scripts and test suites ensure that all of these components can be built, deployed, and tested reliably.
Architectural Patterns and Design Principles
• Modular Design: The project is divided into multiple self-contained modules (node, rpc, wallet, store, crypto) that interact with well-defined interfaces.
• Layered Architecture: There is a clear separation between the application logic (node, consensus, processing) and infrastructure (network transport and database storage).
• Asynchronous and Event-Driven Programming: Utilizing boost asio for networking and thread pools for managing concurrent processing (as seen in nano/boost/asio and threading components).
• Dependency Injection & Cross-platform Abstractions: The existence of platform-specific directories (e.g., “nano/lib/plat”) shows that the system is designed to work across multiple operating systems.
• CI/CD and Automation: Extensive automation scripts (in “ci/”, “docker/”) ensure that building, testing, and deployment are managed efficiently.
Relevant Technologies, Frameworks, and Libraries
• C++ with CMake Build System: Core implementation is in C++ with CMake as the main build configuration.
• Boost (ASIO, Beast, and Process): Used for asynchronous I/O, networking, and other utilities (visible in the “nano/boost” directory and submodules).
• LMDB and RocksDB: For database storage in the ledger component (“nano/store/lmdb”, “nano/store/rocksdb”).
• Flatbuffers: For fast IPC and serialization (noted in “api/flatbuffers” and “nano/ipc_flatbuffers_lib”).
• Cryptographic libraries: ed25519-donna and blake2 implementations are part of the crypto submodules.
• CI/CD Tools: GitHub Actions, GitLab CI, Docker – all play a role in deployment and testing.