forked from liuchengxu/blockchain-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
9795999
commit 3178fbe
Showing
53 changed files
with
75 additions
and
46 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 |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
|
||
blockchain.db | ||
|
||
.DS_Store | ||
|
||
_book/ | ||
node_modules/ | ||
|
||
|
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,7 @@ | ||
BINARY := blockchain | ||
|
||
build: | ||
@echo "====> Go build" | ||
@go build -o $(BINARY) | ||
|
||
.PHONY: build |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,19 @@ | ||
### 账户模型与 UTXO | ||
|
||
比特币,及其很多的继任者,将用户的余额存储在一个基于 UTXO(unspent transaction output)的数据结构中,系统的整个状态由一个“未花费输出,unspent output” 的集合构成。那么 UTXO 到底是什么呢?简单来说,UTXO 就是人民币,就是 “coin”。有多少 UTXO,就有多少人民币。跟人民币的区别在于: | ||
|
||
- “面值”,人民币的面值有 1 元,5 元,20 元,100 元等等是固定的,但是理论上,UTXO 的“面值”可以使任意正数。 | ||
- 新的人民币由政府的印钞机产生,新的 UTXO 由交易产生。 | ||
|
||
每个 UTXO 都有一个所有者和一个值,一笔交易会花费一些 UTXO,并创造出一些新的 UTXO,使用 UTXO 模型的交易在验证上有限制: | ||
|
||
1. 引用的每个输入必须是有效的,而且还没有被花费 | ||
2. 对于每个输入,交易必须有一个跟输入所有者匹配的签名 | ||
3. 总输入必须大于或等于总输出 | ||
|
||
在 UTXO 系统中,一个用户的“余额”实际上并不直接存在,而是通过计算得来。一个用户有一个私钥,这个私钥生成一个有效的签名,这个签名能够解锁的所有币的总和就是“余额”。 | ||
|
||
以太坊摒弃了 UTXO 模型,采用了一种更简单的方式:账户模型。 | ||
|
||
|
||
https://github.com/ethereum/wiki/wiki/Design-Rationale/37be78fa7b726d36156c537b757c874b7aa5705 |
Binary file not shown.
This file was deleted.
Oops, something went wrong.