-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
920 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
abbrlink: 1 | ||
--- | ||
# 基于EOS/Node.js的DApp项目实战---去中心化交易所 | ||
|
||
## 一、介绍 | ||
### 1.1 去中心化交易所简介 | ||
众所周知,在传统中心化交易所的选择上,用户往往最担心的就是资金安全问题,原本想通过投资赚钱却惨遭意外损失,所以会优先选用那些信用度较高且知名机构背书的交易所。 | ||
|
||
但在区块链行业发展初期, 很多兴起的TOKEN中心化交易所都是由一些初创型或者稍有名气但不足以完全信任的公司所运营, 所以提高了用户心理上的资金风险指数。而且通过过往发生的各种交易所事件,也佐证了交易所资金私自挪用、暗箱操作、黑客攻击等事件发生的可能性;除此之外,还要面临公司内部运营风险、交易不透明等问题。 | ||
|
||
与此同时, 随着区块链的进一步发展,出现了不同解决方案的去中化交易所, 用来解决中心化所带来的各种风险问题。其核心优势在于规避集中式资产管理, 用户对自己的资产拥有绝对的所有权与控制权,因此资产被盗的可能性极低,很大程度上降低了用户对交易所的信任成本。但由于资产的交易操作是由区块链来驱动的,所以也会受到区块确认速度的限制,近而影响用户体验。 | ||
目前的商业典型案例有: EtherDela、0x、Kyber、Loopring、bitshares等。 | ||
|
||
### 1.2 项目介绍 | ||
本项目是使用EOS、SmartContract、Node.js、React等技术架构, 采用链上搓合与资产清算的方案实现的去中心化交易所。 | ||
|
||
在交易所中, 用户可以直接使用自己的钱包进行帐号登录;然后使用自己的用户权限直接创建买/卖订单,而无需进行币种充值;当系统发现订单薄中存在符合搓合价格要求的订单后,则由系统直接进行搓合,并将搓合日志记录至区块链上;最后,由系统将搓合成功的部分或完全成交的TOKEN转帐到对方帐号地址。 | ||
|
||
另外,当系统调度发现链上存在成交日志时,会自动将成交记录同步至后端服务数据库,并同步更新K线图报表数据以及实时更新币价信息;最后,根据变动的信息数据, 通过socket服务将消息推送到前端展示页。 | ||
|
||
本系统核心业务逻辑主要是通过智能合约进行实现的, 其中包括搓合逻辑的处理、关键数据的定义、买卖单的创建以及订单薄的维护;而后端服务主要是以node.js技术进行功能实现,一方面用于与区块链的接口交互,比如:查询合约内数据以及链上区块数据;另一方面主要用于对外提供http及socket接口服务,通过整合业务数据及合约数据,以供前端页面的数据展示;除此之外,后端还有配套的调度服务,实时同步链上数据,并生成不同维度的报表数据。 | ||
|
||
### 1.3 项目详情 | ||
|
||
本项目从功能结构上,主要划分为六大模块: | ||
- 基础数据管理; | ||
- 订单管理 | ||
- 搓合管理 | ||
- 系统管理 | ||
- 报表管理 | ||
- 调度管理 | ||
|
||
**基础数据管理**,主要用于维护币种及交易对数据。 币种管理主要用于定义当前交易所所支持的币种, 比如币种名称, 合约名称及资金精度等;交易对管理主要用于定义基准代币可兑换的币种、交易对最小订单量以及手续费等信息; | ||
|
||
**订单管理**, 主要用于维护用户订单数据以及交易所订单薄数据。用户订单功能主要用于记录用户实时创建的买/卖单交易数据, 其中包括交易对、购买价格、订单量、订单状态等数据信息;而订单薄功能主要用于对交易所所有的订单按卖买类型进行分队列排序,从而方便展示当前交易对的交易深度以及供搓合功能处理; | ||
|
||
**搓合管理**, 主要用于实时将订单薄中符中搓合条件的订单进行数据处理,并同时更新用户订单数据以及资金清算等业务; | ||
|
||
**系统管理**, 主要用于维护交易所配置数据以及运营状态。比如,是否锁定或开启交易所; | ||
|
||
**调度管理**, 主要用于实时监控链上搓合成交记录,并实时同步订单数据至数据库,供前端K线图的数据展示; | ||
|
||
**报表管理**, 主要用于通过交易市场的交易情况实时展示K线图报表数据以及实时更新所有交易对币价信息, 比如:24小时成交量, 当前币种价格、涨跌幅等信息。 | ||
|
||
### 1. 4 技术需求 | ||
要成功完成本项目开发, 您应该对以下语言有基本的了解: | ||
- C/C++编程基础 | ||
EOS智能合约本身是用C++语言进行编写的,所以需要对一些基础的数据类型、结构体、函数库有一些简单的了解; | ||
- Docker容器 | ||
为了提供最佳的实践环境,考虑EOS链的搭建时间成本较高,所以使用Docker技术快速构建链环境,方便大家在开发过程对链环境的快速启动或还原; | ||
- Node.js | ||
Node主要用于链接前端页面与智能合约间的交互,其中包括: 调用合约方法、同步数据、提供服务接口等工作。 | ||
- Jest | ||
为了保证功能在持续完善过程中,可能出现的各种不确定的代码影响。所以使用测试用例可以提高验证效率,降低代码bug风险。 | ||
|
||
### 1.5 涉及技术点 | ||
|
||
![](http://assets.processon.com/chart_image/5c6cee61e4b07fada4ec47a0.png) | ||
|
||
## 二、项目架构 | ||
|
||
![](http://assets.processon.com/chart_image/5c6ccd91e4b07fada4ec1a3a.png) | ||
|
||
## 三、业务流程图 | ||
|
||
![](http://assets.processon.com/chart_image/5c6e043ee4b056ae2a109843.png) | ||
|
||
## 四、实现步骤 | ||
1. 配置运行环境及IDE工具: Git、Node、npm、vscode; | ||
2. 配置工程环境; | ||
3. 合约设计; 数据结构、接口定义; | ||
4. 编写测试用例,对合约方法进行测试; | ||
5. 封装智能合约SDK,供业务系统调用; | ||
6. 使用Node-Express开发业务系统,并整合调度、数据库、日志、缓存、日期、多配置等组件服务; | ||
7. 实现同步区块调度服务; | ||
8. 实现同步区块数据至报表服务; | ||
9. 实现对外HTTP服务接口; | ||
10. 实现对外SOCKET服务接口; | ||
11. 集成PM2守护启动线程; | ||
12. 与前端界面对接接口并整体测试 | ||
13. 项目发布与部署。发布合约至测试网或正式网, 启动前后端项目系统。 | ||
|
||
## 五、项目进度安排 | ||
|
||
![](http://assets.processon.com/chart_image/5c6baaf8e4b0fa03ceb804b2.png) | ||
|
||
## 五、项目成果展示 | ||
|
||
![](https://ws3.sinaimg.cn/large/006tKfTcly1g0cmwln6fzj315i0u00vk.jpg) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: 'HackDApp学习周报01W:习惯与仪式感' | ||
categories: 周报(2019) | ||
url: weekly01 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 44014 | ||
date: 2019-01-09 20:17:23 | ||
--- | ||
|
||
最近,纠正了自己一个关于精力方面的概念理解。就是 自律 VS 习惯。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 'HackDApp学习周报02W:关于工具与产品' | ||
categories: 周报(2019) | ||
url: weekly02 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 'HackDApp学习周报03W:关于工具与产品' | ||
categories: 周报(2019) | ||
url: weekly03 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 'HackDApp学习周报02W:关于工具与产品' | ||
categories: 周报(2019) | ||
url: weekly04 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 'HackDApp学习周报02W:关于工具与产品' | ||
categories: 周报(2019) | ||
url: weekly05 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 'HackDApp学习周报02W:关于工具与产品' | ||
categories: 周报(2019) | ||
url: weekly06 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: 'HackDApp学习周报02W:关于工具与产品' | ||
categories: 周报(2019) | ||
url: weekly07 | ||
tags: | ||
- EOSDApp教程 | ||
keywords: | ||
- EOS开发环境 | ||
- EOS开发工具 | ||
- EOS实战开发 | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: 坚持的长性 | ||
categories: 重塑思维 | ||
url: think_habit | ||
tags: | ||
- 习惯养成 | ||
- 仪式感 | ||
- 内心的满足 | ||
- 2019要做的事 | ||
keywords: | ||
- 习惯养成 | ||
- 仪式感 | ||
- 内心的满足 | ||
- 2019要做的事 | ||
abbrlink: 22134 | ||
date: 2019-01-21 09:31:24 | ||
toc: true | ||
--- | ||
|
||
![](https://ws1.sinaimg.cn/large/006tNc79gy1fzdyksu0ykj30qy0dw400.jpg) | ||
|
||
今天早上算是被媳妇嘲笑了一番,为啥呢? | ||
|
||
因为之前自己有一段时间,为了背英语单词,所以早起了一个月,而如今早一天晚一天,早起完全看心情。 | ||
|
||
媳妇给出的评价就是:用劲过猛,要么及早要么极迟,完全是一种过激行为。 | ||
|
||
同时她也给出建议:只要比上班的时间多出一小时其实就可以做很多事情。重要的是常态化。 | ||
|
||
---- | ||
|
||
2019开始了,自己确没开始。以前都早早给自己作出各种规划,对比现在,还不如之前的自己吗?不应该是每年比前一年好一些吗或者每天比昨天好一些吗? | ||
|
||
哦,也可能是最近超忙,导致各种规划的推迟。但内心同时又会想起另外一种声音:不,你不是,你只是懒。事情没把你逼到一种绝境上,你是不会立即行动的。 | ||
|
||
## 2019要做的事 | ||
|
||
1. 早起,不早起怎么做重要的事;而且希望能找到一些习惯思维方式; | ||
2. 持续写作,写一本自己的技术书籍,打造自己的硬核; | ||
3. 持续总结,不犯过去犯的错,少走弯路; | ||
4. 思考习惯养成路径,以便培养自己新习惯的有效成功率 | ||
|
||
注:事情不在多,夯实好这几点。 | ||
|
||
## 目前的状态 | ||
|
||
- 时不时早起起来做一些事情,可能是工作上的,也可能是生活上的,但缺少对书的阅读;另外,感觉早上精力特别出奇的好,是否应该做一些最重要的事情,而读书的化放在晚上的时候。 | ||
- 未达到持续写东西的地步,需要检讨;可能存在的原因: 对于第二天早上要写的东西,前一天没有大致规划;或者说并不需要规划,每天早上写的时候就按之前的套路写就可以了,不讲究一次写完写完美,而是持续写出自己的每个内容点,草稿结束后再修改,也是告诉自己好文章是持续修改出来的,不可能写完就扔那儿了,而是要持续完善。包括今天写的这篇,其实也是由之前早上写的卡片扩展而来的。 | ||
- 总结之前过于重视形式化。总结对于我来讲,总感觉认可但又未给予足够的重视,因为总是断断续续的写一些自检清单。可能这个和习惯的养成也是一样,归根到底是没有成长的即视感,也就是没有反馈。比如:刮胡子,为什么要举这个例子呢?因为之前用电动剃须刀时,总是时不时刮一次;而用手动刮胡刀后,发现自己几乎每天都会坚持这件事。当时再想为什么这件事能坚持的如此之前呢?那其他事情怎么不能坚持下去呢?我是否能够从刮胡子这件事情中找到自己内心的那一份认识与感受呢。后来才发现,那是因为刮胡子这件事能让我内心出现一份好形象不邋遢的意识。洗漱的时候就是在潜意识里调动这份动力,而且在刮完胡子后更加让自己内心得以满足,这不正是一种仪式感吗? | ||
- 正在有意识,感受自己每天坚持做一件事情的内心是如何的? | ||
|
||
所以,如果要让某个行为成为你的习惯,你就要从内心上提高对它的认可,以及最重要的一件事,你要寻找你的内心感受,是什么让你满足。如果这个不好理解的话,我给你的建议就是观察你已有的习惯中想想那是一种什么感觉,做个比较可能会更形象一些。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: 'HackDApp学习周报02W:如何成为演讲的高手' | ||
categories: 周报(2019) | ||
url: weekly08 | ||
tags: | ||
- 学习周报 | ||
keywords: | ||
abbrlink: 58600 | ||
date: 2019-01-21 00:38:26 | ||
--- | ||
|
||
# 知识学习 | ||
|
||
- [TED深度学习四步法](http://joinwee.com/lesson/20/#4) | ||
何为组块 | ||
- [如保成为演讲的高手](得到) | ||
|
||
---- | ||
|
||
# 思维成长 | ||
|
||
---- | ||
|
||
# 软件工具 | ||
|
||
---- | ||
|
||
# 书籍阅读 | ||
|
||
- 变量 | ||
罗振宇推荐, 从现象中看到本质; | ||
- 创新算法 | ||
阳志平博客推荐 | ||
|
||
---- | ||
|
||
# 好玩的事 | ||
|
||
- | ||
|
||
---- | ||
|
||
# vlog | ||
|
||
1. 如何制作自己的vlog | ||
风格确定; 编写脚本; 根据脚本选择镜头录制; 视频剪辑。 | ||
2. 如何制作转场、添加字幕 | ||
youtube里资源还是蛮多的,购买相关插件 | ||
3. 如何找免费音乐 | ||
B站资源推荐 | ||
|
||
---- | ||
|
||
# 其他 | ||
|
||
[https://www.datascienceweekly.org/newsletters/data-science-weekly-newsletter-issue-272](https://www.datascienceweekly.org/newsletters/data-science-weekly-newsletter-issue-272) | ||
|
||
![xx](https://ws1.sinaimg.cn/large/006tKfTcly1g0e568svouj30t64cs7k4.jpg) |
Oops, something went wrong.