fn import_to_ready(&mut self, tx: WaitingTransaction<Hash, Ex>) -> error::Result<Imported<Hash, Ex>> {
		let hash = tx.transaction.hash.clone();
		let mut promoted = vec![];
		let mut failed = vec![];
		let mut removed = vec![];

		let mut first = true;
		let mut to_import = vec![tx];

		loop {
			// take first transaction from the list
			let tx = match to_import.pop() {
				Some(tx) => tx,
				None => break,
			};

			// find transactions in Future that it unlocks
			to_import.append(&mut self.future.satisfy_tags(&tx.transaction.provides));

			// import this transaction
			let current_hash = tx.transaction.hash.clone();
			match self.ready.import(tx) {
				Ok(mut replaced) => {
					if !first {
						promoted.push(current_hash);
					}
					// The transactions were removed from the ready pool. We might attempt to re-import them.
					removed.append(&mut replaced);
				},
				// transaction failed to be imported.
				Err(e) => if first {
					debug!(target: "txpool", "[{:?}] Error importing: {:?}", current_hash, e);
					return Err(e)
				} else {
					failed.push(current_hash);
				},
			}
			first = false;
		}

		// An edge case when importing transaction caused
		// some future transactions to be imported and that
		// future transactions pushed out current transaction.
		// This means that there is a cycle and the transactions should
		// be moved back to future, since we can't resolve it.
		if removed.iter().any(|tx| tx.hash == hash) {
			// We still need to remove all transactions that we promoted
			// since they depend on each other and will never get to the best iterator.
			self.ready.remove_invalid(&promoted);

			debug!(target: "txpool", "[{:?}] Cycle detected, bailing.", hash);
			bail!(error::ErrorKind::CycleDetected)
		}

		Ok(Imported::Ready {
			hash,
			promoted,
			failed,
			removed,
		})
	}
/// Imports transaction to ready queue.
///
/// NOTE the transaction has to have all requirements satisfied.
Imports transaction to ready queue.
NOTE the transaction has to have all requirements satisfied.
Imports transaction to ready queue . NOTE the transaction has to have all requirements satisfied .
fn import_to_ready(&mut self, tx: WaitingTransaction<Hash, Ex>) -> error::Result<Imported<Hash, Ex>> {
		let hash = tx.transaction.hash.clone();
		let mut promoted = vec![];
		let mut failed = vec![];
		let mut removed = vec![];
		let mut first = true;
		let mut to_import = vec![tx];
		loop {
			// take first transaction from the list
			let tx = match to_import.pop() {
				Some(tx) => tx,
				None => break,
			};
			// find transactions in Future that it unlocks
			to_import.append(&mut self.future.satisfy_tags(&tx.transaction.provides));
			// import this transaction
			let current_hash = tx.transaction.hash.clone();
			match self.ready.import(tx) {
				Ok(mut replaced) => {
					if !first {
						promoted.push(current_hash);
					}
					// The transactions were removed from the ready pool. We might attempt to re-import them.
					removed.append(&mut replaced);
				},
				// transaction failed to be imported.
				Err(e) => if first {
					debug!(target: "txpool", "[{:?}] Error importing: {:?}", current_hash, e);
					return Err(e)
				} else {
					failed.push(current_hash);
				},
			}
			first = false;
		}
		// An edge case when importing transaction caused
		// some future transactions to be imported and that
		// future transactions pushed out current transaction.
		// This means that there is a cycle and the transactions should
		// be moved back to future, since we can't resolve it.
		if removed.iter().any(|tx| tx.hash == hash) {
			// We still need to remove all transactions that we promoted
			// since they depend on each other and will never get to the best iterator.
			self.ready.remove_invalid(&promoted);
			debug!(target: "txpool", "[{:?}] Cycle detected, bailing.", hash);
			bail!(error::ErrorKind::CycleDetected)
		}
		Ok(Imported::Ready {
			hash,
			promoted,
			failed,
			removed,
		})
	}
fn import_to_ready ( & mut self , tx : WaitingTransaction < Hash , Ex > ) -> error :: Result < Imported < Hash , Ex > > { let hash = tx . transaction . hash . clone ( ) ; let mut promoted = vec ! [ ] ; let mut failed = vec ! [ ] ; let mut removed = vec ! [ ] ; let mut first = true ; let mut to_import = vec ! [ tx ] ; loop { // take first transaction from the list let tx = match to_import . pop ( ) { Some ( tx ) => tx , None => break , } ; // find transactions in Future that it unlocks to_import . append ( & mut self . future . satisfy_tags ( & tx . transaction . provides ) ) ; // import this transaction let current_hash = tx . transaction . hash . clone ( ) ; match self . ready . import ( tx ) { Ok ( mut replaced ) => { if ! first { promoted . push ( current_hash ) ; } // The transactions were removed from the ready pool. We might attempt to re-import them. removed . append ( & mut replaced ) ; } , // transaction failed to be imported. Err ( e ) => if first { debug ! ( target " " " " current_hash e ) ; return Err ( e ) } else { failed . push ( current_hash ) ; } , } first = false ; } // An edge case when importing transaction caused // some future transactions to be imported and that // future transactions pushed out current transaction. // This means that there is a cycle and the transactions should // be moved back to future, since we can't resolve it. if removed . iter ( ) . any ( | tx | tx . hash == hash ) { // We still need to remove all transactions that we promoted // since they depend on each other and will never get to the best iterator. self . ready . remove_invalid ( & promoted ) ; debug ! ( target " " " " hash ) ; bail ! ( error ErrorKind CycleDetected ) } Ok ( Imported :: Ready { hash , promoted , failed , removed , } ) }
Imports transaction to ready queue.
Imports transaction to ready queue .
&mut self
tx
WaitingTransaction<Hash, Ex>
&mut self
tx
WaitingTransaction<Hash, Ex>