github.com/igggame/nebulas-go@v2.1.0+incompatible/nbre/fs/blockchain/account/account_db.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  
    21  #pragma once
    22  
    23  #include "common/address.h"
    24  #include "common/common.h"
    25  #include "common/math.h"
    26  #include "fs/blockchain/transaction/transaction_db.h"
    27  
    28  namespace neb {
    29  namespace fs {
    30  
    31  class account_db {
    32  public:
    33    account_db(blockchain_api_base *blockchain_ptr);
    34  
    35    wei_t get_balance(const address_t &addr, block_height_t height);
    36    address_t get_contract_deployer(const address_t &address_t,
    37                                    block_height_t height);
    38  
    39    void set_height_address_val_internal(
    40        const std::vector<transaction_info_t> &txs,
    41        std::unordered_map<address_t, wei_t> &addr_balance);
    42  
    43    wei_t get_account_balance_internal(const address_t &addr,
    44                                       block_height_t height);
    45  
    46    static floatxx_t get_normalized_value(floatxx_t value);
    47  
    48  private:
    49    std::unordered_map<address_t, std::vector<block_height_t>> m_addr_height_list;
    50    std::unordered_map<block_height_t, std::unordered_map<address_t, wei_t>>
    51        m_height_addr_val;
    52    blockchain_api_base *m_blockchain;
    53  };
    54  } // namespace fs
    55  } // namespace neb