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

Function GetPriorityTx

src/miner/miner.cpp:91–110  ·  view source on GitHub ↗

Sort transactions by priority and fee to decide priority orders to process transactions.

Source from the content-addressed store, hash-verified

89
90// Sort transactions by priority and fee to decide priority orders to process transactions.
91void GetPriorityTx(CCacheWrapper &cw, int32_t height, set<TxPriority> &txPriorities, const int32_t nFuelRate) {
92 static TokenSymbol feeSymbol;
93 static uint64_t fee = 0;
94 static uint32_t txSize = 0;
95 static double feePerKb = 0;
96 static double priority = 0;
97
98 for (map<uint256, CTxMemPoolEntry>::iterator mi = mempool.memPoolTxs.begin(); mi != mempool.memPoolTxs.end(); ++mi) {
99 CBaseTx *pBaseTx = mi->second.GetTransaction().get();
100 if (!pBaseTx->IsBlockRewardTx() && !pCdMan->pTxCache->HasTx(pBaseTx->GetHash())) {
101 feeSymbol = std::get<0>(mi->second.GetFees());
102 fee = std::get<1>(mi->second.GetFees());
103 txSize = mi->second.GetTxSize();
104 feePerKb = double(fee - pBaseTx->GetFuelFee(cw, height, nFuelRate)) / txSize * 1000.0;
105 priority = mi->second.GetPriority();
106
107 txPriorities.emplace(TxPriority(priority, feePerKb, mi->second.GetTransaction()));
108 }
109 }
110}
111
112
113bool GetCurrentDelegate(const int64_t currentTime, const int32_t currHeight, const VoteDelegateVector &delegates,

Calls 12

TxPriorityClass · 0.85
GetTransactionMethod · 0.80
IsBlockRewardTxMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
HasTxMethod · 0.45
GetHashMethod · 0.45
GetFeesMethod · 0.45
GetTxSizeMethod · 0.45
GetFuelFeeMethod · 0.45
GetPriorityMethod · 0.45

Tested by

no test coverage detected