Move conversion logic to struct file
This commit is contained in:
parent
920232be4c
commit
d2a47b92c8
@ -1,3 +1,4 @@
|
|||||||
|
use crate::thread_transaction::ThreadTransaction;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
@ -55,3 +56,28 @@ impl Ord for AuditTransaction {
|
|||||||
self.partial_cmp(other).unwrap()
|
self.partial_cmp(other).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AuditTransaction {
|
||||||
|
pub fn from_thread_transaction(tx: &ThreadTransaction) -> Self {
|
||||||
|
AuditTransaction {
|
||||||
|
uid: tx.uid,
|
||||||
|
fee: tx.fee,
|
||||||
|
weight: tx.weight,
|
||||||
|
sigops: tx.sigops,
|
||||||
|
fee_per_vsize: tx.fee_per_vsize,
|
||||||
|
effective_fee_per_vsize: tx.effective_fee_per_vsize,
|
||||||
|
dependency_rate: f64::INFINITY,
|
||||||
|
inputs: tx.inputs.clone(),
|
||||||
|
relatives_set_flag: false,
|
||||||
|
ancestors: HashSet::new(),
|
||||||
|
children: HashSet::new(),
|
||||||
|
ancestor_fee: tx.fee,
|
||||||
|
ancestor_weight: tx.weight,
|
||||||
|
ancestor_sigops: tx.sigops,
|
||||||
|
score: 0.0,
|
||||||
|
used: false,
|
||||||
|
modified: false,
|
||||||
|
dirty: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use priority_queue::PriorityQueue;
|
use priority_queue::PriorityQueue;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::collections::{HashMap, HashSet, VecDeque};
|
use std::collections::{HashMap, HashSet, VecDeque};
|
||||||
use std::f64::INFINITY;
|
|
||||||
|
|
||||||
use crate::audit_transaction::AuditTransaction;
|
use crate::audit_transaction::AuditTransaction;
|
||||||
use crate::thread_transaction::ThreadTransaction;
|
use crate::thread_transaction::ThreadTransaction;
|
||||||
@ -60,26 +59,7 @@ fn make_block_templates(mempool: &mut HashMap<u32, ThreadTransaction>) -> Option
|
|||||||
|
|
||||||
// Initialize working structs
|
// Initialize working structs
|
||||||
for (uid, tx) in mempool {
|
for (uid, tx) in mempool {
|
||||||
let audit_tx = AuditTransaction {
|
let audit_tx = AuditTransaction::from_thread_transaction(tx);
|
||||||
uid: tx.uid,
|
|
||||||
fee: tx.fee,
|
|
||||||
weight: tx.weight,
|
|
||||||
sigops: tx.sigops,
|
|
||||||
fee_per_vsize: tx.fee_per_vsize,
|
|
||||||
effective_fee_per_vsize: tx.effective_fee_per_vsize,
|
|
||||||
dependency_rate: INFINITY,
|
|
||||||
inputs: tx.inputs.clone(),
|
|
||||||
relatives_set_flag: false,
|
|
||||||
ancestors: HashSet::new(),
|
|
||||||
children: HashSet::new(),
|
|
||||||
ancestor_fee: tx.fee,
|
|
||||||
ancestor_weight: tx.weight,
|
|
||||||
ancestor_sigops: tx.sigops,
|
|
||||||
score: 0.0,
|
|
||||||
used: false,
|
|
||||||
modified: false,
|
|
||||||
dirty: false,
|
|
||||||
};
|
|
||||||
audit_pool.insert(audit_tx.uid, audit_tx);
|
audit_pool.insert(audit_tx.uid, audit_tx);
|
||||||
mempool_array.push_back(*uid);
|
mempool_array.push_back(*uid);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user