`

比特股ID

阅读更多
template<uint8_t SpaceID, uint8_t TypeID, typename T = object>
   struct object_id
   {
      typedef T type;
      static const uint8_t space_id = SpaceID;
      static const uint8_t type_id = TypeID;

      object_id(){}
      object_id( unsigned_int i ):instance(i){}
      explicit object_id( uint64_t i ):instance(i)
      {
         FC_ASSERT( (i >> 48) == 0 );
      }
      object_id( object_id_type id ):instance(id.instance())
      {
      }

      friend object_id operator+(const object_id a, int64_t delta ) { return object_id( uint64_t(a.instance.value+delta) ); }
      friend object_id operator+(const object_id a, int delta ) { return object_id( uint64_t(a.instance.value+delta) ); }

      operator object_id_type()const { return object_id_type( SpaceID, TypeID, instance.value ); }
      explicit operator uint64_t()const { return object_id_type( *this ).number; }

      template<typename DB>
      const T& operator()(const DB& db)const { return db.get(*this); }

      friend bool  operator == ( const object_id& a, const object_id& b ) { return a.instance == b.instance; }
      friend bool  operator != ( const object_id& a, const object_id& b ) { return a.instance != b.instance; }
      friend bool  operator == ( const object_id_type& a, const object_id& b ) { return a == object_id_type(b); }
      friend bool  operator != ( const object_id_type& a, const object_id& b ) { return a != object_id_type(b); }
      friend bool  operator == ( const object_id& b, const object_id_type& a ) { return a == object_id_type(b); }
      friend bool  operator != ( const object_id& b, const object_id_type& a ) { return a != object_id_type(b); }

      friend bool  operator < ( const object_id& a, const object_id& b ) { return a.instance.value < b.instance.value; }
      friend bool  operator > ( const object_id& a, const object_id& b ) { return a.instance.value > b.instance.value; }

      friend size_t hash_value( object_id v ) { return std::hash<uint64_t>()(v.instance.value); }

      unsigned_int instance;
   };


object_id由space_id,type_id及unsigned_int组成,则这个unsigned_int实际上是一个结构体,它用于存储T

struct unsigned_int {
    unsigned_int( uint32_t v = 0 ):value(v){}

    template<typename T>
    unsigned_int( T v ):value(v){}

    //operator uint32_t()const { return value; }
    //operator uint64_t()const { return value; }

    template<typename T>
    operator T()const { return static_cast<T>(value); }

    unsigned_int& operator=( int32_t v ) { value = v; return *this; }
    
    uint32_t value;

    friend bool operator==( const unsigned_int& i, const uint32_t& v )     { return i.value == v; }
    friend bool operator==( const uint32_t& i, const unsigned_int& v )     { return i       == v.value; }
    friend bool operator==( const unsigned_int& i, const unsigned_int& v ) { return i.value == v.value; }

    friend bool operator!=( const unsigned_int& i, const uint32_t& v )     { return i.value != v; }
    friend bool operator!=( const uint32_t& i, const unsigned_int& v )     { return i       != v.value; }
    friend bool operator!=( const unsigned_int& i, const unsigned_int& v ) { return i.value != v.value; }

    friend bool operator<( const unsigned_int& i, const uint32_t& v )      { return i.value < v; }
    friend bool operator<( const uint32_t& i, const unsigned_int& v )      { return i       < v.value; }
    friend bool operator<( const unsigned_int& i, const unsigned_int& v )  { return i.value < v.value; }

    friend bool operator>=( const unsigned_int& i, const uint32_t& v )     { return i.value >= v; }
    friend bool operator>=( const uint32_t& i, const unsigned_int& v )     { return i       >= v.value; }
    friend bool operator>=( const unsigned_int& i, const unsigned_int& v ) { return i.value >= v.value; }
};



object_id_type中的num由space_id(char),type_id(char),space_type(6bit)组成

space id:
relative_protocol_ids = 0,
protocol_ids          = 1,
implementation_ids    = 2

type id:
1.正常情况下的type id
enum object_type
   {
      null_object_type, 0
      base_object_type,1
      account_object_type,2
      asset_object_type,3
      force_settlement_object_type,4
      committee_member_object_type,5
      witness_object_type,6
      limit_order_object_type,7
      call_order_object_type,8
      custom_object_type,9
      proposal_object_type,10
      operation_history_object_type,11
      withdraw_permission_object_type,12
      vesting_balance_object_type,13
      worker_object_type,14
      balance_object_type,15
      OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
   };

2.如果space_id为2(implementation_ids),则type_id
enum impl_object_type
   {
      impl_global_property_object_type, 0
      impl_dynamic_global_property_object_type, 1
      impl_reserved0_object_type, 2     // formerly index_meta_object_type, TODO: delete me
      impl_asset_dynamic_data_type, 3
      impl_asset_bitasset_data_type, 4
      impl_account_balance_object_type, 5
      impl_account_statistics_object_type, 6
      impl_transaction_object_type, 7
      impl_block_summary_object_type, 8
      impl_account_transaction_history_object_type, 9
      impl_blinded_balance_object_type, 10
      impl_chain_property_object_type, 11
      impl_witness_schedule_object_type, 12
      impl_budget_record_object_type, 13
      impl_special_authority_object_type, 14
      impl_buyback_object_type, 15
      impl_fba_accumulator_object_type, 16
      impl_collateral_bid_object_type 17
   };

3.数据对象基本都是由space_id,type_id来构建索引
分享到:
评论

相关推荐

    比特精灵

    比特精灵 种子子下载

    山东比特魔笛多媒体面板图册

    该资料详细介绍了山东比特多媒体魔笛风原理

    比特搜索bt

    比特搜索bt

    比特金白皮书

    比特金白皮书 阐述了比特金诞生的初衷

    比特教务管理系统

    比特教务管理系统V2.3是现代教务管理不可缺少的得力工具,实用、方便。

    matlab开发-比特误差率

    matlab开发-比特误差率。该程序绘制了BPSK调制的误码率曲线。

    比特彗星下载器

    比特彗星下载器,BT下载器,可以下载种子文件。

    比特无限源码

    比特无限源码。开源源码,欢迎下载。

    多比特树详解

    超详细,从unibit tree开始讲解,逐步上升到多比特树,可以知道其发展过程。

    比特杀毒软件破解注册机-

    比特杀毒软件破解注册机-比特杀毒软件破解注册机-

    比特彗星全功能解锁绿色版

    比特彗星全功能解锁绿色版,“比特彗星全功能解锁绿色版”BitComet_x64

    比特彗星28774压缩包

    使用时浏览器点击下载的文件右边三个点,复制链接,这时,比特彗星会自动弹出选项框,选择下载地址,点击确定;如果没有弹出,就到比特彗星里,点击左上角html的图标,再粘贴网址,选择下载地址,点击确定。

    bt(比特下载)

    比特精灵(bitspirit)是一款界面美观,使用简单,功能强大的BT客户端。 C++全新内核,它不仅提供BitTorrent协议的完全实现,而且提供强大的个性化功能

    论文研究-基于硬判决反馈的BICM-ID解映射算法及其改进.pdf

    基于硬判决反馈的比特交织编码调制迭代译码(BICM-ID)系统解映射算法计算简单,复杂度低,易于工程实现,但在信噪比较低时,由于预先判决的错误较多,反馈时容易产生误码传播。针对这一问题,提出了一种改进的基于...

    若比特Robotell开源资料

    这是网上找的若比特Robotell的USB2CAN的开源资料,里面包括驱动程序、调试软件、以及源码+原理图

    比特精灵(bitcomet.zip)

    比特彗星软件LOGO比特彗星(BitComet,简写为"BC")是一个用C++语言为Microsoft Windows平台编写的BitTorrent客户端软件,也可用于HTTP/FTP下载,并可选装eMule插件(eMule plug-in)通过ed2k网络进行BT/eMule同时...

    比特彗星BitComet_1.46

    比特彗星是一个用C++语言为Microsoft Windows平台编写的BitTorrent客户端软件,也可用于HTTP/FTP下载,并可选装“eMule插件”通过电驴网络进行BitTorrent/电驴同时下载。

    零比特插入

    零比特插入,在遇到和帧定界符一样的比特组合时所采取的有效方法

    比特Java研发工程师JavaSE.zip

    比特Java研发工程师JavaSE.zip

    比特流操作

    比特流操作的相关函数,包括从源地址复制n个比特数据到目的地址函数,取数据中某起始位置n个比特模板函数等等。

Global site tag (gtag.js) - Google Analytics