vsize -> sigop_adjusted_vsize
This commit is contained in:
parent
10beb76585
commit
79a10ee833
@ -14,7 +14,7 @@ pub struct AuditTransaction {
|
|||||||
pub uid: u32,
|
pub uid: u32,
|
||||||
pub fee: u64,
|
pub fee: u64,
|
||||||
pub weight: u32,
|
pub weight: u32,
|
||||||
pub vsize: u32,
|
pub sigop_adjusted_vsize: u32,
|
||||||
pub sigops: u32,
|
pub sigops: u32,
|
||||||
pub fee_per_vsize: f64,
|
pub fee_per_vsize: f64,
|
||||||
pub effective_fee_per_vsize: f64,
|
pub effective_fee_per_vsize: f64,
|
||||||
@ -25,7 +25,7 @@ pub struct AuditTransaction {
|
|||||||
pub children: HashSet<u32, U32HasherState>,
|
pub children: HashSet<u32, U32HasherState>,
|
||||||
ancestor_fee: u64,
|
ancestor_fee: u64,
|
||||||
ancestor_weight: u32,
|
ancestor_weight: u32,
|
||||||
ancestor_vsize: u32,
|
ancestor_sigop_adjusted_vsize: u32,
|
||||||
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,
|
||||||
@ -76,7 +76,7 @@ impl AuditTransaction {
|
|||||||
uid: tx.uid,
|
uid: tx.uid,
|
||||||
fee: tx.fee,
|
fee: tx.fee,
|
||||||
weight: tx.weight,
|
weight: tx.weight,
|
||||||
vsize: ((tx.weight + 3) / 4).max(tx.sigops * 5), // rounded up to the nearest integer
|
sigop_adjusted_vsize: ((tx.weight + 3) / 4).max(tx.sigops * 5), // rounded up to the nearest integer
|
||||||
sigops: tx.sigops,
|
sigops: tx.sigops,
|
||||||
fee_per_vsize: tx.fee_per_vsize,
|
fee_per_vsize: tx.fee_per_vsize,
|
||||||
effective_fee_per_vsize: tx.effective_fee_per_vsize,
|
effective_fee_per_vsize: tx.effective_fee_per_vsize,
|
||||||
@ -87,7 +87,7 @@ impl AuditTransaction {
|
|||||||
children: u32hashset_new(),
|
children: u32hashset_new(),
|
||||||
ancestor_fee: tx.fee,
|
ancestor_fee: tx.fee,
|
||||||
ancestor_weight: tx.weight,
|
ancestor_weight: tx.weight,
|
||||||
ancestor_vsize: ((tx.weight + 3) / 4).max(tx.sigops * 5), // rounded up to the nearest integer
|
ancestor_sigop_adjusted_vsize: ((tx.weight + 3) / 4).max(tx.sigops * 5), // rounded up to the nearest integer
|
||||||
ancestor_sigops: tx.sigops,
|
ancestor_sigops: tx.sigops,
|
||||||
score: 0.0,
|
score: 0.0,
|
||||||
used: false,
|
used: false,
|
||||||
@ -102,8 +102,8 @@ impl AuditTransaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn ancestor_vsize(&self) -> u32 {
|
pub const fn ancestor_sigop_adjusted_vsize(&self) -> u32 {
|
||||||
self.ancestor_vsize
|
self.ancestor_sigop_adjusted_vsize
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -132,10 +132,10 @@ impl AuditTransaction {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn calc_new_score(&mut self) {
|
fn calc_new_score(&mut self) {
|
||||||
self.score = (self.ancestor_fee as f64)
|
self.score = (self.ancestor_fee as f64)
|
||||||
/ (if self.ancestor_vsize == 0 {
|
/ (if self.ancestor_sigop_adjusted_vsize == 0 {
|
||||||
1.0
|
1.0
|
||||||
} else {
|
} else {
|
||||||
f64::from(self.ancestor_vsize)
|
f64::from(self.ancestor_sigop_adjusted_vsize)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,13 +145,13 @@ impl AuditTransaction {
|
|||||||
ancestors: HashSet<u32, U32HasherState>,
|
ancestors: HashSet<u32, U32HasherState>,
|
||||||
total_fee: u64,
|
total_fee: u64,
|
||||||
total_weight: u32,
|
total_weight: u32,
|
||||||
total_vsize: u32,
|
total_sigop_adjusted_vsize: u32,
|
||||||
total_sigops: u32,
|
total_sigops: u32,
|
||||||
) {
|
) {
|
||||||
self.ancestors = ancestors;
|
self.ancestors = ancestors;
|
||||||
self.ancestor_fee = self.fee + total_fee;
|
self.ancestor_fee = self.fee + total_fee;
|
||||||
self.ancestor_weight = self.weight + total_weight;
|
self.ancestor_weight = self.weight + total_weight;
|
||||||
self.ancestor_vsize = self.vsize + total_vsize;
|
self.ancestor_sigop_adjusted_vsize = self.sigop_adjusted_vsize + total_sigop_adjusted_vsize;
|
||||||
self.ancestor_sigops = self.sigops + total_sigops;
|
self.ancestor_sigops = self.sigops + total_sigops;
|
||||||
self.calc_new_score();
|
self.calc_new_score();
|
||||||
self.relatives_set_flag = true;
|
self.relatives_set_flag = true;
|
||||||
@ -163,7 +163,7 @@ impl AuditTransaction {
|
|||||||
root_txid: u32,
|
root_txid: u32,
|
||||||
root_fee: u64,
|
root_fee: u64,
|
||||||
root_weight: u32,
|
root_weight: u32,
|
||||||
root_vsize: u32,
|
root_sigop_adjusted_vsize: u32,
|
||||||
root_sigops: u32,
|
root_sigops: u32,
|
||||||
cluster_rate: f64,
|
cluster_rate: f64,
|
||||||
) -> f64 {
|
) -> f64 {
|
||||||
@ -172,7 +172,7 @@ impl AuditTransaction {
|
|||||||
if self.ancestors.remove(&root_txid) {
|
if self.ancestors.remove(&root_txid) {
|
||||||
self.ancestor_fee -= root_fee;
|
self.ancestor_fee -= root_fee;
|
||||||
self.ancestor_weight -= root_weight;
|
self.ancestor_weight -= root_weight;
|
||||||
self.ancestor_vsize -= root_vsize;
|
self.ancestor_sigop_adjusted_vsize -= root_sigop_adjusted_vsize;
|
||||||
self.ancestor_sigops -= root_sigops;
|
self.ancestor_sigops -= root_sigops;
|
||||||
self.calc_new_score();
|
self.calc_new_score();
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap) -> GbtResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if blocks.len() < (MAX_BLOCKS - 1)
|
if blocks.len() < (MAX_BLOCKS - 1)
|
||||||
&& ((block_weight + (4 * next_tx.ancestor_vsize()) >= MAX_BLOCK_WEIGHT_UNITS)
|
&& ((block_weight + (4 * next_tx.ancestor_sigop_adjusted_vsize()) >= MAX_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
|
||||||
@ -297,7 +297,7 @@ fn set_relatives(txid: u32, audit_pool: &mut AuditPool) {
|
|||||||
|
|
||||||
let mut total_fee: u64 = 0;
|
let mut total_fee: u64 = 0;
|
||||||
let mut total_weight: u32 = 0;
|
let mut total_weight: u32 = 0;
|
||||||
let mut total_vsize: u32 = 0;
|
let mut total_sigop_adjusted_vsize: u32 = 0;
|
||||||
let mut total_sigops: u32 = 0;
|
let mut total_sigops: u32 = 0;
|
||||||
|
|
||||||
for ancestor_id in &ancestors {
|
for ancestor_id in &ancestors {
|
||||||
@ -306,12 +306,12 @@ fn set_relatives(txid: u32, audit_pool: &mut AuditPool) {
|
|||||||
.expect("audit_pool contains all ancestors");
|
.expect("audit_pool contains all ancestors");
|
||||||
total_fee += ancestor.fee;
|
total_fee += ancestor.fee;
|
||||||
total_weight += ancestor.weight;
|
total_weight += ancestor.weight;
|
||||||
total_vsize += ancestor.vsize;
|
total_sigop_adjusted_vsize += ancestor.sigop_adjusted_vsize;
|
||||||
total_sigops += ancestor.sigops;
|
total_sigops += ancestor.sigops;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(tx) = audit_pool.get_mut(&txid) {
|
if let Some(tx) = audit_pool.get_mut(&txid) {
|
||||||
tx.set_ancestors(ancestors, total_fee, total_weight, total_vsize, total_sigops);
|
tx.set_ancestors(ancestors, total_fee, total_weight, total_sigop_adjusted_vsize, total_sigops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ fn update_descendants(
|
|||||||
let mut descendant_stack: Vec<u32> = Vec::new();
|
let mut descendant_stack: Vec<u32> = Vec::new();
|
||||||
let root_fee: u64;
|
let root_fee: u64;
|
||||||
let root_weight: u32;
|
let root_weight: u32;
|
||||||
let root_vsize: u32;
|
let root_sigop_adjusted_vsize: u32;
|
||||||
let root_sigops: u32;
|
let root_sigops: u32;
|
||||||
if let Some(root_tx) = audit_pool.get(&root_txid) {
|
if let Some(root_tx) = audit_pool.get(&root_txid) {
|
||||||
for descendant_id in &root_tx.children {
|
for descendant_id in &root_tx.children {
|
||||||
@ -337,7 +337,7 @@ fn update_descendants(
|
|||||||
}
|
}
|
||||||
root_fee = root_tx.fee;
|
root_fee = root_tx.fee;
|
||||||
root_weight = root_tx.weight;
|
root_weight = root_tx.weight;
|
||||||
root_vsize = root_tx.vsize;
|
root_sigop_adjusted_vsize = root_tx.sigop_adjusted_vsize;
|
||||||
root_sigops = root_tx.sigops;
|
root_sigops = root_tx.sigops;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -346,7 +346,7 @@ fn update_descendants(
|
|||||||
if let Some(descendant) = audit_pool.get_mut(&next_txid) {
|
if let Some(descendant) = audit_pool.get_mut(&next_txid) {
|
||||||
// remove root tx as ancestor
|
// remove root tx as ancestor
|
||||||
let old_score =
|
let old_score =
|
||||||
descendant.remove_root(root_txid, root_fee, root_weight, root_vsize, root_sigops, cluster_rate);
|
descendant.remove_root(root_txid, root_fee, root_weight, root_sigop_adjusted_vsize, root_sigops, cluster_rate);
|
||||||
// add to priority queue or update priority if score has changed
|
// add to priority queue or update priority if score has changed
|
||||||
if descendant.score() < old_score {
|
if descendant.score() < old_score {
|
||||||
descendant.modified = true;
|
descendant.modified = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user