| 111 | } |
| 112 | |
| 113 | WalletState::WalletState(Wallet &wallet, logging::ILogger &log, const Config &config, const Currency ¤cy, DB &db) |
| 114 | : WalletStateBasic(log, config, currency, db, wallet.get_cache_name()) |
| 115 | , m_log_redo_block(std::chrono::steady_clock::now()) |
| 116 | , m_wallet(wallet) { |
| 117 | if (m_wallet.is_amethyst()) { |
| 118 | for (DB::Cursor cur = m_db.rbegin(ADDRESSES_PREFIX); !cur.end();) |
| 119 | cur.erase(); |
| 120 | BinaryArray ts, ac; |
| 121 | // TODO - convert to invariant after DB upgrade |
| 122 | if (m_db.get("$oldest_timestamp", ts) && m_db.get("$address_count", ac)) { |
| 123 | Timestamp oldest_timestamp = 0; |
| 124 | size_t cache_address_count = 0; |
| 125 | seria::from_binary(oldest_timestamp, ts); |
| 126 | seria::from_binary(cache_address_count, ac); |
| 127 | if (m_wallet.get_oldest_timestamp() < oldest_timestamp) |
| 128 | clear_db(true); |
| 129 | if (m_wallet.get_actual_records_count() < cache_address_count) |
| 130 | m_wallet.create_look_ahead_records(cache_address_count); |
| 131 | } |
| 132 | } |
| 133 | wallet_addresses_updated(); |
| 134 | auto pq = m_wallet.payment_queue_get(); |
| 135 | for (const auto &body : pq) { |
| 136 | Transaction tx; |
| 137 | try { |
| 138 | add_to_payment_queue(body, false); |
| 139 | } catch (const std::exception &) { |
| 140 | m_log(logging::WARNING) << "Error adding transaction to payment queue "; |
| 141 | continue; |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | void WalletState::db_commit() { |
| 147 | if (m_wallet.is_amethyst()) { |
nothing calls this directly
no test coverage detected