docs: add reference for the event dispatcher changes

This commit is contained in:
Aaron Blankstein
2021-11-10 10:40:30 -06:00
parent 9ee9101520
commit b1291dac21
3 changed files with 52 additions and 4 deletions

View File

@@ -87,7 +87,21 @@ Example:
"from_stacks_block_hash": "0xf5d4ce0efe1d42c963d615ce57f0d014f263a985175e4ece766eceff10e0a358",
"from_index_block_hash": "0x329efcbcc6daf5ac3f264522e0df50eddb5be85df6ee8a9fc2384c54274d7afc",
}
]
],
"anchored_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
},
"confirmed_microblocks_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
}
}
```
@@ -216,3 +230,37 @@ Reason can be one of:
* `ReplaceAcrossFork` - replaced by a transaction with the same nonce but in the canonical fork
* `TooExpensive` - the transaction is too expensive to include in a block
* `StaleGarbageCollect` - transaction was dropped because it became stale
### `POST /mined_block`
This payload includes data related to block mined by this Stacks node. This
will never be invoked if the node is configured only as a follower. This is invoked
when the miner **assembles** the block; this block may or may not win the sortition.
This endpoint will only broadcast events to observers that explicitly register for
`MinedBlocks` events, `AnyEvent` observers will not receive the events by default.
Example:
```json
{
"block_hash": "0x4eaabcd105865e471f697eff5dd5bd85d47ecb5a26a3379d74fae0ae87c40904",
"staks_height": 3,
"target_burn_height": 745000,
"block_size": 145000,
"anchored_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
},
"confirmed_microblocks_cost": {
"runtime": 100,
"read_count": 10,
"write_count": 5,
"read_length": 150,
"write_length": 75
}
}
```

View File

@@ -67,7 +67,7 @@ pub const PATH_ATTACHMENT_PROCESSED: &str = "attachments/new";
#[derive(Clone, Serialize, Deserialize)]
pub struct MinedBlockEvent {
pub target_burn_block: u64,
pub target_burn_height: u64,
pub block_hash: String,
pub stacks_height: u64,
pub block_size: u64,
@@ -802,7 +802,7 @@ impl EventDispatcher {
}
let payload = serde_json::to_value(MinedBlockEvent {
target_burn_block: target_burn_height,
target_burn_height,
block_hash: block.block_hash().to_string(),
stacks_height: block.header.total_work.work,
block_size: block_size_bytes,

View File

@@ -189,7 +189,7 @@ fn test_exact_block_costs() {
let mined_blocks = test_observer::get_mined_blocks();
let mut mined_blocks_map = HashMap::new();
for mined_block in mined_blocks.into_iter() {
mined_blocks_map.insert(mined_block.target_burn_block, mined_block);
mined_blocks_map.insert(mined_block.target_burn_height, mined_block);
}
let mut total_txs = 0;