0
0
Blockchain / Solidityprogramming~10 mins

Public vs private blockchains - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Concept Flow - Public vs private blockchains
Start
Choose Blockchain Type
Public Blockchain
Open to Everyone
Decentralized
Consensus by All
Transparent
End
This flow shows the choice between public and private blockchains, highlighting their access, control, consensus, and transparency differences.
Execution Sample
Blockchain / Solidity
blockchain_type = 'public'
if blockchain_type == 'public':
    access = 'open to everyone'
else:
    access = 'restricted access'
print(access)
This code checks the blockchain type and sets access accordingly, then prints the access type.
Execution Table
Stepblockchain_typeConditionBranch TakenaccessOutput
1'public'blockchain_type == 'public'Trueopen to everyone
2'public'elseFalseopen to everyone
💡 Condition true at Step 1 (if branch taken), else skipped (Step 2), access set and printed, execution ends.
Variable Tracker
VariableStartAfter Step 1After Step 2Final
blockchain_type'public''public''public''public'
accessundefined'open to everyone''open to everyone''open to everyone'
Key Moments - 2 Insights
Why does the code choose 'open to everyone' access?
Because the variable blockchain_type is 'public', the condition blockchain_type == 'public' is True at Step 1 in the execution_table, so the code sets access to 'open to everyone'.
What happens if blockchain_type is not 'public'?
The condition at Step 1 becomes False, so the else branch runs (Step 2), setting access to 'restricted access' instead.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the value of 'access' after Step 1?
A'open to everyone'
B'restricted access'
Cundefined
D'public'
💡 Hint
Check the 'access' column in the row for Step 1 in execution_table.
At which step does the else branch run if blockchain_type is 'private'?
AStep 1
BStep 2
CNo step, code stops
DStep 3
💡 Hint
Look at the 'Branch Taken' column for the else condition in execution_table.
If blockchain_type changes to 'private', how does the 'access' variable change in variable_tracker?
AIt stays 'open to everyone'
BIt becomes undefined
CIt becomes 'restricted access'
DIt becomes 'public'
💡 Hint
Refer to the explanation in key_moments about the else branch and variable_tracker changes.
Concept Snapshot
Public vs Private Blockchains:
- Public: open to everyone, decentralized, consensus by all, transparent.
- Private: restricted access, centralized control, consensus by selected nodes, limited transparency.
- Access control is key difference.
- Code example shows simple access assignment based on type.
Full Transcript
This visual execution compares public and private blockchains by showing a simple code example that sets access based on blockchain type. The flow diagram outlines the decision path from choosing blockchain type to access and consensus differences. The execution table traces the code steps, showing how the condition blockchain_type == 'public' leads to setting access to 'open to everyone'. The variable tracker follows variable changes step by step. Key moments clarify why the code chooses one branch over another. The quiz tests understanding of variable values and branching decisions. The snapshot summarizes the main differences and the code logic.