mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +02:00
Use int32_t type for most transaction size/weight values
This change gets rid of a few casts and makes the following commit diff smaller.
This commit is contained in:
@@ -75,7 +75,7 @@ private:
|
||||
mutable Parents m_parents;
|
||||
mutable Children m_children;
|
||||
const CAmount nFee; //!< Cached to avoid expensive parent-transaction lookups
|
||||
const size_t nTxWeight; //!< ... and avoid recomputing tx weight (also used for GetTxSize())
|
||||
const int32_t nTxWeight; //!< ... and avoid recomputing tx weight (also used for GetTxSize())
|
||||
const size_t nUsageSize; //!< ... and total memory usage
|
||||
const int64_t nTime; //!< Local time when entering the mempool
|
||||
const unsigned int entryHeight; //!< Chain height when entering the mempool
|
||||
@@ -88,12 +88,14 @@ private:
|
||||
// mempool; if we remove this transaction we must remove all of these
|
||||
// descendants as well.
|
||||
uint64_t nCountWithDescendants{1}; //!< number of descendant transactions
|
||||
uint64_t nSizeWithDescendants; //!< ... and size
|
||||
// Using int64_t instead of int32_t to avoid signed integer overflow issues.
|
||||
int64_t nSizeWithDescendants; //!< ... and size
|
||||
CAmount nModFeesWithDescendants; //!< ... and total fees (all including us)
|
||||
|
||||
// Analogous statistics for ancestor transactions
|
||||
uint64_t nCountWithAncestors{1};
|
||||
uint64_t nSizeWithAncestors;
|
||||
// Using int64_t instead of int32_t to avoid signed integer overflow issues.
|
||||
int64_t nSizeWithAncestors;
|
||||
CAmount nModFeesWithAncestors;
|
||||
int64_t nSigOpCostWithAncestors;
|
||||
|
||||
@@ -104,7 +106,7 @@ public:
|
||||
int64_t sigops_cost, LockPoints lp)
|
||||
: tx{tx},
|
||||
nFee{fee},
|
||||
nTxWeight(GetTransactionWeight(*tx)),
|
||||
nTxWeight{GetTransactionWeight(*tx)},
|
||||
nUsageSize{RecursiveDynamicUsage(tx)},
|
||||
nTime{time},
|
||||
entryHeight{entry_height},
|
||||
@@ -121,11 +123,11 @@ public:
|
||||
const CTransaction& GetTx() const { return *this->tx; }
|
||||
CTransactionRef GetSharedTx() const { return this->tx; }
|
||||
const CAmount& GetFee() const { return nFee; }
|
||||
size_t GetTxSize() const
|
||||
int32_t GetTxSize() const
|
||||
{
|
||||
return GetVirtualTransactionSize(nTxWeight, sigOpCost, ::nBytesPerSigOp);
|
||||
}
|
||||
size_t GetTxWeight() const { return nTxWeight; }
|
||||
int32_t GetTxWeight() const { return nTxWeight; }
|
||||
std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
|
||||
unsigned int GetHeight() const { return entryHeight; }
|
||||
int64_t GetSigOpCost() const { return sigOpCost; }
|
||||
@@ -134,9 +136,9 @@ public:
|
||||
const LockPoints& GetLockPoints() const { return lockPoints; }
|
||||
|
||||
// Adjusts the descendant state.
|
||||
void UpdateDescendantState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount);
|
||||
void UpdateDescendantState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount);
|
||||
// Adjusts the ancestor state
|
||||
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
|
||||
void UpdateAncestorState(int32_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
|
||||
// Updates the modified fees with descendants/ancestors.
|
||||
void UpdateModifiedFee(CAmount fee_diff)
|
||||
{
|
||||
@@ -152,13 +154,13 @@ public:
|
||||
}
|
||||
|
||||
uint64_t GetCountWithDescendants() const { return nCountWithDescendants; }
|
||||
uint64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
|
||||
int64_t GetSizeWithDescendants() const { return nSizeWithDescendants; }
|
||||
CAmount GetModFeesWithDescendants() const { return nModFeesWithDescendants; }
|
||||
|
||||
bool GetSpendsCoinbase() const { return spendsCoinbase; }
|
||||
|
||||
uint64_t GetCountWithAncestors() const { return nCountWithAncestors; }
|
||||
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
||||
int64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
|
||||
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
|
||||
int64_t GetSigOpCostWithAncestors() const { return nSigOpCostWithAncestors; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user