protect ancestor data from outside assignments
This commit is contained in:
parent
7873f1c26a
commit
ac8f88da38
@ -22,9 +22,9 @@ pub struct AuditTransaction {
|
|||||||
pub relatives_set_flag: bool,
|
pub relatives_set_flag: bool,
|
||||||
pub ancestors: HashSet<u32, U32HasherState>,
|
pub ancestors: HashSet<u32, U32HasherState>,
|
||||||
pub children: HashSet<u32, U32HasherState>,
|
pub children: HashSet<u32, U32HasherState>,
|
||||||
pub ancestor_fee: u64,
|
ancestor_fee: u64,
|
||||||
pub ancestor_weight: u32,
|
ancestor_weight: u32,
|
||||||
pub ancestor_sigops: u32,
|
ancestor_sigops: u32,
|
||||||
// Safety: Must be private to prevent NaN breaking Ord impl.
|
// Safety: Must be private to prevent NaN breaking Ord impl.
|
||||||
score: f64,
|
score: f64,
|
||||||
pub used: bool,
|
pub used: bool,
|
||||||
@ -97,6 +97,21 @@ impl AuditTransaction {
|
|||||||
self.score
|
self.score
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub const fn ancestor_fee(&self) -> u64 {
|
||||||
|
self.ancestor_fee
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub const fn ancestor_weight(&self) -> u32 {
|
||||||
|
self.ancestor_weight
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub const fn ancestor_sigops(&self) -> u32 {
|
||||||
|
self.ancestor_sigops
|
||||||
|
}
|
||||||
|
|
||||||
/// Safety: This function must NEVER set score to NaN.
|
/// Safety: This function must NEVER set score to NaN.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn calc_new_score(&mut self) {
|
fn calc_new_score(&mut self) {
|
||||||
|
@ -128,8 +128,8 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap) -> Option<GbtResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if blocks.len() < (MAX_BLOCKS - 1)
|
if blocks.len() < (MAX_BLOCKS - 1)
|
||||||
&& ((block_weight + next_tx.ancestor_weight >= BLOCK_WEIGHT_UNITS)
|
&& ((block_weight + next_tx.ancestor_weight() >= BLOCK_WEIGHT_UNITS)
|
||||||
|| (block_sigops + next_tx.ancestor_sigops > BLOCK_SIGOPS))
|
|| (block_sigops + next_tx.ancestor_sigops() > BLOCK_SIGOPS))
|
||||||
{
|
{
|
||||||
// hold this package in an overflow list while we check for smaller options
|
// hold this package in an overflow list while we check for smaller options
|
||||||
overflow.push(next_txid);
|
overflow.push(next_txid);
|
||||||
@ -148,7 +148,7 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap) -> Option<GbtResult> {
|
|||||||
|
|
||||||
let cluster_rate = next_tx
|
let cluster_rate = next_tx
|
||||||
.dependency_rate
|
.dependency_rate
|
||||||
.min(next_tx.ancestor_fee as f64 / (f64::from(next_tx.ancestor_weight) / 4.0));
|
.min(next_tx.ancestor_fee() as f64 / (f64::from(next_tx.ancestor_weight()) / 4.0));
|
||||||
|
|
||||||
for (txid, _) in &package {
|
for (txid, _) in &package {
|
||||||
cluster.push(*txid);
|
cluster.push(*txid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user