A C++17 blockchain-style audit framework for file access, featuring:
- gRPC-based client/server and peer-to-peer gossip protocols
- RSA digital signatures for end-to-end integrity and non-repudiation
- Merkle-tree block integrity and cryptographic hashing
- Leader election and heartbeat for high-availability consensus
- On-demand block retrieval (
GetBlock) for new or recovering nodes - Persistent mempool, chain.json, and per-block JSON files
-
Submit & Gossip Audits
Clients submitFileAuditrequests over gRPC; servers persist them to a mempool and gossip to peers. -
Batch Block Proposal
The leader periodically collects pending audits, forms a block, computes a Merkle root, and broadcasts aProposeBlockmessage. -
Voting & Commit
Peers verify each proposal (Merkle root, previous-hash, audit signatures), vote, and upon majority, commit the block (updatingchain.json, pruning the mempool, and writingblocks/block_<id>.json). -
Leader Heartbeats
Nodes exchange heartbeats every 2 s, tracking each other’s latest block IDs and mempool sizes, and marking peers dead after a 4 s timeout. -
Leader Election
When no leader is known or the leader dies, a node triggers an election viaTriggerElection/NotifyLeadershipRPCs, comparing its own metrics (block ID, mempool size, address) against the candidate to vote. -
Block Synchronization
Recovering nodes can request missing blocks (GetBlock) from peers, ensuring they catch up before accepting new proposals.
- C++17 compiler (e.g.
gcc≥ 9,clang≥ 11) - CMake ≥ 3.15
- gRPC & Protocol Buffers
- OpenSSL (for RSA signing/verification)
- nlohmann/json (header-only)
. ├── CMakeLists.txt ├── README.md ├── peers.json # List of peer addresses ├── leader.json # Initial leader, batch size & interval ├── keys/ # RSA keypair for clients ├── proto/ # .proto definitions ├── include/ # Public headers ├── src/ # Implementation (.cpp) files ├── blocks/ # Generated per-block JSON files ├── mempool.dat # Persisted mempool └── chain.json # Persisted blockchain metadata
chmod +x starter.sh build.sh run.sh
./starter.sh
./build.sh./run.shIf you want to run the server with a different address run:
cd build
./node_server 0.0.0.0:<port_number>For running the client:
cd build
./clientpeer.json:
Put address of all the peer nodes in the array
leader.json:
The leader_addr field is redundant, you can use the batch size, batch_interval_s to determine when to trigger a block creation and proposal.