vector<TxInfo> createRandomTransaction_uniformLoadingCreating() { vector<optional<TxInfo>> txs; size_t iFrom, iTo; do { iFrom = static_cast<int>(rand_fraction() * mAccounts.size()); iTo = static_cast<int>(rand_fraction() * mAccounts.size()); } while (iFrom == iTo); txs.push_back(ensureAccountIsLoadedCreated(iFrom)); txs.push_back(ensureAccountIsLoadedCreated(iTo)); uint64_t amount = static_cast<uint64_t>( rand_fraction() * min(static_cast<uint64_t>(1000), (mAccounts[iFrom]->mBalance - getMinBalance()) / 3)); txs.push_back(make_optional<TxInfo>(createTransferTransaction(iFrom, iTo, amount))); vector<TxInfo> result; for(auto tx : txs) { if (tx) result.push_back(*tx); } return result; }
vector<TxInfo> createRandomTransaction_uniformLoadingCreating() { auto from = pickRandomAccount(mAccounts.at(0), 0); auto to = pickRandomAccount(from, 0); vector<optional<TxInfo>> txs; txs.push_back(ensureAccountIsLoadedCreated(from->mId)); txs.push_back(ensureAccountIsLoadedCreated(to->mId)); int64_t amount = static_cast<int64_t>( rand_fraction() * min(static_cast<int64_t>(1000), (from->mBalance - mMinBalance) / 3)); txs.push_back(make_optional<TxInfo>( createTransferNativeTransaction(from, to, amount))); vector<TxInfo> result; for (auto tx : txs) { if (tx) result.push_back(*tx); } return result; }