Skip to content

Commit 6055f41

Browse files
author
Aaron Blankstein
authored
Merge pull request #2059 from blockstack/feat/event-burn-height
feat: add burn_block_height to /new_burn_block event-dispatcher endpoint
2 parents 151e06e + ff241aa commit 6055f41

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

docs/event-dispatcher.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Example:
9494
```json
9595
{
9696
"burn_block_hash": "0x4eaabcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
97+
"burn_block_height": 331,
9798
"reward_recipients": [
9899
{
99100
"recipient": "1C56LYirKa3PFXFsvhSESgDy2acEHVAEt6",

src/chainstate/coordinator/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ pub trait BlockEventDispatcher {
120120
fn announce_burn_block(
121121
&self,
122122
burn_block: &BurnchainHeaderHash,
123+
burn_block_height: u64,
123124
rewards: Vec<(StacksAddress, u64)>,
124125
burns: u64,
125126
);
@@ -464,7 +465,12 @@ fn dispatcher_announce_burn_ops<T: BlockEventDispatcher>(
464465
}
465466
}
466467
let reward_recipients_vec = reward_recipients.into_iter().collect();
467-
dispatcher.announce_burn_block(&burn_header.block_hash, reward_recipients_vec, burn_amt);
468+
dispatcher.announce_burn_block(
469+
&burn_header.block_hash,
470+
burn_header.block_height,
471+
reward_recipients_vec,
472+
burn_amt,
473+
);
468474
}
469475

470476
impl<'a, T: BlockEventDispatcher, N: CoordinatorNotices, U: RewardSetProvider>

src/chainstate/coordinator/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ impl BlockEventDispatcher for NullEventDispatcher {
243243
fn announce_burn_block(
244244
&self,
245245
_burn_block: &BurnchainHeaderHash,
246+
_burn_block_height: u64,
246247
_rewards: Vec<(StacksAddress, u64)>,
247248
_burns: u64,
248249
) {

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl EventObserver {
117117

118118
fn make_new_burn_block_payload(
119119
burn_block: &BurnchainHeaderHash,
120+
burn_block_height: u64,
120121
rewards: Vec<(StacksAddress, u64)>,
121122
burns: u64,
122123
) -> serde_json::Value {
@@ -132,6 +133,7 @@ impl EventObserver {
132133

133134
json!({
134135
"burn_block_hash": format!("0x{}", burn_block),
136+
"burn_block_height": burn_block_height,
135137
"reward_recipients": serde_json::Value::Array(reward_recipients),
136138
"burn_amount": burns
137139
})
@@ -291,10 +293,11 @@ impl BlockEventDispatcher for EventDispatcher {
291293
fn announce_burn_block(
292294
&self,
293295
burn_block: &BurnchainHeaderHash,
296+
burn_block_height: u64,
294297
rewards: Vec<(StacksAddress, u64)>,
295298
burns: u64,
296299
) {
297-
self.process_burn_block(burn_block, rewards, burns)
300+
self.process_burn_block(burn_block, burn_block_height, rewards, burns)
298301
}
299302

300303
fn dispatch_boot_receipts(&mut self, receipts: Vec<StacksTransactionReceipt>) {
@@ -319,6 +322,7 @@ impl EventDispatcher {
319322
pub fn process_burn_block(
320323
&self,
321324
burn_block: &BurnchainHeaderHash,
325+
burn_block_height: u64,
322326
rewards: Vec<(StacksAddress, u64)>,
323327
burns: u64,
324328
) {
@@ -336,7 +340,12 @@ impl EventDispatcher {
336340
return;
337341
}
338342

339-
let payload = EventObserver::make_new_burn_block_payload(burn_block, rewards, burns);
343+
let payload = EventObserver::make_new_burn_block_payload(
344+
burn_block,
345+
burn_block_height,
346+
rewards,
347+
burns,
348+
);
340349

341350
for (_, observer) in interested_observers.iter() {
342351
observer.send_new_burn_block(&payload);

0 commit comments

Comments
 (0)