diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 589464e3a..88be29414 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1258,7 +1258,8 @@ namespace bts { namespace wallet { { try { auto sorted_delegates = my->_blockchain->get_active_delegates(); - uint32_t interval_number = bts::blockchain::now().sec_since_epoch() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; + auto current_time = bts::blockchain::now(); + uint32_t interval_number = current_time.sec_since_epoch() / BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; auto next_block_time = fc::time_point_sec( interval_number * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC ); if( next_block_time == my->_blockchain->now() ) next_block_time += BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; auto last_block_time = next_block_time + (BTS_BLOCKCHAIN_NUM_DELEGATES * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC); @@ -1276,7 +1277,12 @@ namespace bts { namespace wallet { { auto key = my->_wallet_db.lookup_key( delegate_record->active_key() ); if( key.valid() && key->has_private_key() ) - return next_block_time; + { + if( next_block_time >= current_time ) + return next_block_time; + else + last_block_time += BTS_BLOCKCHAIN_NUM_DELEGATES * BTS_BLOCKCHAIN_BLOCK_INTERVAL_SEC; + } } } return fc::time_point_sec(); diff --git a/libraries/wallet/wallet_db.cpp b/libraries/wallet/wallet_db.cpp index c36bea6ed..e13e10fa4 100644 --- a/libraries/wallet/wallet_db.cpp +++ b/libraries/wallet/wallet_db.cpp @@ -385,15 +385,16 @@ namespace bts{ namespace wallet { void wallet_db::clear_pending_transactions() { vector clear_list; - for (auto id_trx_pair : transactions) + for( const auto& id_trx_pair : transactions ) { - if (id_trx_pair.second.block_num == 0) + if( id_trx_pair.second.block_num == 0 ) { clear_list.push_back( id_trx_pair.first ); my->_records.remove( id_trx_pair.second.wallet_record_index ); } } - for( auto id : clear_list ) transactions.erase(id); + for( const auto& id : clear_list ) + transactions.erase( id ); } void wallet_db::export_to_json( const path& filename )const