一起來讀源碼22-eos history_plugin

摘要:

插件功能:

1.獲得action,獲得傳輸塊,獲得賬號的key;

2.過濾/添加/記錄/響應/追蹤/應用 action;

 

詳情:

account_control_history_object.hpp

history_plugin.hpp

public_key_history_object.hpp

history_plugin.cpp

 

歷史插件:

定義4張表:

account_control_history_multi_index:賬號歷史多索引表;

有序單鍵索引 分索引1 分索引2 分索引3
id       
正在控制的賬號  正在控制的賬號 id類型  
賬號控制權限 賬號控制權限 權限 正在控制的賬號

 

public_key_history_multi_index:歷史公鑰表;

有序單鍵索引 分索引1 分索引2 分索引3
公鑰鍵索引  公鑰 id  
賬號權限 name 權限 id

 

action_history_index:action歷史表;

有序單鍵索引 分索引1 分索引2 分索引3
id      
action序列號      
正在傳輸的塊id 傳輸的塊id 塊序列號  

 

account_history_index:賬號歷史表;

有序單鍵索引 分索引1 分索引2 分索引3
id      
賬號action請求 賬號名 賬號歷史  

 

定義了1個靜態對象,用作單例:

appbase::abstract_plugin

 

定義類:

read_only:只讀類(用來實現一些只讀操作)

    //獲得actions(只讀)

    get_actions_result   get_actions( const read_only::get_actions_params& params ) const

    //獲得傳輸塊

    get_transaction_result    get_transaction( get_transaction_param& p ) const

    //獲得賬號的key

    get_key_accounts_results    get_key_accounts(const get_key_accounts_params& params) const

    //獲得已經控制的賬號

    get_controlled_accounts_results    get_controlled_accounts(

        const get_controlled_accounts_params& params) const

history_plgin:歷史插件類

    //設置程序選項

    void    set_program_options(options_description& cli, options_description& cfg)

    //插件初始化

    plugin_initialize(const variables_map& options)

history_plugin_impl:歷史插件實現

    //過濾(分爲出口過濾和入口過濾)

    bool    filter(const action_trace& act)

    //添加賬號

    set<account_name>    account_set( const action_trace& act )

    //記錄賬號action

    void    record_account_action( account_name n, const action_trace& act )

    //響應系統action

    void    on_system_action( const action_trace& at )

    //action追蹤

    void    on_action_trace( const action_trace& at )

    //應用傳輸

    on_applied_transaction( const transaction_trace_ptr& trace )


提供了一些全局函數(namespace eosio):

//多索引表刪除

remove(chainbase::database& db, const account_name& account_name,

    const permission_name& permission) 

//多索引表添加

add(chainbase::database& db, const vector<key_weight>& keys,const account_name& name,

    const permission_name& permission)

//按權重添加

add(chainbase::database& db, const vector<key_weight>& keys, const account_name& name,

    const permission_name& permisssion)

//按權限等級添加

add(chainbase::database& db, const vector<permission_level_weight>& controlling_accounts,

    const account_name& account_name, const permission_name& permission)

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章