![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
区块链学习
昧昧我思之
这个作者很懒,什么都没留下…
展开
-
go-ethereum/core/vm/stack.go
这个包是对虚拟机堆的定义,只用了fmt和math/big。stack是堆栈操作的对象,出栈的Item被用作修改。type Stack struct { data []*big.Int}这里可以看到,栈结构是big.Int的数组。Stack由于开头是大写,所以可以被包外访问。func newstack() *Stack { return &Stack{data: make([]原创 2018-01-21 15:05:42 · 295 阅读 · 0 评论 -
go实现一个区块链
TrasactionTx类TxIn&TxOutScriptAddressTrasactionTx类type Tx struct { Hash utils.Hash //如果改成指针型会更好一些 Version uint32 Ins []*TxIn Outs []*TxOut}其实比特币...原创 2018-03-09 10:38:16 · 1217 阅读 · 0 评论 -
bitcoin代码分析
UML图UML图比特币有一个重要的概念就是每个Tx的所有TxIn都必须用完。用不完的不代表成为其他Tx的In,而是必须成为一个TxOut。 比如A要转100给B,A现有有2个可以支配的Out,Out1是60,Out2是50,但是50+60=110>100,那么多余的10该怎么办呢?比特币中规定这多余的10也要创建一个Out来锁住这10块,从而In和Out总额相等。...原创 2018-03-08 23:17:18 · 1282 阅读 · 0 评论 -
ethereum-go win7 64位编译
1.安装go语言 输入go version 输出go version go1.9.2表示成功2. github:https://github.com/ethereum/go-ethereum dowmload zip到本地目录结构GOPATH/src├── github.com│ └── ethereum│ └── go-ethereum└──原创 2018-01-20 10:32:07 · 2356 阅读 · 0 评论 -
go-ethereum/blob/master/core/vm/instructions.go
这里定义了许多操作,以几个例子来说明。func opAdd(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { x, y := stack.pop(), stack.pop() stack.push(math.U256(x.Add(x, y))) evm.in原创 2018-01-21 15:57:51 · 253 阅读 · 0 评论 -
go-ethereum/core/vm/stack_table.go
func makeStackFunc(pop, push int) stackValidationFunc { return func(stack *Stack) error { if err := stack.require(pop); err != nil { return err } if stack.len()+push-pop > int(params.StackL原创 2018-01-21 15:23:27 · 236 阅读 · 0 评论 -
一个最小可行的区块链
通过三重记账确保交易安全用加密来确保交易安全Balance = Σ(receipts)多方转账和验证双花和分布式共识机制分布式共识网络通过三重记账确保交易安全Alice和Bob是邮件收藏者。一天,Alice非常想要Bob的一枚邮票又苦于没有足够的资金,于是她决定打白条。白条上有Alice和Bob的签名,同时又有一个中间人Chunk的签名,每个人都有一份白条...翻译 2018-03-02 23:20:05 · 485 阅读 · 0 评论