Skip to content

Commit

Permalink
Merge pull request #823 from oasisprotocol/ptrus/feature/consensus-ev…
Browse files Browse the repository at this point in the history
…ents-timestamp

api/consensus/events: Include timestamp
  • Loading branch information
ptrus authored Dec 10, 2024
2 parents 2225e3f + 40767eb commit f6673ae
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/823.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
api/consensus/events: Include timestamp in response
6 changes: 6 additions & 0 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,12 @@ components:
relates.
Present only for events of type `roothash.*` except for
`roothash.execution_discrepancy` before Eden.
timestamp:
type: string
format: date-time
description: |
The second-granular consensus time of this event's block.
example: *iso_timestamp_1
type:
allOf: [$ref: '#/components/schemas/ConsensusEventType']
description: The type of the event.
Expand Down
1 change: 1 addition & 0 deletions storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ func (c *StorageClient) Events(ctx context.Context, p apiTypes.GetConsensusEvent
&e.RoothashRuntimeRound,
&e.Type,
&e.Body,
&e.Timestamp,
); err != nil {
return nil, wrapError(err)
}
Expand Down
3 changes: 2 additions & 1 deletion storage/client/queries/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ const (
OFFSET $9::bigint`

Events = `
SELECT tx_block, tx_index, tx_hash, roothash_runtime_id, roothash_runtime, roothash_runtime_round, type, body
SELECT tx_block, tx_index, tx_hash, roothash_runtime_id, roothash_runtime, roothash_runtime_round, type, body, b.time
FROM chain.events
LEFT JOIN chain.blocks b ON tx_block = b.height
WHERE ($1::bigint IS NULL OR tx_block = $1::bigint) AND
($2::integer IS NULL OR tx_index = $2::integer) AND
($3::text IS NULL OR tx_hash = $3::text) AND
Expand Down
Loading

0 comments on commit f6673ae

Please sign in to comment.