<commit_before>#include <bts/blockchain/transaction_creation_state.hpp>
#include <bts/blockchain/balance_operations.hpp>

#include <algorithm>

namespace bts { namespace blockchain {
 
    transaction_creation_state::transaction_creation_state( chain_interface_ptr prev_state )
    :pending_state(prev_state),required_signatures(1),eval_state(&pending_state)
    {
       
    }

    void transaction_creation_state::withdraw( const asset& amount_to_withdraw )
    {
       share_type left_to_withdraw = amount_to_withdraw.amount;
       for( auto item : pending_state._balance_id_to_record )
       {
          if( item.second.asset_id() == amount_to_withdraw.asset_id )
          {
             auto owner = item.second.owner();
             if( owner && eval_state.signed_keys.find(*owner) != eval_state.signed_keys.end() )
             {
                auto withdraw_from_balance = std::min<share_type>( item.second.balance, left_to_withdraw );
                left_to_withdraw    -= withdraw_from_balance;

                trx.withdraw( item.first, withdraw_from_balance );

                eval_state.evaluate_operation( trx.operations.back() );

                required_signatures.front().owners.insert( *owner );
                required_signatures.front().required = required_signatures.front().owners.size();

                if( left_to_withdraw == 0 )
                   break;
             }
          }
       }
       FC_ASSERT( left_to_withdraw == 0 );
    }

    void transaction_creation_state::add_known_key( const address& key )
    {
      eval_state.signed_keys.insert(key); 
    }

    public_key_type transaction_creation_state::deposit( const asset&           amount, 
                                              const public_key_type&            to, 
                                              slate_id_type                     slate,
                                              const optional<private_key_type>& one_time_key,
                                              const string&                     memo,
                                              const optional<private_key_type>& from,
                                              bool                              stealth )
    {
       public_key_type receive_key = to;
       if( !one_time_key )
       {
          trx.deposit( to, amount, slate );
       }
       else
       {
          withdraw_with_signature by_account;
          receive_key = by_account.encrypt_memo_data( *one_time_key, 
                                                      to,
                                                      from ? *from 
                                                           : fc::ecc::private_key(), 
                                                      memo, 
                                                      one_time_key->get_public_key(), 
                                                      to_memo, 
                                                      stealth );

          deposit_operation op;
          op.amount = amount.amount;
          op.condition = withdraw_condition( by_account, amount.asset_id, slate );
          trx.operations.emplace_back(op);

       }
       eval_state.evaluate_operation( trx.operations.back() );
       return receive_key;
    }

    void transaction_creation_state::pay_fee( const asset& amount )
    {
        // TODO
    }

} }
<commit_msg>[GS] Fix build (MSVS)<commit_after>#include <bts/blockchain/transaction_creation_state.hpp>
#include <bts/blockchain/balance_operations.hpp>

#include <algorithm>

namespace bts { namespace blockchain {
 
    transaction_creation_state::transaction_creation_state( chain_interface_ptr prev_state )
    :pending_state(prev_state),required_signatures(1),eval_state(&pending_state)
    {
       
    }

    void transaction_creation_state::withdraw( const asset& amount_to_withdraw )
    {
       share_type left_to_withdraw = amount_to_withdraw.amount;
       for( auto item : pending_state._balance_id_to_record )
       {
          if( item.second.asset_id() == amount_to_withdraw.asset_id )
          {
             auto owner = item.second.owner();
             if( owner && eval_state.signed_keys.find(*owner) != eval_state.signed_keys.end() )
             {
                auto withdraw_from_balance = std::min<share_type>( item.second.balance, left_to_withdraw );
                left_to_withdraw    -= withdraw_from_balance;

                trx.withdraw( item.first, withdraw_from_balance );

                eval_state.evaluate_operation( trx.operations.back() );

                required_signatures.front().owners.insert( *owner );
                required_signatures.front().required = required_signatures.front().owners.size();

                if( left_to_withdraw == 0 )
                   break;
             }
          }
       }
       FC_ASSERT( left_to_withdraw == 0 );
    }

    void transaction_creation_state::add_known_key( const address& key )
    {
      eval_state.signed_keys.insert(key); 
    }

    public_key_type transaction_creation_state::deposit( const asset&           amount, 
                                              const public_key_type&            to, 
                                              slate_id_type                     slate,
                                              const optional<private_key_type>& one_time_key,
                                              const string&                     memo,
                                              const optional<private_key_type>& from,
                                              bool                              stealth )
    {
       public_key_type receive_key = to;
       if( !one_time_key )
       {
          trx.deposit( to, amount, slate );
       }
       else
       {
          withdraw_with_signature by_account;
          receive_key = by_account.encrypt_memo_data( *one_time_key, 
                                                      to,
                                                      from ? *from 
                                                           : fc::ecc::private_key(), 
                                                      memo, 
                                                      one_time_key->get_public_key(), 
                                                      to_memo, 
                                                      stealth );

          deposit_operation op;
          op.amount = amount.amount;
          op.condition = withdraw_condition( by_account, amount.asset_id, slate );
          trx.operations.emplace_back(op);

       }
       eval_state.evaluate_operation( trx.operations.back() );
       return receive_key;
    }

    void transaction_creation_state::sell(const public_key_type& order_key,
                                          const asset& amount_to_sell,
                                          asset_id_type asset_to_receive,
                                          double base_price,
                                          double relative_percent)
    {
        // TODO
    }

    void transaction_creation_state::pay_fee( const asset& amount )
    {
        // TODO
    }

} }

{'fraction_non_alphanumeric': 0.07426981919332407, 'fraction_numerical': 0.0008344923504867872, 'mean_word_length': 1.2641687657430731, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1211046', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1666, 'n_words': 275}