มาสร้าง Blockchain ของเราเองกันเถอะ ( 1 )
Blockchain คือ การบันทึกข้อมูล ที่ยากในการแก้ไข ( แทบจะเป็นไปไม่ได้ ) ที่จะเปลี่ยนแปลงข้อมูล, hack ระบบ, หรือโกงได้

องค์ประกอบของ blockchain จะประกอบด้วย Block ซึ่งเป็นที่เก็บข้อมูลที่เราต้องการบันทึก เมื่อมี block ใหม่เข้ามา ก็จะทำการไปต่อท้ายเหมือนเป็นสายโซ่ ( chain ) เราเลยเรียกว่า Blockchain แต่การที่จะเพิ่ม block เข้าไปใหม่ใน blockchain network จะมีขั้นตอนที่เรียกว่า proof of work ( การสร้าง hash key ที่ตรงตามเงื่อนไขที่เรากำหนดไว้ เราอาจจะรู้จักขั้นตอนนี้ว่า "ขุด" mine )
เราสามารถนำ blockchain มาเป็น บัญชี digital ( digital ledger ) โดยทำการสำเนา transaction และแจกจ่าย ( distributed ) ไปในระบบเครือข่าย ( network system ) ของ blockchain ด้วยการทำงานแบบ decentralize network ทำให้ระบบมีความปลอดภัยสูง และยากในการที่จะทำการปลอมแปลงข้อมูลได้ทุก node ใน network. ในเวลาเดียวกันได้
เรามาดูว่า data structure ของ blockchain จะมีหน้าตาอย่างไร
function Blockchain() {
this.chain = [];
this.pendingTransactions = [];
this.currentNodeUrl = currentNodeUrl;
this.networkNodes = [];
this.createNewBlock(100, '0', '0');
};
มาทำความเข้าใจแต่ละ attribute ใน Blockchain class
- chains array: เป็นที่เก็บ block ใน blockchain
- pendingTransactions: ที่พัก transaction เพื่อจะถูกเก็บไว้ใน block ที่จะถูกสร้างขึ้นใหม่
- currentNodeUrl: URL ของ node นี้ ( เราจะสร้าง blockchain server ในภายหลัง )
- networkNodes: node อื่นๆ ใน blockchain network
- this.createNewBlock(100, '0', '0') คือ block แรกของ blockchain ( genesis block )
ในบทความต่อไป จะอธิบายเกี่ยวกับการจัดเก็บข้อมูลของ transaction ไปใน block อย่างไร
Get in Touch with us
Related Posts
- How to Use Local LLM Models in Daily Work
- How to Use Embedding Models with LLMs for Smarter AI Applications
- Smart Vision System for Continuous Material Defect Detection
- Building a Real-Time Defect Detector with Line-Scan + ML (Reusable Playbook)
- How to Read Source Code: Frappe Framework Sample
- Interface-Oriented Design: The Foundation of Clean Architecture
- Understanding Anti-Drone Systems: Architecture, Hardware, and Software
- RTOS vs Linux in Drone Systems: Modern Design, Security, and Rust for Next-Gen Drones
- Why Does Spring Use So Many Annotations? Java vs. Python Web Development Explained
- From Django to Spring Boot: A Practical, Visual Guide for Web Developers
- How to Build Large, Maintainable Python Systems with Clean Architecture: Concepts & Real-World Examples
- Why Test-Driven Development Makes Better Business Sense
- Continuous Delivery for Django on DigitalOcean with GitHub Actions & Docker
- Build a Local Product Recommendation System with LangChain, Ollama, and Open-Source Embeddings
- 2025 Guide: Comparing the Top Mobile App Frameworks (Flutter, React Native, Expo, Ionic, and More)
- Understanding `np.meshgrid()` in NumPy: Why It’s Needed and What Happens When You Swap It
- How to Use PyMeasure for Automated Instrument Control and Lab Experiments
- Supercharge Your Chatbot: Custom API Integration Services for Your Business
- How to Guess an Equation Without Math: Exploring Cat vs. Bird Populations
- How to Build an AI-Resistant Project: Ideas That Thrive on Human Interaction