pub fn prune_tags(&mut self, tag: Tag) -> Vec<Arc<Transaction<Hash, Ex>>> {
		let mut removed = vec![];
		let mut to_remove = vec![tag];

		loop {
			let tag = match to_remove.pop() {
				Some(tag) => tag,
				None => return removed,
			};

			let res = self.provided_tags.remove(&tag)
					.and_then(|hash| self.ready.write().remove(&hash));

			if let Some(tx) = res {
				let unlocks = tx.unlocks;
				let tx = tx.transaction.transaction;

				// prune previous transactions as well
				{
					let hash = &tx.hash;
					let mut ready = self.ready.write();
					let mut find_previous = |tag| -> Option<Vec<Tag>> {
						let prev_hash = self.provided_tags.get(tag)?;
						let tx2 = ready.get_mut(&prev_hash)?;
						remove_item(&mut tx2.unlocks, hash);
						// We eagerly prune previous transactions as well.
						// But it might not always be good.
						// Possible edge case:
						// - tx provides two tags
						// - the second tag enables some subgraph we don't know of yet
						// - we will prune the transaction
						// - when we learn about the subgraph it will go to future
						// - we will have to wait for re-propagation of that transaction
						// Alternatively the caller may attempt to re-import these transactions.
						if tx2.unlocks.is_empty() {
							Some(tx2.transaction.transaction.provides.clone())
						} else {
							None
						}
					};

					// find previous transactions
					for tag in &tx.requires {
						if let Some(mut tags_to_remove) = find_previous(tag) {
							to_remove.append(&mut tags_to_remove);
						}
					}
				}

				// add the transactions that just got unlocked to `best`
				for hash in unlocks {
					if let Some(tx) = self.ready.write().get_mut(&hash) {
						tx.requires_offset += 1;
						// this transaction is ready
						if tx.requires_offset == tx.transaction.transaction.requires.len() {
							self.best.insert(tx.transaction.clone());
						}
					}
				}

				debug!(target: "txpool", "[{:?}] Pruned.", tx.hash);
				removed.push(tx);
			}
		}
	}
/// Removes transactions that provide given tag.
///
/// All transactions that lead to a transaction, which provides this tag
/// are going to be removed from the queue, but no other transactions are touched -
/// i.e. all other subgraphs starting from given tag are still considered valid & ready.
Removes transactions that provide given tag.
All transactions that lead to a transaction, which provides this tag
are going to be removed from the queue, but no other transactions are touched
i.e. all other subgraphs starting from given tag are still considered valid & ready.
Removes transactions that provide given tag . All transactions that lead to a transaction which provides this tag are going to be removed from the queue but no other transactions are touched i . e . all other subgraphs starting from given tag are still considered valid & ready .
pub fn prune_tags(&mut self, tag: Tag) -> Vec<Arc<Transaction<Hash, Ex>>> {
		let mut removed = vec![];
		let mut to_remove = vec![tag];
		loop {
			let tag = match to_remove.pop() {
				Some(tag) => tag,
				None => return removed,
			};
			let res = self.provided_tags.remove(&tag)
					.and_then(|hash| self.ready.write().remove(&hash));
			if let Some(tx) = res {
				let unlocks = tx.unlocks;
				let tx = tx.transaction.transaction;
				// prune previous transactions as well
				{
					let hash = &tx.hash;
					let mut ready = self.ready.write();
					let mut find_previous = |tag| -> Option<Vec<Tag>> {
						let prev_hash = self.provided_tags.get(tag)?;
						let tx2 = ready.get_mut(&prev_hash)?;
						remove_item(&mut tx2.unlocks, hash);
						// We eagerly prune previous transactions as well.
						// But it might not always be good.
						// Possible edge case:
						// - tx provides two tags
						// - the second tag enables some subgraph we don't know of yet
						// - we will prune the transaction
						// - when we learn about the subgraph it will go to future
						// - we will have to wait for re-propagation of that transaction
						// Alternatively the caller may attempt to re-import these transactions.
						if tx2.unlocks.is_empty() {
							Some(tx2.transaction.transaction.provides.clone())
						} else {
							None
						}
					};
					// find previous transactions
					for tag in &tx.requires {
						if let Some(mut tags_to_remove) = find_previous(tag) {
							to_remove.append(&mut tags_to_remove);
						}
					}
				}
				// add the transactions that just got unlocked to `best`
				for hash in unlocks {
					if let Some(tx) = self.ready.write().get_mut(&hash) {
						tx.requires_offset += 1;
						// this transaction is ready
						if tx.requires_offset == tx.transaction.transaction.requires.len() {
							self.best.insert(tx.transaction.clone());
						}
					}
				}
				debug!(target: "txpool", "[{:?}] Pruned.", tx.hash);
				removed.push(tx);
			}
		}
	}
pub fn prune_tags ( & mut self , tag : Tag ) -> Vec < Arc < Transaction < Hash , Ex > > > { let mut removed = vec ! [ ] ; let mut to_remove = vec ! [ tag ] ; loop { let tag = match to_remove . pop ( ) { Some ( tag ) => tag , None => return removed , } ; let res = self . provided_tags . remove ( & tag ) . and_then ( | hash | self . ready . write ( ) . remove ( & hash ) ) ; if let Some ( tx ) = res { let unlocks = tx . unlocks ; let tx = tx . transaction . transaction ; // prune previous transactions as well { let hash = & tx . hash ; let mut ready = self . ready . write ( ) ; let mut find_previous = | tag | -> Option < Vec < Tag > > { let prev_hash = self . provided_tags . get ( tag ) ? ; let tx2 = ready . get_mut ( & prev_hash ) ? ; remove_item ( & mut tx2 . unlocks , hash ) ; // We eagerly prune previous transactions as well. // But it might not always be good. // Possible edge case: // - tx provides two tags // - the second tag enables some subgraph we don't know of yet // - we will prune the transaction // - when we learn about the subgraph it will go to future // - we will have to wait for re-propagation of that transaction // Alternatively the caller may attempt to re-import these transactions. if tx2 . unlocks . is_empty ( ) { Some ( tx2 . transaction . transaction . provides . clone ( ) ) } else { None } } ; // find previous transactions for tag in & tx . requires { if let Some ( mut tags_to_remove ) = find_previous ( tag ) { to_remove . append ( & mut tags_to_remove ) ; } } } // add the transactions that just got unlocked to `best` for hash in unlocks { if let Some ( tx ) = self . ready . write ( ) . get_mut ( & hash ) { tx . requires_offset += 1 ; // this transaction is ready if tx . requires_offset == tx . transaction . transaction . requires . len ( ) { self . best . insert ( tx . transaction . clone ( ) ) ; } } } debug ! ( target " " " " tx hash ) ; removed . push ( tx ) ; } } }
Removes transactions that provide given tag.
Removes transactions that provide given tag .
&mut self
tag
Tag
&mut self
tag
Tag