มาสร้าง 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
- Using the Source–Victim Matrix to Connect RE102 and RS103 in Shipboard EMC
- Rebuilding Trust with Technology After a Crisis
- Digital Beauty: Reimagining Cosmetic Clinics with Mobile Apps
- Smarter Product Discovery with AI: Image Labeling, Translation, and Cross-Selling
- How TAK Systems Transform Flood Disaster Response
- Smarter Shopping: From Photo to Product Recommendations with AI
- Tackling Antenna Coupling Challenges with Our Advanced Simulation Program
- The Future of Work: Open-Source Projects Driving Labor-Saving Automation
- 下一个前沿:面向富裕人群的数字私人俱乐部
- The Next Frontier: A Digital Private Club for the Affluent
- Thinking Better with Code: Using Mathematical Shortcuts to Master Large Codebases
- Building the Macrohard of Today: AI Agents Platform for Enterprises
- Build Vue.js Apps Smarter with Aider + IDE Integration
- Yo Dev! Here’s How I Use AI Tools Like Codex CLI and Aider to Speed Up My Coding
- Working With AI in Coding the Right Way
- How to Select the Right LLM Model: Instruct, MLX, 8-bit, and Embedding Models
- 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)