Merge pull request #754 from ethcore/tx_queue_all
Attempting to add all transactions to mined block
This commit is contained in:
commit
0d77937caf
@ -125,10 +125,7 @@ impl MinerService for Miner {
|
||||
}
|
||||
|
||||
fn prepare_sealing(&self, chain: &BlockChainClient) {
|
||||
let no_of_transactions = 128;
|
||||
// TODO: should select transactions orm queue according to gas limit of block.
|
||||
let transactions = self.transaction_queue.lock().unwrap().top_transactions(no_of_transactions);
|
||||
|
||||
let transactions = self.transaction_queue.lock().unwrap().top_transactions();
|
||||
let b = chain.prepare_sealing(
|
||||
self.author(),
|
||||
self.gas_floor_target(),
|
||||
|
@ -59,7 +59,7 @@
|
||||
//! // Check status
|
||||
//! assert_eq!(txq.status().pending, 2);
|
||||
//! // Check top transactions
|
||||
//! let top = txq.top_transactions(3);
|
||||
//! let top = txq.top_transactions();
|
||||
//! assert_eq!(top.len(), 2);
|
||||
//! assert_eq!(top[0], st1);
|
||||
//! assert_eq!(top[1], st2);
|
||||
@ -69,7 +69,7 @@
|
||||
//! txq.remove(&st1.hash(), &default_nonce);
|
||||
//! assert_eq!(txq.status().pending, 0);
|
||||
//! assert_eq!(txq.status().future, 1);
|
||||
//! assert_eq!(txq.top_transactions(3).len(), 0);
|
||||
//! assert_eq!(txq.top_transactions().len(), 0);
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
@ -459,10 +459,9 @@ impl TransactionQueue {
|
||||
// Will be used when mining merged
|
||||
#[allow(dead_code)]
|
||||
/// Returns top transactions from the queue ordered by priority.
|
||||
pub fn top_transactions(&self, size: usize) -> Vec<SignedTransaction> {
|
||||
pub fn top_transactions(&self) -> Vec<SignedTransaction> {
|
||||
self.current.by_priority
|
||||
.iter()
|
||||
.take(size)
|
||||
.map(|t| self.by_hash.get(&t.hash).expect("Transaction Queue Inconsistency"))
|
||||
.map(|t| t.transaction.clone())
|
||||
.collect()
|
||||
@ -754,7 +753,7 @@ mod test {
|
||||
txq.add(tx2.clone(), &default_nonce).unwrap();
|
||||
|
||||
// then
|
||||
let top = txq.top_transactions(5);
|
||||
let top = txq.top_transactions();
|
||||
assert_eq!(top[0], tx);
|
||||
assert_eq!(top[1], tx2);
|
||||
assert_eq!(top.len(), 2);
|
||||
@ -793,7 +792,7 @@ mod test {
|
||||
let stats = txq.status();
|
||||
assert_eq!(stats.pending, 1);
|
||||
assert_eq!(stats.future, 1);
|
||||
let top = txq.top_transactions(5);
|
||||
let top = txq.top_transactions();
|
||||
assert_eq!(top.len(), 1);
|
||||
assert_eq!(top[0], tx);
|
||||
}
|
||||
@ -920,7 +919,7 @@ mod test {
|
||||
txq.add(tx2.clone(), &default_nonce).unwrap();
|
||||
|
||||
// then
|
||||
let t = txq.top_transactions(2);
|
||||
let t = txq.top_transactions();
|
||||
assert_eq!(txq.status().pending, 1);
|
||||
assert_eq!(t.len(), 1);
|
||||
assert_eq!(t[0], tx);
|
||||
@ -1044,7 +1043,7 @@ mod test {
|
||||
let stats = txq.status();
|
||||
assert_eq!(stats.pending, 1);
|
||||
assert_eq!(stats.future, 0);
|
||||
assert_eq!(txq.top_transactions(1)[0].gas_price, U256::from(200));
|
||||
assert_eq!(txq.top_transactions()[0].gas_price, U256::from(200));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1074,7 +1073,7 @@ mod test {
|
||||
let stats = txq.status();
|
||||
assert_eq!(stats.future, 0);
|
||||
assert_eq!(stats.pending, 2);
|
||||
assert_eq!(txq.top_transactions(2)[1].gas_price, U256::from(200));
|
||||
assert_eq!(txq.top_transactions()[1].gas_price, U256::from(200));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user