feat: add get_stacks_epochs() trait implementation

This commit is contained in:
Jude Nelson
2021-11-17 14:51:51 -05:00
parent 7b48264890
commit 02cd864dae

View File

@@ -42,6 +42,7 @@ use stacks::chainstate::burn::operations::{
};
use stacks::chainstate::coordinator::comm::CoordinatorChannels;
use stacks::codec::StacksMessageCodec;
use stacks::core::StacksEpoch;
use stacks::deps::bitcoin::blockdata::opcodes;
use stacks::deps::bitcoin::blockdata::script::{Builder, Script};
use stacks::deps::bitcoin::blockdata::transaction::{OutPoint, Transaction, TxIn, TxOut};
@@ -320,7 +321,7 @@ impl BitcoinRegtestController {
}
}
fn setup_indexer_runtime(&mut self) -> (Burnchain, BitcoinIndexer) {
fn setup_indexer_runtime(&self) -> (Burnchain, BitcoinIndexer) {
let (_, network_type) = self.config.burnchain.get_bitcoin_network();
let indexer_runtime = BitcoinIndexerRuntime::new(network_type);
let burnchain_indexer = BitcoinIndexer {
@@ -1480,6 +1481,16 @@ impl BurnchainController for BitcoinRegtestController {
Ok(())
}
fn get_stacks_epochs(&self) -> Vec<StacksEpoch> {
match self.config.burnchain.epochs.as_ref() {
Some(epochs) => epochs.clone(),
None => {
let (_, indexer) = self.setup_indexer_runtime();
indexer.get_stacks_epochs()
}
}
}
fn start(
&mut self,
target_block_height_opt: Option<u64>,