v30.3-roots.1 · Commit 3: [PATCH 03/68] feat(policy): preserve Roots relay and network controls on Core 30.3
src/policy/coin_age_priority.h
Before: /dev/null · After: src/policy/coin_age_priority.h
File metadata
new file mode 100644 index 0000000000000000000000000000000000000000..cdf1ac93174e3d3e1a75b15dcdb70c572c2c6fca
Download original patch · Release notes
Diff rows 1–40 of 40. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/policy/coin_age_priority.h
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright (c) 2012-2017 The Bitcoin Core developers
|
|
2
|
+
// Distributed under the MIT software license, see the accompanying
|
|
3
|
+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
4
|
+
|
|
5
|
+
#ifndef BITCOIN_POLICY_COIN_AGE_PRIORITY_H
|
|
6
|
+
#define BITCOIN_POLICY_COIN_AGE_PRIORITY_H
|
|
7
|
+
|
|
8
|
+
#include <consensus/amount.h>
|
|
9
|
+
|
|
10
|
+
class CCoinsViewCache;
|
|
11
|
+
class CTransaction;
|
|
12
|
+
|
|
13
|
+
struct CoinAgeCache
|
|
14
|
+
{
|
|
15
|
+
double inputs_coin_age; //!< Sum coin-age of all confirmed inputs
|
|
16
|
+
CAmount in_chain_input_value; //!< Sum value of all confirmed inputs
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
static constexpr CoinAgeCache COIN_AGE_CACHE_ZERO{
|
|
20
|
+
.inputs_coin_age = 0.0,
|
|
21
|
+
.in_chain_input_value = 0,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Compute modified tx vsize for priority calculation
|
|
25
|
+
unsigned int CalculateModifiedSize(const CTransaction& tx, unsigned int nTxSize);
|
|
26
|
+
|
|
27
|
+
// Compute priority, given sum coin-age of inputs and modified tx vsize
|
|
28
|
+
// CAUTION: Original ComputePriority accepted UNMODIFIED tx vsize and did the modification internally
|
|
29
|
+
double ComputePriority2(double inputs_coin_age, unsigned int mod_vsize);
|
|
30
|
+
double ReversePriority2(double coin_age_priority, unsigned int mod_vsize);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Return sum coin-age of tx inputs at height nHeight. Also calculate the sum of the values of the inputs
|
|
34
|
+
* that are already in the chain. These are the inputs that will age and increase priority as
|
|
35
|
+
* new blocks are added to the chain.
|
|
36
|
+
* CAUTION: Original GetPriority also called ComputePriority and returned the final coin-age priority
|
|
37
|
+
*/
|
|
38
|
+
CoinAgeCache GetCoinAge(const CTransaction &tx, const CCoinsViewCache& view, int nHeight);
|
|
39
|
+
|
|
40
|
+
#endif // BITCOIN_POLICY_COIN_AGE_PRIORITY_H
|