-
Blockchain Core (C++)
- Block structure and chain management
- Consensus mechanism (LCR)
- Transaction nonce validation
- State management
-
API Layer (Node.js)
- RESTful interface
- Transaction Signature Validation
- Block Validation
- P2P Network communication
- Client request handling
-
Native Miner (C++)
- Calculate Nonce for Cryptographic Puzzle
-
Web Client (MERN)
- Web Interface
- Utility tools for Signing, generating Assymetric Cryptographic Key Pairs
class Block {
public:
string prevHash;
string message;
int blockNumber;
string hash;
vector<shared_ptr<Block>> children;
shared_ptr<Block> parent;
Block(string prevHash, string message, int blockNumber, string hash)
: prevHash(prevHash), message(message), blockNumber(blockNumber), hash(hash) {}
};
class Blockchain {
public:
unordered_map<int, vector<shared_ptr<Block>>> levels; // Blocks stored by level
vector<shared_ptr<Block>> confirmedBlockchain;
int confirmedLength;
string lastHash;
bool isGenesisAdded = false;
shared_ptr<Block> Genesis;
}
- The chain with the most accumulated blocks is considered the valid chain
- When a node receives blocks, it:
- Validates the new blocks
- Compares the length with its current chain
- Switches to the longer chain if one is found
- When a conflict is detected, nodes:
- Temporarily maintain all chain versions
- Continue building on the arbitarily left chain
- Prune the shorter fork once the longest chain is clearly established
-
Transaction Validation:
- Digital signature verification
- Nonce checking for replay protection
-
State Management:
- Blockchain State stored as Merkle-Patricia Tree
- Upon request for Transaction Execution to state
- Nonce is verified
- if verified, Balance is updated and nonce is updated
- Prevents Replay Attacks
-
Node Discovery
- New nodes register via
/contribute
endpoint - Peer list maintained in storage
- New nodes register via
-
Transaction Propagation
- Broadcast to all peers
-
Merkle Patricia Tree
-
Blockchain
src/
├──
-
Transaction Security
- ECDSA signature verification
- Replay attack prevention
-
Network Security
- Node authentication
-
Coding Standards
- C++11 or higher
- JavaScript
- Comprehensive unit tests
-
Testing
- Unit tests for core components
- Integration tests for API
- Network simulation tests