美文网首页eosEOS开发系列EOS技术
区块链技术EOS之块,cycle,thread,交易,消息等结构

区块链技术EOS之块,cycle,thread,交易,消息等结构

作者: 菠菜期权 | 来源:发表于2017-09-01 09:58 被阅读860次

    设计理念:https://github.com/EOSIO/eos/issues/5

    块结构位于eos/libraries/chain/include/eos/chain/block.hpp

    struct block_header

    {

    block_id_type                previous;

    fc::time_point_sec            timestamp;

    checksum_type                transaction_merkle_root;

    AccountName                  producer;

    RoundChanges                  producer_changes;

    };

    struct signed_block_header:public block_header

    {

    signature_type            producer_signature;

    };

    struct thread{

    vector<> generated_input;

    vector<>  user_input;

    };

    using cycle = vector<thread>;

    struct signed_block : public signed_block_header

    {

    vector<cycle> cycles;

    };

    参考:https://github.com/EOSIO/Documentation/blob/master/zh-CN/TechnicalWhitePaper.md

    重点:同一个循环内不存在两个线程包含同一帐户下对交易的变更,意味着同一个账户肯定在同一个thread处理。

    交易结构位于 eos/libraries/types/include/eos/types/generated.hpp

    struct Transaction{

    UInt16                          refBlockNum;

    UInt32                          refBlockPrefix;

    Time                            expiration;

    Vector<> scope;

    Vector<> readscope;

    Vector<>messages;

    };


    tx

    消息结构交易结构位于 eos/libraries/types/include/eos/types/generated.hpp

    struct Message{

    AccountName                      code;

    FuncName                        type;

    Vector<AccountPermission> authorization;

    Bytes                            data;

    };


    看了eos的设计,感觉与golang或rust的设计有异曲同工之处,语言在解决并发时也在向分布式channel的逻辑演进。

    通道(channel)可以传递消息的ownership,这样你就可以从一个线程发送一个指针到另一个线程,而不用担心线程在后续通过指针访问数据而发生竞争。Rust的通道(channel)能强制隔离线程。

    大家可以通过一下方式跟踪关注我:

    github:https://github.com/philsong

    微博:http://weibo.com/bocaicfa

    本文是EOS技术研究系列的第六篇。

    第一篇.Mac下的编译:http://www.jianshu.com/p/f26ee4cf1d4a

    第二篇.eosc命令行工具:http://www.jianshu.com/p/b2db966435d0

    第三篇.appbase库:http://www.jianshu.com/p/b7f0bbe89610

    第四篇.chainbase库与database_plugin插件:http://www.jianshu.com/p/df835b574b52

    第五篇.如何开发合约发行代币:http://www.jianshu.com/p/5228da9c5631

    第六篇.块,交易等结构:http://www.jianshu.com/p/d5ef6280b94d

    相关文章

      网友评论

      • SHIT_48b8:看起来很高级,请告诉我eos很牛逼😍

      本文标题:区块链技术EOS之块,cycle,thread,交易,消息等结构

      本文链接:https://www.haomeiwen.com/subject/ljyhjxtx.html