<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>cr4fun (cr4fun)</title>
    <link>https://ruby-china.org/cr4fun</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>从零开始写一个区块链</title>
      <description>&lt;p&gt;一、原理
上一个区块的 hash 和下一个区块的“上一个区块 hash”能对上，就意味着，数据没有被篡改。
&lt;img src="https://l.ruby-china.com/photo/2018/574e785b-b634-4c08-99f6-1f6573da50f9.svg!large" title="" alt=""&gt;
如果 hash 对不上，就意味着数据被篡改了。
&lt;img src="https://l.ruby-china.com/photo/2018/6fa4bd99-e8d1-4b03-a122-860f3d546fef.svg!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;二、演示&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;创建一个数据库&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/cebb3f49-4bde-4f48-b569-985e10194e9d.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;2.创建一个创世区块&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/fa1a9f4c-49c3-4513-ad3a-fcf927976eb7.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;添加区块&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/4099a2d5-a69a-464e-8058-3a3a5548c841.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;获得最后区块&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/d4106f14-1676-4954-8fed-267cd7836485.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;获得全部区块&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/4d1f7101-c2ef-4b36-bc2a-90e5d6960551.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;验证&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/d52b5f78-a182-4b9a-a93f-eafecae6b379.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;手动篡改数据，发现验证不通过&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/2c56435d-cc14-4c2b-b0de-0b94360fdcd3.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;改回数据，通过验证&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2018/f5edae79-0b79-48b6-bcf3-880b81d0783b.gif" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;三、项目地址：&lt;/p&gt;

&lt;p&gt;github &lt;a href="https://github.com/rubybook/blockchain" rel="nofollow" target="_blank"&gt;https://github.com/rubybook/blockchain&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;四、后续说明&lt;/p&gt;

&lt;p&gt;这个项目是为了做区块链教学的，目前还没有实现节点同步、共识、加密转账等。后续会逐步添加。&lt;/p&gt;</description>
      <author>cr4fun</author>
      <pubDate>Fri, 09 Nov 2018 14:13:25 +0800</pubDate>
      <link>https://ruby-china.org/topics/37746</link>
      <guid>https://ruby-china.org/topics/37746</guid>
    </item>
  </channel>
</rss>
