+ if !skip_manager {
+ match *node.connect_style.borrow() {
+ ConnectStyle::BestBlockFirst|ConnectStyle::BestBlockFirstSkippingBlocks => {
+ node.node.update_best_block(&block.header, height);
+ node.node.transactions_confirmed(&block.header, height, &block.txdata.iter().enumerate().collect::<Vec<_>>());
+ },
+ ConnectStyle::TransactionsFirst|ConnectStyle::TransactionsFirstSkippingBlocks => {
+ node.node.transactions_confirmed(&block.header, height, &block.txdata.iter().enumerate().collect::<Vec<_>>());
+ node.node.update_best_block(&block.header, height);
+ },
+ ConnectStyle::FullBlockViaListen => {
+ Listen::block_connected(node.node, &block, height);
+ }
+ }
+ }
+ node.node.test_process_background_events();
+ node.blocks.borrow_mut().push((block.header, height));
+}
+
+pub fn disconnect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, count: u32) {
+ for i in 0..count {
+ let orig_header = node.blocks.borrow_mut().pop().unwrap();
+ assert!(orig_header.1 > 0); // Cannot disconnect genesis
+ let prev_header = node.blocks.borrow().last().unwrap().clone();
+
+ node.chain_monitor.chain_monitor.block_disconnected(&orig_header.0, orig_header.1);
+ match *node.connect_style.borrow() {
+ ConnectStyle::FullBlockViaListen => {
+ Listen::block_disconnected(node.node, &orig_header.0, orig_header.1);
+ },
+ ConnectStyle::BestBlockFirstSkippingBlocks|ConnectStyle::TransactionsFirstSkippingBlocks => {
+ if i == count - 1 {
+ node.node.update_best_block(&prev_header.0, prev_header.1);
+ }
+ },
+ _ => {
+ node.node.update_best_block(&prev_header.0, prev_header.1);
+ },
+ }
+ }