fcn从头开始_如何使用Go从头开始构建区块链

2023-11-14

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)厌倦了:

  • Programming solid, old fashion PHP/Java/Javascript applications

    编程可靠的老式PHP / Java / Javascript应用程序

  • Forgetting how much money his friends and clients owe him for all the unpaid Friday night vodka shots

    忘记了他的朋友和客户欠他周五晚上所有未付的伏特加酒花多少钱
  • Spending time collecting and counting coins, returning change and generally touching COVID-19-exposed bank bills

    花费时间收集和计数硬币,退还找零钱并且通常接触COVID-19暴露的银行票据
  • Maintaining different plastic chips for table football, darts, billiard and poker

    维护用于桌上足球,Dart,台球和扑克的不同塑料芯片

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(使用前将#替换为@)

fcn从头开始_如何使用Go从头开始构建区块链 的相关文章

  • 从 Bitmap 类创建 .bmp 图像文件

    我创建了一个使用套接字的应用程序 客户端在其中接收图像并将图像数据存储在 Bitmap 类中 谁能告诉我如何创建一个名为我的图像 png or 我的图像 bmp来自此 Bitmap 对象 String base64Code dataInpu
  • Java,将 null 分配给对象和仅声明之间有什么区别

    之间有什么区别 Object o null and Object o 仅声明 有人可以回答我吗 这取决于您声明变量的范围 例如 局部变量没有default values在这种情况下你将不得不分配null手动 在这种情况下实例变量分配 nul
  • 使用 java 的 RAR 档案 [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 将 JSON Map 传递到 Spring MVC 控制器

    我正在尝试将 Map 的 JSON 表示形式作为 POST 参数发送到我的控制器中 RequestMapping value search do method RequestMethod GET consumes application j
  • 隐藏类的 System.out.print 调用

    我正在使用 java 库 jar 文件 该文件的作者放入了一堆System out print and System out printlns 有没有办法隐藏特定对象的这些消息 编辑 看起来jar文件似乎正在创建一堆线程 并且每个线程都有它
  • 我需要显式关闭连接吗?

    我持有一个实例MongoClient and DB在我的应用程序中 每次我想执行某些操作时 我都会调用getCollection 我想知道是否需要显式关闭连接 就像connection close 在 JDBC 中 强调一下 我只有一个Mo
  • 根据哈希值确认文件内容

    我需要 检查完整性 content文件数量 文件将写入 CD DVD 可能会被复制多次 这个想法是识别正确复制的副本 在从 Nero 等中删除它们之后 我对此很陌生 但快速搜索表明Arrays hashCode byte http down
  • ASM之前看一下maxStack指令吗?

    我正在尝试使用 ASM 库将字节代码转换为不同的格式 这可以使用 MethodVisitor 来完成 就像这个简单的测试代码一样 return new MethodVisitor ASM7 Override public void visi
  • MongoDB:尝试从 JSON 读取 Long 导致 java.lang.Integer 无法转换为 java.lang.Long

    我有一个代码可以从 MongoDB 读取特定格式的数据 我需要测试一下 为此 我使用要测试的数据创建一个 JSON id ObjectId 57552e32e4b0839ede67e0af serial 574000690 startDat
  • Java 套接字:可以从一个线程发送并在另一个线程上接收吗?

    这可能是一个非常基本的问题 但我很难找到答案 让一个线程写入 Socket 的输出流 而另一个线程从 Socket 的输入流读取数据 这样可以吗 编辑 这是一个与外部服务器通信的客户端应用程序 我并不是想让两个线程互相交谈 很抱歉含糊不清
  • 我们必须将 .class 文件放在 Tomcat 目录中的位置

    我必须把我的 class文件在 Tomcat 目录中 在我的 Java Complete Reference 书中 他们告诉将其放入C Program Files Apache Tomcat 4 0 webapps examples WEB
  • Java中无参数的for循环

    我在看别人的代码 发现了这段代码 for 我不是 Java 专家 这行代码在做什么 起初 我认为这会创建一个无限循环 但在该程序员使用的同一个类中 while true 其中 如果我错了 请纠正我 是一个无限循环 这两个相同吗 为什么有人会
  • 在 Java 中使用 Inflater 解压缩 gzip 数据

    我正在尝试使用以下方法解压缩 gzip 数据Inflater 根据文档 如果参数 nowrap 为 true 则 ZLIB 标头和校验和 字段将不会被使用 这提供了与 GZIP 和 PKZIP 使用的压缩格式 注意 使用 nowrap 选项
  • 使用 Java 通过 HTTP 下载未知长度的文件

    我想用java下载一个HTTP查询 但是我下载的文件在下载时有一个未确定的长度 我认为这将是相当标准的 所以我搜索并找到了它的代码片段 http snipplr com view 33805 http snipplr com view 33
  • 在Spring-Boot中,我们如何在同一个项目中连接两个数据库(Mysql数据库和MongoDB)?

    我正在尝试创建一个 Spring Boot 项目 其中我有一个要求 我想连接到不同的数据库 MySql 和 MongoDB 我是否需要做一些特殊的事情来连接到这两个数据库 或者 spring boot 会自动计算出自己连接到这两个数据库 我
  • java 1.8下无法启动eclipse

    java 1 8 升级后我无法启动 eclipse 附上错误截图 这是我的 eclipse 配置设置 我该如何解决 startup plugins org eclipse equinox launcher 1 3 0 v20120522 1
  • 将变量从 jenkins 传递到 testng.xml

    我想根据从詹金斯传递的变量运行测试用例 例如 选择您要运行的测试用例 测试用例一 测试用例二 在 pom xml maven 中
  • 如何告诉 IntelliJ 使用 Java 1.6 JDK 启动 gradle?

    一个简单的问题 即使经过几个小时的尝试和搜索 我也无法弄清楚 我安装了 Java 6 和 7 如何告诉 IntelliJ 使用 JDK 版本 1 6 启动 Gradle 构建 无论我做什么 IntelliJ 都会以以下方式开始我的 grad
  • Microsoft JDBC 中的 JTDS 属性相当于什么?

    我正在将 JTDS 连接更改为 Microsoft JDBC 并且我看到存在于http jtds sourceforge net faq html http jtds sourceforge net faq htmlMicrosoft JD
  • Java,如何管理线程读取socket(websocket)?

    我有一个 WebSocket 服务器 我的服务器创建一个新线程来处理新连接 该线程一直处于活动状态 直到 websocket 中断 我的问题 对于 1 000 000 个连接 我需要 1 000 000 个线程 我如何通过一个线程处理多个

随机推荐

  • nginx(六十七)http_ssl模块 client与nginx的ssl握手

    一 HTTPS握手机制 关注点 SSL TLS握手 的细节与nginx 配置指令 的关系 核心 讲解 客户端 下游 与作为 server 端的nginx之间的 握手 最佳实践 建议在 http块 中通过 include ssl conf 把
  • 01-pytest-安装及入门

    目录 1 安装 2 查看版本 3 创建第一个测试 4 pytest用例规则 1 安装 pip install U pytest 2 查看版本 pytest version 或 pip show pytest 3 创建第一个测试 1 新建te
  • 分享一个QTabWidget的好看样式

    void setTabWidgetStyleSheet QTabWidget obj obj gt setStyleSheet QTabWidget background color transparent QTabWidget pane
  • python rfind函数用法_纵经千万次增删改,初心永不变

    开篇 上一期介绍了字符串及其切片用法 相信你已经掌握 那么这一期 我们就来学习一下字符串的增删改查等一系列方法 正是因为有了这些方法 你才能像呼吸一样自然地操作字符串 需要指出的是 字符串是不可变类型 也就是说 只要一个字符串确定了 那么任
  • Navicat远程连接mysql数据库

    第一 首先能ping通mysql数据库所在的主机 第二 telnet mysql数据库的端口号 如果不行 要在防火墙 高级设置里面 配置入站规则 开放3306端口 第三 如果还不行 结合下面两个网址 http blog csdn net a
  • iOS进阶_Log分类打印日志自动转换中文

    description方法是NSObject类的一个实例方法 因此所有的Object C对象都有description方法 description方法返回的永远是字符串 对于一个Person类 如果没有重写description方法 NSL
  • DWR3常见错误解决方法

    1 提示 缺少对象 原因 程序中使用了dwr util setValue userInfo data 或getValues 之类的语句 而控件ID与这里的userInfo名字不匹配 则提示缺少对象 解决方法 检查每一个setValue中的控
  • 设置对象的键为一个变量

    在JS中将对象的键设为变量的方法是将对象的键用 包起来 否则会直接识别成键名 例如 var key mykey var num mynum let obj key num 上面代码创建后的对象是 key mynum 并不是我们所期望的 my
  • (CVPR2019医学影像)LesaNet配置

    目录 一 环境配置 1 下载CADLab中的LesaNet文件夹 2 roi pooling编译 3 预训练模型下载 二 数据集 三 配置参数 1 demo 2 训练 3 测试 作者原版github LesaNet 一 环境配置 1 下载C
  • 【STM32】系统时钟RCC详解(超详细,超全面)

    转载 https blog csdn net as480133937 article details 98845509 1什么是时钟 时钟是单片机运行的基础 时钟信号推动单片机内各个部分执行相应的指令 时钟系统就是CPU的脉搏 决定cpu速
  • 嵌入式毕业设计 基于红外热释电的房间人数计数系统 - 单片机 物联网嵌入式

    文章目录 0 前言 1 简介 2 主要器件 3 实现效果 4 设计原理 4 1 PIR传感器 4 2 mlx90614红外传感器 5 部分核心代码 6 最后 0 前言 这两年开始毕业设计和毕业答辩的要求和难度不断提升 传统的毕设题目缺少创新
  • 谈谈前后端分离

    1 首先我们先看看SPA SPA全称是single page application 单页面应用 它是一种网络应用程序 webAPP 模型 传统网站里面 不同页面的切换一般是直接从服务器加载一整个新页面 而SPA这个模型 则是通过动态的重写
  • AI根据视频画面自动配音 ,真假难辨 !(附数据集)

    本文经AI新媒体量子位 公众号ID qbitai 授权转载 转载请联系出处 本文长度为3216字 建议阅读7分钟 本文为你分享实现AI自动为视频配音的流程 先来做个 真假美猴王 的游戏 你将看到两段画面相同的视频 请判断哪段来自视频原声 哪
  • Golang goroutine MPG模式浅析

    协程是通过使用关键字 go 调用 或执行 一个函数或者方法来实现的 也可以是匿名函数 Go 语言在语言层面上支持了并发 goroutine是Go语言提供的一种用户态线程 有时我们也称之为协程 所谓的协程 某种程度上也可以叫做轻量线程 它不由
  • package有什么作用

    常见笔试题 下列说法中 正确的是 A Java 中包的主要作用是实现跨平台功能 B package 语句只能放在 import 语句后面 C 包 package 由一组类 class 和接口 interface 组成 D 可以用 inclu
  • 硬件面试题目

    1 请列举您知道的电阻 电容 电感品牌 最好包括国内 国外品牌 电阻 日本 muRata 村田 Panasonic 松下 ROHM 罗姆 susumu TDK 中国 YAGEO 国巨 FH 风华 电容 日本 Matsushita 松下 mu
  • Windows Git配置SSH

    进入桌面 或者文件管理中右键 gt 打开Git命令窗口 生成ssh keygen 命令 wolfs com 为你的Git账号 ssh keygen t rsa C wolfs com 必要信息有所打码 可自行更改 然后提示你输入密码进行验证
  • vue总引入VConsole

    第一种 使用import的方式 通过main js中引入 先创建一个全局的vconsole js import Vconsole from vconsole const vConsole new Vconsole export defaul
  • mybatis缓存级别以及如何开启二级缓存

    一级缓存 范围 一级缓存是基于 SqlSession 的本地缓存 与单个 SqlSession 相关联 生命周期 一级缓存的生命周期是短暂的 仅在同一个 SqlSession 内有效 当在同一个 SqlSession 中执行相同的查询时 第
  • fcn从头开始_如何使用Go从头开始构建区块链

    fcn从头开始 介绍 Introduction With Web 3 0 and blockchain becoming more mainstream every day do you know what blockchain is Do
Powered by Hwhale