二维码

3.4 比特币的区块 - 数据结构 - 机器学习

1298 人阅读 | 时间:2021年01月15日 01:10
3.4 比特币的区块 - 数据结构 - 机器学习 #daohang ul li t,.reed .riqi,a.shangg,a.xiatt,a.shangg:hover,a.xiatt:hover,a.shang,a.xiat,a.shang:hover,a.xiat:hover,.reed-pinglun-anniu,span.now-page,#daohangs-around,#caidan-tubiao,#daohangs,#daohangs li,#btnPost{background-color:#D10B04;} .dinglanyou1 h3{border-bottom:3px solid #D10B04;} #dibuer{border-top:2px solid #D10B04;}.cebianlan .rongqi h3{border-bottom:1px solid #D10B04;} #edtSearch{border:1px solid #D10B04;} #daohang .zuo ul li{border-right:1px solid #;} #daohang ul li t a{border-top:1px solid #;border-right:1px solid #D10B04;} #daohang ul li t a:hover{border-right:1px solid #;} #daohang .you ul li a:hover,#daohang .zuo ul li a:hover,.reed-pinglun-anniu:hover{background-color:#;} a:hover,.reed h6 a:hover,#dibuer a:hover,.reed .riqiding,.cebianlan .rongqi li a:hover,#pinglun-liebiao ul.fubens li.depth-1 dl dd span.shu a,#pinglun-liebiao ul.fubens li.depth-1 dl dd span.huifuliuyan a:hover,.reed-biaoti h6 span{color:#D10B04;} .reed .kan a{color:#0A0AF5;}.reed .kan a:hover{color:#D10101;} @media screen and (max-width:1492px){a.shang,a.xiat{background:none;} a.xiat:hover,a.shang:hover{background-color:#f9f9f9;background-image:none;text-decoration:none;}} var _hmt = _hmt || [];(function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?b19db5ba3b437a9e8698d2bc8fc64334"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);})(); var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?b19db5ba3b437a9e8698d2bc8fc64334"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?2d748c9763cfc72fb7d1ccab29f0770d"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f6d451f3f1be23f3abf240c64c469c1b"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();

当前位置:首页 » 区块链精品文章 » 正文

(function() { var s = "_" + Math.random().toString(36).slice(2); document.write('
'); (window.slotbydup = window.slotbydup || []).push({ id: "u3646201", container: s }); })();
(function() { var s = "_" + Math.random().toString(36).slice(2); document.write('
'); (window.slotbydup = window.slotbydup || []).push({ id: "u3646162", container: s }); })();

3.4 比特币的区块

1281 人参与  2018年09月12日 14:45  分类 : 区块链精品文章  评论

现在,我们已经了解了单个交易是如何创建的,但是在第2章里提到,所有交易都是被打包放入区块的,为什么要这么 做呢?其实这是为了性能优化,如果每一个交易都要矿工单独去达成共识,那整个系统的交易处理速度将会变得非常慢。而如果我们把大量交易组织起来放入一个区 块,得到的哈希链就更短,大大提高了验证区块链数据结构的效率。

区块链(块链)非常聪明地把两个基于哈希值的数据结构结合起来:第一个数据结构是区块的哈希链,每一个区块 都有一个区块头部,里面有一个哈希指针指向上一个区块。第二个数据结构是一个树状数据结构,也就是以树状结构把区块内所有交易的哈希值进行排列存储。也叫 梅克尔树(请参考第1章),它以一种非常高效的形式把所有交易组织起来。为了证明某个交易在某个区块内,可以通过树内路径来进行搜索,而树的长度就是区块 内所包含的交易数目的对数(见图3.7)。

我们在第2章中提到过(在第5章还将继续涉及),区块头部还包含了挖矿谜题[1]相 关的信息。还记得,区块头部的哈希函数必须以一大堆零开头才有效,此外,区块头部还要包含一个矿工可以修改的“临时随机数”、一个时间戳和一个点数(点数 用来表示找到这个区块的难度)。区块头部是挖矿过程中唯一哈希值化的,所以要验证一个区块的链,只要检查区块头部即可。在区块头部唯一的交易数据是交易树 的树根——“mrkl_root”。

3.4 比特币的区块 - 数据结构 - 机器学习

图3.7 比特币的区块链有两个哈希结构

注:一个就是把区块联结在一起的哈希链,另一个就是区块内部的交易哈希值梅克尔树。

每个区块的梅克尔树上都有一个有意思的交易,叫作币基交易(见图3.8)。这就类似于财奴币里的造币交易。这个交易创造新的比特币,它看上去像是一个普通的交易,但有几点不同:

3.4 比特币的区块 - 数据结构 - 机器学习

图3.8 币基交易

注:币基交易创造新的比特币,这个交易并不消费之前交易输出的比特币,因此,没有指针指向“上一交易”。币基交易的参数可以是任意数据。币基交易的价值等于区块奖励加上区块中包含的所有交易费。

1.它永远只有一个单一的输入与单一的输出。

2.这个交易并不消费之前交易输出的比特币,因此,没有指针指向“上一交易”。

3.这个输出值目前大约是25个币多一点点。这个输出值就是矿工的挖矿收入。它由两部分组成:一部分是奖励的25个比特币(奖励在每生产210 000个区块——大概4年——后减半),另一部分是所有交易的交易手续费。

4.还有一个特别的地方就是“币基”参数,矿工可以放任何值进去。

这里值得一提的是,当比特币的第一个区块被铸造出来的时候,该区块的币基参数提及了伦敦《泰晤士时报》的一 则报道:2009年1月3日,财政大臣拯救银行。这被看成比特币发明的政治动机,同时也很好地证明了第一个区块的打包时间是在2009年1月3日,上述报 道出来之后。这也是矿工使用“币基”参数来支持很多比特币的不同特性。

想更好了解比特币的区块和交易结构,最好的办法是自己浏览区块链的数据,有很多网站提供数据,比如blockchain.info,在该网站上可以看到所有交易,以及每笔交易所引用的上一笔交易。由于比特币的数据都是公开的,一些程序员已经开发出了全图形化的展现方式。

[1] 也就是竞争记账权利问题。——译者注

来源:我是码农,转载请保留出处和链接!

本文链接:http://www.54manong.com/?id=413

(function() { var s = "_" + Math.random().toString(36).slice(2); document.write('
'); (window.slotbydup = window.slotbydup || []).push({ id: "u3646208", container: s }); })();
(function() { var s = "_" + Math.random().toString(36).slice(2); document.write('
'); (window.slotbydup = window.slotbydup || []).push({ id: "u3646147", container: s }); })();
window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdPic":"","bdStyle":"0","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
区块链是什么  

微信号:qq444848023    QQ号:444848023

加入【我是码农】QQ群:864689844(加群验证:我是码农)

<< 上一篇 下一篇 >>
(function() { var s = "_" + Math.random().toString(36).slice(2); document.write('
'); (window.slotbydup = window.slotbydup || []).push({ id: "u3646186", container: s }); })();
(function() { var s = "_" + Math.random().toString(36).slice(2); document.write('
'); (window.slotbydup = window.slotbydup || []).push({ id: "u3646175", container: s }); })();
搜索

网站分类

标签列表

最近发表

    (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https'){ bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else{ bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();

全站首页 | 数据结构 | 区块链| 大数据 | 机器学习 | 物联网和云计算 | 面试笔试

var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1276413723'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s23.cnzz.com/z_stat.php%3Fid%3D1276413723%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));本站资源大部分来自互联网,版权归原作者所有!

jQuery(document).ready(function($){ /* prepend menu icon */ $('#daohangs-around').prepend('
'); /* toggle nav */ $("#caidan-tubiao").on("click", function(){ $("#daohangs").slideToggle(); $(this).toggleClass("active"); }); });

©著作权归作者所有:来自ZhiKuGroup博客作者没文化的原创作品,如需转载,请注明出处,否则将追究法律责任 来源:ZhiKuGroup博客,欢迎分享。

评论专区
  • 昵 称必填
  • 邮 箱选填
  • 网 址选填
  • 验证码
◎已有 0 人评论
搜索
作者介绍
本站会员尊享VIP特权,现在就加入我们吧!登录注册×
»
会员登录
新用户注册
×
会员注册
已有账号登录
×