github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/cmd/dummy_neb/dummies/random_dummy.h (about)

     1  // Copyright (C) 2018 go-nebulas authors
     2  //
     3  // This file is part of the go-nebulas library.
     4  //
     5  // the go-nebulas library is free software: you can redistribute it and/or
     6  // modify
     7  // it under the terms of the GNU General Public License as published by
     8  // the Free Software Foundation, either version 3 of the License, or
     9  // (at your option) any later version.
    10  //
    11  // the go-nebulas library is distributed in the hope that it will be useful,
    12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  // GNU General Public License for more details.
    15  //
    16  // You should have received a copy of the GNU General Public License
    17  // along with the go-nebulas library.  If not, see
    18  // <http://www.gnu.org/licenses/>.
    19  //
    20  #pragma once
    21  #include "cmd/dummy_neb/dummies/dummy_base.h"
    22  #include "cmd/dummy_neb/generator/generators.h"
    23  
    24  class random_dummy : public dummy_base {
    25  public:
    26    random_dummy(const std::string &name, int initial_account_num,
    27                 nas initial_nas, double account_increase_ratio,
    28                 const std::string &rpc_listen, uint16_t rpc_port);
    29  
    30    address_t enable_auth_gen_with_ratio(double auth_ratio,
    31                                         block_height_t block_interval);
    32    void enable_nr_ir_with_ratio(double nr_ratio, block_height_t block_interval);
    33    void enable_dip_ir_with_ratio(double dip_ratio,
    34                                  block_height_t block_interval);
    35  
    36    void enable_call_tx_with_ratio(double contract_ratio, double call_ratio);
    37  
    38    virtual ~random_dummy();
    39    virtual std::shared_ptr<generate_block> generate_LIB_block();
    40  
    41    virtual std::shared_ptr<checker_task_base> generate_checker_task();
    42  
    43    virtual address_t get_auth_admin_addr();
    44  
    45  protected:
    46    void handle_cli_pkgs();
    47  
    48  protected:
    49    all_accounts m_all_accounts;
    50    std::unique_ptr<transaction_generator> m_tx_gen;
    51    std::unique_ptr<genesis_generator> m_genesis_gen;
    52    std::unique_ptr<auth_table_generator> m_auth_gen;
    53    std::unique_ptr<nr_ir_generator> m_nr_gen;
    54    std::unique_ptr<dip_ir_generator> m_dip_gen;
    55    std::unique_ptr<call_tx_generator> m_call_gen;
    56    std::unique_ptr<contract_generator> m_contract_gen;
    57    std::unique_ptr<cli_generator> m_cli_generator;
    58    int m_initial_account_num;
    59    nas m_initial_nas;
    60    double m_account_increase_ratio;
    61    double m_auth_ratio;
    62    double m_nr_ratio;
    63    double m_dip_ratio;
    64    double m_contract_ratio;
    65    double m_call_ratio;
    66  
    67    block_height_t m_auth_interval;
    68    block_height_t m_nr_interval;
    69    block_height_t m_dip_interval;
    70  
    71    std::string m_rpc_listen;
    72    uint16_t m_rpc_port;
    73  
    74    neb::version m_nr_version;
    75    neb::version m_dip_version;
    76  
    77    address_t m_auth_admin_addr;
    78    address_t m_nr_admin_addr;
    79    address_t m_dip_admin_addr;
    80  
    81    std::unique_ptr<std::thread> m_thread;
    82    neb::util::wakeable_queue<std::shared_ptr<ff::net::package>> m_pkgs;
    83    ff::net::tcp_connection_base_ptr m_conn;
    84  
    85    std::shared_ptr<nbre_version_checker> m_version_checker;
    86    ff::net::net_nervure *m_p_nn;
    87  };