区块链技术eos开发

cocosbcx1808 eos实现源码结构分析

2019-04-10  本文已影响5人  剑有偏锋

一 源码
https://github.com/Cocos-BCX/EOS-1808

二 数据结构

        //管理员表
        TABLE admins
        {
            name admin;
            uint64_t primary_key() const { return admin.value; }
        };

       //nft可用状态表
        TABLE nftindexs
        {
            id_type id;
            id_type status;
            uint64_t primary_key() const { return id; }
            uint64_t get_status() const { return status; }
        };

        //账户拥有nft数量表
        TABLE nftnumber
        {
            name owner;
            id_type number;
            uint64_t primary_key() const { return owner.value; }
        };

        //nft表
        TABLE nftts
        {
            id_type id;
            name creator;
            name owner;
            name auth;
            std::string explain;
            time_point_sec createtime;
            //std::map<string, string> attr;
            //id_type composeattr;
            std::string worldview;            
            uint64_t primary_key() const { return id; }
            uint64_t get_owner() const { return owner.value; }
            uint64_t get_creator() const { return creator.value; }
            
        };

        //组件表,表示nft属于组件
        TABLE composeattr
        {
            id_type nftid;
            uint64_t primary_key() const { return nftid; }
        };
        
       //认证账户表
        TABLE accauth 
        {
            name owner;
            name auth;
            uint64_t primary_key() const { return owner.value; }
            uint64_t get_auth() const { return auth.value; }
        };

       //区块链表
        TABLE nftchains{
            id_type chainid;
            string chain;
            id_type status;
            uint64_t primary_key() const { return chainid; }
            uint64_t get_status() const { return status; }
        };
      
        //组件组合关系表
        TABLE composes
        {
            id_type id;
            id_type firid;
            id_type secid;
            id_type status;
            uint64_t primary_key() const { return id; }
            uint64_t get_fir() const { return firid; }
            uint64_t get_sec() const { return secid; }
            uint64_t get_status() const { return status; }
        };
       
        //游戏世界表
        TABLE nftgame
        {
            id_type gameid;
            std::string gamename;
            std::string introduces;
            id_type status;
            id_type index;
            time_point_sec createtime;
            std::map<string, string> gameattr;
            uint64_t primary_key() const { return gameid; }
            uint64_t get_status() const { return status; }
            uint64_t get_index() const { return index; }
        };


         //资产隐射关系表,A游戏的nft映射到B游戏
        TABLE assetmapes 
        {
            id_type mappingid;
            id_type fromid;
            id_type targetid;
            id_type chainid;
            uint64_t primary_key() const { return mappingid; }
            uint64_t get_fromid() const { return fromid; }
            uint64_t get_targetid() const { return targetid; }
            uint64_t get_chainid() const { return chainid; }
        };

三 action

        //添加删除管理员
        ACTION addadmin(name admin);
        ACTION deladmin(name admin);

        //创建代币类型
        ACTION create(name creator, name owner, std::string explain, std::string worldview);
        //创建其他???
        ACTION createother(name creator, name owner, std::string explain, std::string worldview, id_type chainid, id_type targetid);

        //添加账户验证
        ACTION addaccauth(name owner, name auth);
        ACTION delaccauth(name owner);
        
        ACTION addnftauth(name owner, name auth, id_type id);
        ACTION delnftauth(name owner, id_type id);
        
        //转账
        ACTION transfer(name from, name to, id_type id, string memo);
        
        //链相关
        ACTION addchain(name owner, string chain);
        ACTION setchain(name owner, id_type chainid, id_type status);
        
        //添加要设置组件的nft的id
        ACTION addcompattr(name owner, id_type id);
        ACTION delcompattr(name owner, id_type id);
        
        //设置两个id组合在一起,设置nft的组合关系  firid为first id缩写  secid为second id缩写
        ACTION setcompose(name owner, id_type firid, id_type secid);
        ACTION delcompose(name owner, id_type firid, id_type secid);
        
        //添加游戏及属性状态
        ACTION addgame(name owner, std::string gamename, std::string introduces);
        ACTION editgame(name owner, id_type gameid, std::string gamename, std::string introduces);
        ACTION setgame(name owner, id_type gameid, id_type status);
        ACTION delgame(name owner, id_type gameid);
        
        //游戏属性
        ACTION addgameattr(name owner, id_type gameid, string key, string value);
        ACTION editgameattr(name owner, id_type gameid, string key, string value);
        ACTION delgameattr(name owner, id_type gameid, string key);
        
        //映射关系,把A游戏的道具映射到B游戏
        ACTION addmapping(name owner, id_type fromid, id_type targetid, id_type chainid);
        ACTION delmapping(name owner, id_type fromid, id_type chainid);
        
        //销毁代币
        ACTION burn(name owner, id_type nftid);

四 参考

https://cn-dev.cocosbcx.io/docs/%E5%90%8C%E8%B4%A8%E8%B5%84%E4%BA%A7%E5%8F%91%E5%B8%83%E6%95%99%E7%A8%8B
《道具发布教程》

https://cn-dev.cocosbcx.io/docs/bcx-nhas-1808%E6%A0%87%E5%87%86 《BCX-NHAS-1808标准》

上一篇下一篇

猜你喜欢

热点阅读