How samikshabagri/distributed-consensus-simulator works
This is a continuously running C++ banking and distributed-consensus simulator. Its main workflow creates and starts a five-node Raft cluster, waits for a leader, maps each account key through consistent hashing, submits the transaction to the leader, and replicates log entries to followers. The simulator also exercises leader step-down and re-election. The graph separates the client driver, Raft roles and log, and in-memory messaging and routing. README-described capabilities are retained, but source excerpts show no follower acknowledgements or actual quorum tracking; commit behavior is therefore represented as the leader’s proposal step, not verified consensus.
Main entry points: RaftNode.cpp Raft nodes · main.cpp Simulation driver · NetworkSimulator.h Network simulator · ConsistentHash.h Consistent hash ring
Components 12
Banking Driver
- Simulation driver
main.cpp - Account routing
NetworkSimulator.h - Consistent hash ring
ConsistentHash.h
Raft Cluster
- Raft nodes
RaftNode.cpp - Election and roles
RaftNode.cpp - Message dispatch
RaftNode.cpp - Transaction log replication
RaftNode.cpp
In-Memory Network
- Protocol messages
Message.h - Network simulator
NetworkSimulator.h - Node mailboxes
NetworkSimulator.h - Thread-safe queue
ThreadSafeQueue.h
Other components
- Banking client
Connections 18
- Banking client → Simulation driver: submits transactions
main.cpp - Simulation driver → Raft nodes: starts cluster
main.cpp - Simulation driver → Account routing: routes account
main.cpp - Account routing → Consistent hash ring: maps account
NetworkSimulator.h - Simulation driver → Raft nodes: proposes transaction
main.cpp - Simulation driver → Raft nodes: simulates step-down
main.cpp - Raft nodes → Network simulator: registers node
RaftNode.cpp - Raft nodes → Node mailboxes: gets mailbox
RaftNode.cpp - Raft nodes → Election and roles: runs elections
RaftNode.cpp - Raft nodes → Message dispatch: processes messages
RaftNode.cpp - Message dispatch → Transaction log replication: handles entries
RaftNode.cpp - Raft nodes → Transaction log replication: appends and broadcasts
RaftNode.cpp - Raft nodes → Network simulator: sends messages
RaftNode.cpp - Network simulator → Node mailboxes: routes messages
NetworkSimulator.h - Network simulator → Consistent hash ring: adds nodes
NetworkSimulator.h - Node mailboxes → Thread-safe queue: uses queue
NetworkSimulator.h - Network simulator → Protocol messages: routes messages
NetworkSimulator.h - Message dispatch → Protocol messages: dispatches by type
RaftNode.cpp