mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-25 00:33:20 +08:00
address refactoring review comments
This commit is contained in:
@@ -887,34 +887,6 @@ impl<'a, 'b> ClarityBlockConnection<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn initialize_epoch_2_2(&mut self) -> Result<Vec<StacksTransactionReceipt>, Error> {
|
||||
// use the `using!` statement to ensure that the old cost_tracker is placed
|
||||
// back in all branches after initialization
|
||||
using!(self.cost_track, "cost tracker", |old_cost_tracker| {
|
||||
// epoch initialization is *free*.
|
||||
// NOTE: this also means that cost functions won't be evaluated.
|
||||
// This is important because pox-2 is instantiated before costs-3.
|
||||
self.cost_track.replace(LimitedCostTracker::new_free());
|
||||
self.epoch = StacksEpochId::Epoch22;
|
||||
self.as_transaction(|tx_conn| {
|
||||
// bump the epoch in the Clarity DB
|
||||
tx_conn
|
||||
.with_clarity_db(|db| {
|
||||
db.set_clarity_epoch_version(StacksEpochId::Epoch22);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// require 2.2 rules henceforth in this connection as well
|
||||
tx_conn.epoch = StacksEpochId::Epoch22;
|
||||
});
|
||||
|
||||
debug!("Epoch 2.2 initialized");
|
||||
|
||||
(old_cost_tracker, Ok(vec![]))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn initialize_epoch_2_1(&mut self) -> Result<Vec<StacksTransactionReceipt>, Error> {
|
||||
// use the `using!` statement to ensure that the old cost_tracker is placed
|
||||
// back in all branches after initialization
|
||||
@@ -1110,6 +1082,33 @@ impl<'a, 'b> ClarityBlockConnection<'a, 'b> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn initialize_epoch_2_2(&mut self) -> Result<Vec<StacksTransactionReceipt>, Error> {
|
||||
// use the `using!` statement to ensure that the old cost_tracker is placed
|
||||
// back in all branches after initialization
|
||||
using!(self.cost_track, "cost tracker", |old_cost_tracker| {
|
||||
// epoch initialization is *free*.
|
||||
// NOTE: this also means that cost functions won't be evaluated.
|
||||
self.cost_track.replace(LimitedCostTracker::new_free());
|
||||
self.epoch = StacksEpochId::Epoch22;
|
||||
self.as_transaction(|tx_conn| {
|
||||
// bump the epoch in the Clarity DB
|
||||
tx_conn
|
||||
.with_clarity_db(|db| {
|
||||
db.set_clarity_epoch_version(StacksEpochId::Epoch22);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
// require 2.2 rules henceforth in this connection as well
|
||||
tx_conn.epoch = StacksEpochId::Epoch22;
|
||||
});
|
||||
|
||||
debug!("Epoch 2.2 initialized");
|
||||
|
||||
(old_cost_tracker, Ok(vec![]))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn start_transaction_processing<'c>(&'c mut self) -> ClarityTransactionConnection<'c, 'a> {
|
||||
let store = &mut self.datastore;
|
||||
let cost_track = &mut self.cost_track;
|
||||
|
||||
@@ -649,7 +649,7 @@ impl StacksEpochExtension for StacksEpoch {
|
||||
read_count: 210210,
|
||||
runtime: 210210,
|
||||
},
|
||||
network_epoch: PEER_VERSION_EPOCH_2_1,
|
||||
network_epoch: PEER_VERSION_EPOCH_2_2,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -462,30 +462,6 @@ fn disable_pox() {
|
||||
.insert(pox_addr_1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// let mut have_expected_payout = false;
|
||||
// if height < epoch_2_1 + (reward_cycle_len as u64) {
|
||||
// for addr_tuple in pox_addrs {
|
||||
// // can either pay to pox tuple 1, or burn
|
||||
// assert_ne!(addr_tuple, pox_addr_tuple_2);
|
||||
// if addr_tuple == pox_addr_tuple_1 {
|
||||
// have_expected_payout = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if pox_addrs.len() > 0 {
|
||||
// assert_eq!(pox_addrs.len(), 2);
|
||||
// for addr_tuple in pox_addrs {
|
||||
// // can either pay to pox tuple 2, or burn
|
||||
// assert_ne!(addr_tuple, pox_addr_tuple_1);
|
||||
// if addr_tuple == pox_addr_tuple_2 {
|
||||
// have_expected_payout = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// assert!(have_expected_payout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user