aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-02-10 10:38:33 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-02-16 17:13:06 +0000
commitf2c4c39971f25adaecde377ad325856ea785b9ac (patch)
tree772b8ec46b08407cc073767f058e0c43b41b70f1 /src/wallet/wallet2.cpp
parentMerge pull request #3198 (diff)
downloadmonero-f2c4c39971f25adaecde377ad325856ea785b9ac.tar.xz
wallet2: speed up subaddress generation (by about a third)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 7dc8a1e47..a17f0ffc6 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -889,14 +889,13 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
cryptonote::subaddress_index index2;
for (index2.major = m_subaddress_labels.size(); index2.major < index.major + m_subaddress_lookahead_major; ++index2.major)
{
- for (index2.minor = 0; index2.minor < (index2.major == index.major ? index.minor : 0) + m_subaddress_lookahead_minor; ++index2.minor)
+ const uint32_t end = (index2.major == index.major ? index.minor : 0) + m_subaddress_lookahead_minor;
+ const std::vector<crypto::public_key> pkeys = cryptonote::get_subaddress_spend_public_keys(m_account.get_keys(), index2.major, 0, end);
+ for (index2.minor = 0; index2.minor < end; ++index2.minor)
{
- if (m_subaddresses_inv.count(index2) == 0)
- {
- crypto::public_key D = get_subaddress_spend_public_key(index2);
- m_subaddresses[D] = index2;
- m_subaddresses_inv[index2] = D;
- }
+ const crypto::public_key &D = pkeys[index2.minor];
+ m_subaddresses[D] = index2;
+ m_subaddresses_inv[index2] = D;
}
}
m_subaddress_labels.resize(index.major + 1, {"Untitled account"});
@@ -905,15 +904,15 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
else if (m_subaddress_labels[index.major].size() <= index.minor)
{
// add new subaddresses
- cryptonote::subaddress_index index2 = index;
- for (index2.minor = m_subaddress_labels[index.major].size(); index2.minor < index.minor + m_subaddress_lookahead_minor; ++index2.minor)
- {
- if (m_subaddresses_inv.count(index2) == 0)
- {
- crypto::public_key D = get_subaddress_spend_public_key(index2);
- m_subaddresses[D] = index2;
- m_subaddresses_inv[index2] = D;
- }
+ const uint32_t end = index.minor + m_subaddress_lookahead_minor;
+ const uint32_t begin = m_subaddress_labels[index.major].size();
+ cryptonote::subaddress_index index2 = {index.major, begin};
+ const std::vector<crypto::public_key> pkeys = cryptonote::get_subaddress_spend_public_keys(m_account.get_keys(), index2.major, index2.minor, end);
+ for (; index2.minor < end; ++index2.minor)
+ {
+ const crypto::public_key &D = pkeys[index2.minor - begin];
+ m_subaddresses[D] = index2;
+ m_subaddresses_inv[index2] = D;
}
m_subaddress_labels[index.major].resize(index.minor + 1);
}