Skip to content

Commit b2f1809

Browse files
authored
Merge pull request #3470 from eigerco/nijo/add-support-for-get-block-header
Add support for GET /{network}/block/{height}/header
2 parents 07c15fa + 00a73c2 commit b2f1809

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

node/rest/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
153153
.route(&format!("/{network}/block/:height_or_hash"), get(Self::get_block))
154154
// The path param here is actually only the height, but the name must match the route
155155
// above, otherwise there'll be a conflict at runtime.
156+
.route(&format!("/{network}/block/:height_or_hash/header"), get(Self::get_block_header))
156157
.route(&format!("/{network}/block/:height_or_hash/transactions"), get(Self::get_block_transactions))
157158

158159
// GET and POST ../transaction/..

node/rest/src/routes.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
125125
Ok(ErasedJson::pretty(rest.ledger.get_height(&hash)?))
126126
}
127127

128+
// GET /<network>/block/{height}/header
129+
pub(crate) async fn get_block_header(
130+
State(rest): State<Self>,
131+
Path(height): Path<u32>,
132+
) -> Result<ErasedJson, RestError> {
133+
Ok(ErasedJson::pretty(rest.ledger.get_header(height)?))
134+
}
135+
128136
// GET /<network>/block/{height}/transactions
129137
pub(crate) async fn get_block_transactions(
130138
State(rest): State<Self>,

0 commit comments

Comments
 (0)