pub fn create_block_with_transactions<I>(&mut self, txs: I)
    where
        I: IntoIterator<Item = Box<Transaction>>,
    {
        let tx_hashes: Vec<_> = {
            let blockchain = self.blockchain_mut();
            let mut fork = blockchain.fork();
            let hashes = {
                let mut schema = CoreSchema::new(&mut fork);

                txs.into_iter()
                    .filter(|tx| tx.verify())
                    .map(|tx| {
                        let tx_id = tx.hash();
                        let tx_not_found = !schema.transactions().contains(&tx_id);
                        let tx_in_pool = schema.transactions_pool().contains(&tx_id);
                        assert!(
                            tx_not_found || tx_in_pool,
                            "Transaction is already committed: {:?}",
                            tx
                        );
                        schema.add_transaction_into_pool(tx.raw().clone());

                        tx_id
                    })
                    .collect()
            };
            blockchain.merge(fork.into_patch()).unwrap();
            hashes
        };

        self.create_block_with_tx_hashes(&tx_hashes);
    }
/// Creates a block with the given transactions.
/// Transactions that are in the pool will be ignored.
///
/// # Panics
///
/// - Panics if any of transactions has been already committed to the blockchain.
Creates a block with the given transactions.
Transactions that are in the pool will be ignored.
Creates a block with the given transactions . Transactions that are in the pool will be ignored .
pub fn create_block_with_transactions<I>(&mut self, txs: I)
    where
        I: IntoIterator<Item = Box<Transaction>>,
    {
        let tx_hashes: Vec<_> = {
            let blockchain = self.blockchain_mut();
            let mut fork = blockchain.fork();
            let hashes = {
                let mut schema = CoreSchema::new(&mut fork);
                txs.into_iter()
                    .filter(|tx| tx.verify())
                    .map(|tx| {
                        let tx_id = tx.hash();
                        let tx_not_found = !schema.transactions().contains(&tx_id);
                        let tx_in_pool = schema.transactions_pool().contains(&tx_id);
                        assert!(
                            tx_not_found || tx_in_pool,
                            "Transaction is already committed: {:?}",
                            tx
                        );
                        schema.add_transaction_into_pool(tx.raw().clone());
                        tx_id
                    })
                    .collect()
            };
            blockchain.merge(fork.into_patch()).unwrap();
            hashes
        };
        self.create_block_with_tx_hashes(&tx_hashes);
    }
pub fn create_block_with_transactions < I > ( & mut self , txs : I ) where I : IntoIterator < Item = Box < Transaction > > , { let tx_hashes : Vec < _ > = { let blockchain = self . blockchain_mut ( ) ; let mut fork = blockchain . fork ( ) ; let hashes = { let mut schema = CoreSchema :: new ( & mut fork ) ; txs . into_iter ( ) . filter ( | tx | tx . verify ( ) ) . map ( | tx | { let tx_id = tx . hash ( ) ; let tx_not_found = ! schema . transactions ( ) . contains ( & tx_id ) ; let tx_in_pool = schema . transactions_pool ( ) . contains ( & tx_id ) ; assert ! ( tx_not_found tx_in_pool " " tx ) ; schema . add_transaction_into_pool ( tx . raw ( ) . clone ( ) ) ; tx_id } ) . collect ( ) } ; blockchain . merge ( fork . into_patch ( ) ) . unwrap ( ) ; hashes } ; self . create_block_with_tx_hashes ( & tx_hashes ) ; }
Creates a block with the given transactions.
Creates a block with the given transactions .
&mut self
txs
I
&mut self
txs
I
panics
Panics if any of transactions has been already committed to the blockchain.
Panics if any of transactions has been already committed to the blockchain .