Пример #1
0
        private void saveUnlockTransactionsJobs(CryptoNote.ISerializer serializer)
        {
            auto index   = m_unlockTransactions.get <TransactionHashIndex>();
            auto wallets = m_walletsContainer.get <TransfersContainerIndex>();

            ulong jobsCount = index.size();

            serializer.functorMethod(jobsCount, "unlockTransactionsJobsCount");

            foreach (var j in index)
            {
                var containerIt = wallets.find(j.container);
                Debug.Assert(containerIt != wallets.end());

                var keyIt = m_walletsContainer.project <KeysIndex>(containerIt);
                Debug.Assert(keyIt != m_walletsContainer.get <KeysIndex>().end());

                UnlockTransactionJobDtoV2 dto = new UnlockTransactionJobDtoV2();
                dto.blockHeight          = j.blockHeight;
                dto.transactionHash      = j.transactionHash;
                dto.walletSpendPublicKey = keyIt.spendPublicKey;

                serializer.functorMethod(dto, "unlockTransactionsJob");
            }
        }
Пример #2
0
        private void loadUnlockTransactionsJobs(CryptoNote.ISerializer serializer)
        {
            auto index        = m_unlockTransactions.get <TransactionHashIndex>();
            auto walletsIndex = m_walletsContainer.get <KeysIndex>();

            ulong jobsCount = 0;

            serializer.functorMethod(jobsCount, "unlockTransactionsJobsCount");

            for (ulong i = 0; i < jobsCount; ++i)
            {
                UnlockTransactionJobDtoV2 dto = new UnlockTransactionJobDtoV2();
                serializer.functorMethod(dto, "unlockTransactionsJob");

                var walletIt = walletsIndex.find(dto.walletSpendPublicKey);
                if (walletIt != walletsIndex.end())
                {
                    UnlockTransactionJob job = new UnlockTransactionJob();
                    job.blockHeight     = dto.blockHeight;
                    job.transactionHash = dto.transactionHash;
                    job.container       = walletIt.container;

                    index.insert(std::move(job));
                }
            }
        }
Пример #3
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);
                }
            }
        }