MCPcopy Create free account
hub / github.com/bcndev/bytecoin / WalletState

Method WalletState

src/Core/WalletState.cpp:113–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113WalletState::WalletState(Wallet &wallet, logging::ILogger &log, const Config &config, const Currency &currency, 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
146void WalletState::db_commit() {
147 if (m_wallet.is_amethyst()) {

Callers

nothing calls this directly

Calls 11

from_binaryFunction · 0.85
get_cache_nameMethod · 0.80
is_amethystMethod · 0.45
rbeginMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
getMethod · 0.45
get_oldest_timestampMethod · 0.45
payment_queue_getMethod · 0.45

Tested by

no test coverage detected