From 46a76c68529575b0bfb19ee528c3ada6ad94c50c Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Wed, 5 Oct 2022 23:16:24 -0400 Subject: [PATCH] feat: make it possible to create a burnchain tx submission client from ongoing commit state (so another thread can be used to send the burnchain commit) --- .../burnchains/bitcoin_regtest_controller.rs | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs index 6a181505a..f401a26ff 100644 --- a/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs +++ b/testnet/stacks-node/src/burnchains/bitcoin_regtest_controller.rs @@ -80,7 +80,8 @@ pub struct BitcoinRegtestController { should_keep_running: Option>, } -struct OngoingBlockCommit { +#[derive(Clone)] +pub struct OngoingBlockCommit { payload: LeaderBlockCommitOp, utxos: UTXOSet, fees: LeaderBlockCommitFees, @@ -309,6 +310,23 @@ impl BitcoinRegtestController { } } + /// Creates a dummy bitcoin regtest controller, with the given ongoing block-commits + pub fn new_ongoing_dummy(config: Config, ongoing: Option) -> Self { + let mut ret = Self::new_dummy(config); + ret.ongoing_block_commit = ongoing; + ret + } + + /// Get an owned copy of the ongoing block commit state + pub fn get_ongoing_commit(&self) -> Option { + self.ongoing_block_commit.clone() + } + + /// Set the ongoing block commit state + pub fn set_ongoing_commit(&mut self, ongoing: Option) { + self.ongoing_block_commit = ongoing; + } + fn default_burnchain(&self) -> Burnchain { let (network_name, _network_type) = self.config.burnchain.get_bitcoin_network(); match &self.burnchain_config { @@ -1446,6 +1464,18 @@ impl BitcoinRegtestController { } } } + + #[cfg(test)] + pub fn get_mining_pubkey(&self) -> Option { + self.config.burnchain.local_mining_public_key.clone() + } + + #[cfg(test)] + pub fn set_mining_pubkey(&mut self, pubkey: String) -> Option { + let old_key = self.config.burnchain.local_mining_public_key.take(); + self.config.burnchain.local_mining_public_key = Some(pubkey); + old_key + } } impl BurnchainController for BitcoinRegtestController {