fcn从头开始
介绍 (Introduction)
With Web 3.0 and blockchain becoming more mainstream every day, do you know what blockchain is? Do you know its technical advantages and use-cases?
随着Web 3.0和区块链每天变得越来越主流,您知道什么是区块链吗? 您知道它的技术优势和用例吗?
The goal of this tutorial is to introduce blockchain technology from a technical perspective by building one from scratch.
本教程的目的是通过从头开始构建区块链技术,从技术角度介绍区块链技术。
Forget everything you've heard about blockchain from social media. Now, you will build a blockchain system from ground zero to really understand the ins and outs of this peer-to-peer, distributed technology.
忘记您从社交媒体上听到的有关区块链的所有信息。 现在,您将从零开始构建一个区块链系统,以真正了解这种对等分布式技术的来龙去脉。
Afterwards, make your own mind up about its future and advantages. Spoiler alert: you will fall in love with programming blockchain software.
然后,自己决定其未来和优势。 剧透警报:您将爱上编程区块链软件。
怎么样? (How?)
You will follow the story of a software developer who is looking to revolutionize his local bar by implementing blockchain technology for its payment system.
您将跟随一个软件开发人员的故事,该软件开发人员希望通过为其支付系统实施区块链技术来革新其本地律师事务所。
Although blockchain has several undeniable use-cases, at the moment, the number one application is payments. This is because banks are still running on an inefficient, 40 year old infrastructure powered by CSV files and FTP.
尽管区块链有多个不可否认的用例,但目前,排名第一的应用是支付。 这是因为银行仍在使用CSV文件和FTP的低效率,已有40年历史的基础架构上运行。
The story comes with a lot of fun and intriguing facts about the overall blockchain ecosystem and different protocols such as Bitcoin, Ethereum and XRP.
这个故事带来了关于整个区块链生态系统以及比特币,以太坊和XRP等不同协议的许多有趣有趣的事实。
您将在本教程中构建,学习和做什么? (What will you build, learn, and do in this tutorial?)
- You'll setup a Go project on your local machine without any prior GoLang experience 您将在没有任何GoLang经验的情况下在本地计算机上设置Go项目
- You'll generate and distribute your first blockchain tokens 您将生成并分发您的第一个区块链令牌
- You'll develop a CLI controlled database in Go from scratch 您将在Go中从头开始开发CLI控制的数据库
- You'll find out how few rights users posses in their favourite apps 您会发现在他们最喜欢的应用中,有多少位权限用户拥有
- You'll discover the blockchain's main value proposition 您会发现区块链的主要价值主张
- You'll make your DB immutable using a secure cryptographic hash function 您将使用安全的加密哈希函数使数据库不可变
So let's get started and jump into our story.
因此,让我们开始吧,进入我们的故事。
⭐认识主角安德烈(Andrej)。 (⭐ Meet the protagonist, Andrej.)
Andrej is a bar owner by night and a software developer by day in a small Slovakian town called Bardejov.
Andrej晚上在斯洛伐克的一个叫Bardejov的小镇里是酒吧的老板,白天是软件开发人员。
Andrej is tired of:
安德烈(Andrej)厌倦了:
Andrej would love to:
安德烈(Andrej)希望:
-
Have a perfect auditable history of the bar's activities and sales to make his bar compliant with tax regulations
对酒吧的活动和销售有完善的可审计历史,以使其酒吧符合税收法规
-
Transform his bar into an autonomous, payment-efficient, decentralized and safe environment his customers can trust and profit from
将他的律师事务所转变为客户可以信任并从中获利的自治,付款高效,去中心化和安全的环境
His goal is to write a simple program and keep all the balances of his clients in virtual form.
他的目标是编写一个简单的程序,并以虚拟形式保留其客户的所有余额。
Andrej shares his thoughts here:
安德烈(Andrej)在这里分享他的想法:
"Every new customer will give me cash, and I will credit them an equivalent amount of my digital tokens (coins/cryptocurrency). The tokens will represent a monetary unit within and outside the bar.
“每个新客户都会给我现金, 我会把他们等值的我的数字代币(硬币/加密货币)记入贷方。代币将代表条形图内外的货币单位。
The users will use the tokens for all bar functionalities from paying for drinks, borrowing and lending them to their friends, and playing table tennis, poker and kicker.
用户将把令牌用于所有酒吧功能,包括支付酒水,将其借贷给朋友,打乒乓球,玩扑克和踢球。
Having a bar powered by blockchain tokens will generate tons of value for my customers. Contrary to my competition and other bars on this street, where the customers only spend money and get a hangover in exchange, my bar customers holding bar's tokens will have shareholders rights.
拥有由区块链令牌驱动的酒吧将为我的客户带来大量价值。 与我在这条街上的竞争对手和其他酒吧相反,那里的顾客只花钱并得到宿醉作为交换, 我持有酒吧代币的酒吧顾客将拥有股东权利。
Similar to owning a large portion of stocks in a company like Apple or Microsoft, the customers holding these bar tokens will be able to decide how the bar will operate by voting and deciding on:
与在Apple或Microsoft这样的公司中拥有大量股票类似,持有这些条形码令牌的客户将能够通过投票并决定以下内容来决定条形码的运作方式:
- drinks prices 饮料价格
- opening hours 营业时间
- new features (TV, Jukebox...) 新功能(电视,自动点唱机...)
- interior and exterior design 室内和外部设计
- profits allocation 利润分配
- etc. 等等
Oh, this will be a programming dream!
哦,这将是一个编程梦想!
I will call the tokens: The Blockchain Bar tokens, TBB!"
我将这些代币称为:区块链酒吧代币, TBB! ”
Now that Andrej has shared his dream, we'll get started.
现在,安德烈(Andrej)分享了他的梦想,我们将开始。
目录 (Table of Contents)
要求 (Requirements)
Let's dive into our tutorial. I recommend 2+ years of programming experience in Java/PHP/Javascript, or another language similar to Go.
让我们深入研究我们的教程。 我推荐2年以上Java / PHP / Javascript或类似于Go的语言的编程经验。
If you want to get a good quick intro to go, here's a free course that'll get you started.
如果您想快速入门, 这里有一个免费课程 ,可以帮助您入门。
You can also complete the official 17 lectures of A Tour Of Go to get familiar with the language syntax and basic concepts (~20 mins).
您也可以完成A Tour Of Go的 17场官方讲座,以熟悉语言语法和基本概念(约20分钟)。
为什么去? (Why Go?)
Because like blockchain, it's a fantastic technology for your overall programming career. Go is a trendy language and Go devs are better paid than the average Java/PHP/Javascript positions.
因为像区块链一样,这对于您的整体编程职业来说是一种了不起的技术。 Go是一种流行的语言,Go开发人员的薪水比平均Java / PHP / Javascript职位高。
Go is optimized for multi-core CPU architecture. You can spawn thousands of light-weight threads (Go-routines) without problems. It's extremely practical for highly parallel and concurrent software such as blockchain networks.
Go针对多核CPU架构进行了优化。 您可以生成数千个轻量级线程(Go例程)而不会出现问题。 对于高度并行和并发的软件(例如区块链网络),这是极其实用的。
By writing your software in Go, you achieve nearly C++ level of performance out of the box without killing yourself for that one time you forgot to free up memory.
通过用Go编写软件,您可以立即获得接近C ++的性能,而不会因为忘记释放内存而丧生。
Go also compiles to binary which makes it very portable.
Go还可以编译为二进制文件,这使其非常易于移植。
设置项目 (Setup the project)
This article has a dedicated open-sourced Github repository with full source code so you can compile the code and run the program on your own local machine.
本文具有专用的开源Github存储库,其中包含完整的源代码,因此您可以编译代码并在自己的本地计算机上运行程序。
If you get stuck at any chapter or a particular line of code, create a Github Issue in this repository describing your problem and I will help you out ASAP!
如果您陷入任何一章或特定的代码行中,请在此存储库中创建一个描述您的问题的Github问题,我会尽快帮助您!
↓ Visit the Github repository and follow the installation instructions ↓
↓访问Github存储库并按照安装说明进行操作↓
01 | MVP数据库 (01 | The MVP Database)
✍ git checkout c1_genesis_json
git checkout c1_genesis_json
Andrej mastered relational SQL databases in the 90s. He knows how to make advanced data models and how to optimize the SQL queries.
Andrej在90年代掌握了关系SQL数据库。 他知道如何制作高级数据模型以及如何优化SQL查询。
It's time for Andrej to catch up with innovation and start building Web 3.0 software.
现在是Andrej赶上创新并开始构建Web 3.0软件的时候了。
Luckily, after reading "The Lean Startup" book last week, Andrej feels like he shouldn't over-engineer the solution just yet. Hence, he chooses a simple but effective JSON file for the bar's MVP database.
幸运的是,安德烈(Andrej)在上周阅读了《精益创业》(The Lean Startup)一书后,觉得他现在还不应该过度设计解决方案。 因此,他为酒吧的MVP数据库选择了一个简单但有效的JSON文件。
In the beginning, there was a primitive centralized database.
最初,有一个原始的集中式数据库。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)