MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / WasmTxGenerator

Function WasmTxGenerator

src/rpc/rpcblockchain.cpp:708–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706
707
708void static WasmTxGenerator(TpsTester *tpsTester, wasm::inline_transaction &inlineTx) {
709 RenameThread("coin-gentxwasm");
710 SetThreadPriority(THREAD_PRIORITY_NORMAL);
711
712 CCoinSecret vchSecret;
713 vchSecret.SetString("Y6J4aK6Wcs4A3Ex4HXdfjJ6ZsHpNZfjaS4B9w7xqEnmFEYMqQd13");
714 CKey key = vchSecret.GetKey();
715
716 // remove key from wallet first.
717 {
718 LOCK2(cs_main, pWalletMain->cs_wallet);
719 if (!pWalletMain->RemoveKey(key))
720 throw boost::thread_interrupted();
721 }
722 shared_ptr<CCacheWrapper> spCw;
723 uint64_t minFees = 0;
724 {
725 LOCK(cs_main);
726 spCw = make_shared<CCacheWrapper>(pCdMan);
727 GetTxMinFee(*spCw, BCOIN_TRANSFER_TX, chainActive.Height(), SYMB::WICC, minFees);
728 }
729 CRegID txUid("0-1");
730 auto payer = wasm::regid(txUid.GetIntValue());
731
732 inlineTx.authorization = std::vector<permission>{{payer.value, wasmio_owner}};
733
734 int32_t lastHeight = 0;
735 uint64_t fees = minFees;
736 while (true) {
737 // add interruption point
738 boost::this_thread::interruption_point();
739
740 int64_t nStart = GetTimeMillis();
741 int32_t validHeight = chainActive.Height();
742 if (lastHeight != validHeight) {
743 fees = minFees;
744 lastHeight = validHeight;
745 }
746
747 for (int64_t i = 0; i < tpsTester->batchSize; ++i) {
748 shared_ptr<CUniversalTx> tx = std::make_shared<CUniversalTx>();
749 tx->txUid = txUid;
750 tx->fee_symbol = SYMB::WICC;
751 tx->llFees = fees;
752 tx->valid_height = validHeight;
753
754 tx->inline_transactions.push_back(inlineTx);
755 // sign transaction
756 key.Sign(tx->GetHash(), tx->signature);
757
758 tpsTester->generationQueue->Push(tx);
759 fees++;
760 }
761
762 int64_t elapseTime = GetTimeMillis() - nStart;
763 LogPrint(BCLog::DEBUG, "batch generate transaction(s): %ld, elapse time: %ld ms.\n", tpsTester->batchSize, elapseTime);
764
765 if (elapseTime < tpsTester->period) {

Callers

nothing calls this directly

Calls 15

RenameThreadFunction · 0.85
SetThreadPriorityFunction · 0.85
GetTxMinFeeFunction · 0.85
regidClass · 0.85
MilliSleepFunction · 0.85
SetStringMethod · 0.80
RemoveKeyMethod · 0.80
HeightMethod · 0.80
GetIntValueMethod · 0.80
push_backMethod · 0.80
PushMethod · 0.80
GetTimeMillisFunction · 0.50

Tested by

no test coverage detected