Skip to content

Commit

Permalink
api/consensus: validator proposed blocks endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Oct 9, 2024
1 parent a42f1e4 commit 105285a
Show file tree
Hide file tree
Showing 10 changed files with 50,835 additions and 3 deletions.
1 change: 1 addition & 0 deletions .changelog/764.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api/consensus: support filtering blocks by proposer
5 changes: 5 additions & 0 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ paths:
type: string
description: A filter on the block hash.
example: *block_hash_1
- in: query
name: proposed_by
schema:
allOf: [$ref: '#/components/schemas/StakingAddress']
description: A filter on the proposer of the block.
responses:
'200':
description: A JSON object containing a list of consensus blocks.
Expand Down
1 change: 1 addition & 0 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ func (c *StorageClient) Blocks(ctx context.Context, r apiTypes.GetConsensusBlock
r.After,
r.Before,
hash,
r.ProposedBy,
r.Limit,
r.Offset,
)
Expand Down
12 changes: 9 additions & 3 deletions storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ const (
($2::bigint IS NULL OR height <= $2::bigint) AND
($3::timestamptz IS NULL OR time >= $3::timestamptz) AND
($4::timestamptz IS NULL OR time < $4::timestamptz) AND
($5::text IS NULL OR block_hash = $5::text)
($5::text IS NULL OR block_hash = $5::text) AND
($6::text IS NULL OR proposer_entity_id = (
SELECT id
FROM chain.entities
WHERE address = $6::text
LIMIT 1
))
ORDER BY height DESC
LIMIT $6::bigint
OFFSET $7::bigint`
LIMIT $7::bigint
OFFSET $8::bigint`

Block = `
SELECT height, block_hash, time, num_txs, gas_limit, size_limit, epoch, state_root
Expand Down
Loading

0 comments on commit 105285a

Please sign in to comment.