Exemplo n.º 1
0
        private void loadKeyListAndBalances(CryptoNote.ISerializer serializer, bool saveCache)
        {
            ulong walletCount;

            serializer.functorMethod(walletCount, "walletCount");

            m_actualBalance  = 0;
            m_pendingBalance = 0;
            m_deletedKeys.Clear();

            HashSet <Crypto.PublicKey> cachedKeySet = new HashSet <Crypto.PublicKey>();
            auto index = m_walletsContainer.get <KeysIndex>();

            for (uint i = 0; i < walletCount; ++i)
            {
                Crypto.PublicKey spendPublicKey = new Crypto.PublicKey();
                ulong            actualBalance;
                ulong            pendingBalance;
                serializer.functorMethod(spendPublicKey, "spendPublicKey");

                if (saveCache)
                {
                    serializer.functorMethod(actualBalance, "actualBalance");
                    serializer.functorMethod(pendingBalance, "pendingBalance");
                }

                cachedKeySet.Add(spendPublicKey);

                var it = index.find(spendPublicKey);
                if (it == index.end())
                {
                    m_deletedKeys.emplace(std::move(spendPublicKey));
                }
                else if (saveCache)
                {
                    m_actualBalance  += actualBalance;
                    m_pendingBalance += pendingBalance;

//C++ TO C# CONVERTER TODO TASK: Only lambda expressions having all locals passed by reference can be converted to C#:
//ORIGINAL LINE: index.modify(it, [actualBalance, pendingBalance](WalletRecord& wallet)
                    index.modify(it, (WalletRecord wallet) =>
                    {
                        wallet.actualBalance  = actualBalance;
                        wallet.pendingBalance = pendingBalance;
                    });
                }
            }

            foreach (var wallet in index)
            {
                if (cachedKeySet.count(wallet.spendPublicKey) == 0)
                {
                    m_addedKeys.Add(wallet.spendPublicKey);
                }
            }
        }