pub fn import(
		&mut self,
		tx: WaitingTransaction<Hash, Ex>,
	) -> error::Result<Vec<Arc<Transaction<Hash, Ex>>>> {
		assert!(tx.is_ready(), "Only ready transactions can be imported.");
		assert!(!self.ready.read().contains_key(&tx.transaction.hash), "Transaction is already imported.");

		self.insertion_id += 1;
		let insertion_id = self.insertion_id;
		let hash = tx.transaction.hash.clone();
		let transaction = tx.transaction;

		let replaced = self.replace_previous(&transaction)?;

		let mut goes_to_best = true;
		let mut ready = self.ready.write();
		// Add links to transactions that unlock the current one
		for tag in &transaction.requires {
			// Check if the transaction that satisfies the tag is still in the queue.
			if let Some(other) = self.provided_tags.get(tag) {
				let tx = ready.get_mut(other).expect(HASH_READY);
				tx.unlocks.push(hash.clone());
				// this transaction depends on some other, so it doesn't go to best directly.
				goes_to_best = false;
			}
	 	}

		// update provided_tags
		for tag in &transaction.provides {
			self.provided_tags.insert(tag.clone(), hash.clone());
		}

		let transaction = TransactionRef {
			insertion_id,
			transaction
		};

		// insert to best if it doesn't require any other transaction to be included before it
		if goes_to_best {
			self.best.insert(transaction.clone());
		}

		// insert to Ready
		ready.insert(hash, ReadyTx {
			transaction,
			unlocks: vec![],
			requires_offset: 0,
		});

		Ok(replaced)
	}
/// Imports transactions to the pool of ready transactions.
///
/// The transaction needs to have all tags satisfied (be ready) by transactions
/// that are in this queue.
/// Returns transactions that were replaced by the one imported.
Imports transactions to the pool of ready transactions.
The transaction needs to have all tags satisfied (be ready) by transactions
that are in this queue.
Returns transactions that were replaced by the one imported.
Imports transactions to the pool of ready transactions . The transaction needs to have all tags satisfied ( be ready ) by transactions that are in this queue . Returns transactions that were replaced by the one imported .
pub fn import(
		&mut self,
		tx: WaitingTransaction<Hash, Ex>,
	) -> error::Result<Vec<Arc<Transaction<Hash, Ex>>>> {
		assert!(tx.is_ready(), "Only ready transactions can be imported.");
		assert!(!self.ready.read().contains_key(&tx.transaction.hash), "Transaction is already imported.");
		self.insertion_id += 1;
		let insertion_id = self.insertion_id;
		let hash = tx.transaction.hash.clone();
		let transaction = tx.transaction;
		let replaced = self.replace_previous(&transaction)?;
		let mut goes_to_best = true;
		let mut ready = self.ready.write();
		// Add links to transactions that unlock the current one
		for tag in &transaction.requires {
			// Check if the transaction that satisfies the tag is still in the queue.
			if let Some(other) = self.provided_tags.get(tag) {
				let tx = ready.get_mut(other).expect(HASH_READY);
				tx.unlocks.push(hash.clone());
				// this transaction depends on some other, so it doesn't go to best directly.
				goes_to_best = false;
			}
	 	}
		// update provided_tags
		for tag in &transaction.provides {
			self.provided_tags.insert(tag.clone(), hash.clone());
		}
		let transaction = TransactionRef {
			insertion_id,
			transaction
		};
		// insert to best if it doesn't require any other transaction to be included before it
		if goes_to_best {
			self.best.insert(transaction.clone());
		}
		// insert to Ready
		ready.insert(hash, ReadyTx {
			transaction,
			unlocks: vec![],
			requires_offset: 0,
		});
		Ok(replaced)
	}
pub fn import ( & mut self , tx : WaitingTransaction < Hash , Ex > , ) -> error :: Result < Vec < Arc < Transaction < Hash , Ex > > > > { assert ! ( tx is_ready ( ) " " ) ; assert ! ( self ready read ( ) contains_key ( tx transaction hash ) " " ) ; self . insertion_id += 1 ; let insertion_id = self . insertion_id ; let hash = tx . transaction . hash . clone ( ) ; let transaction = tx . transaction ; let replaced = self . replace_previous ( & transaction ) ? ; let mut goes_to_best = true ; let mut ready = self . ready . write ( ) ; // Add links to transactions that unlock the current one for tag in & transaction . requires { // Check if the transaction that satisfies the tag is still in the queue. if let Some ( other ) = self . provided_tags . get ( tag ) { let tx = ready . get_mut ( other ) . expect ( HASH_READY ) ; tx . unlocks . push ( hash . clone ( ) ) ; // this transaction depends on some other, so it doesn't go to best directly. goes_to_best = false ; } } // update provided_tags for tag in & transaction . provides { self . provided_tags . insert ( tag . clone ( ) , hash . clone ( ) ) ; } let transaction = TransactionRef { insertion_id , transaction } ; // insert to best if it doesn't require any other transaction to be included before it if goes_to_best { self . best . insert ( transaction . clone ( ) ) ; } // insert to Ready ready . insert ( hash , ReadyTx { transaction , unlocks : vec ! [ ] , requires_offset : 0 , } ) ; Ok ( replaced ) }
Imports transactions to the pool of ready transactions.
Imports transactions to the pool of ready transactions .
&mut self
tx
WaitingTransaction<Hash, Ex>
&mut self
tx
WaitingTransaction<Hash, Ex>