Skip to content

Commit 28e9141

Browse files
committed
Added block status enum
1 parent b823f12 commit 28e9141

File tree

6 files changed

+47
-5
lines changed

6 files changed

+47
-5
lines changed

engine/access/rest/common/models/block.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,27 @@ func (b *Block) Build(
6363
}
6464

6565
b.Links = self
66-
b.BlockStatus = blockStatus.String()
66+
67+
var status BlockStatus
68+
status.Build(blockStatus)
69+
b.BlockStatus = &status
70+
6771
return nil
6872
}
6973

74+
func (b *BlockStatus) Build(status flow.BlockStatus) {
75+
switch status {
76+
case flow.BlockStatusUnknown:
77+
*b = BLOCK_UNKNOWN
78+
case flow.BlockStatusFinalized:
79+
*b = BLOCK_FINALIZED
80+
case flow.BlockStatusSealed:
81+
*b = BLOCK_SEALED
82+
default:
83+
*b = ""
84+
}
85+
}
86+
7087
func (b *BlockPayload) Build(payload *flow.Payload) error {
7188
var blockSeal BlockSeals
7289
err := blockSeal.Build(payload.Seals)

engine/access/rest/common/models/enums.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ const (
1515
SUCCESS_RESULT = SUCCESS_TransactionExecution
1616
FAILURE_RESULT = FAILURE_TransactionExecution
1717
)
18+
19+
const (
20+
BLOCK_UNKNOWN = UNKNOWN_BlockStatus
21+
BLOCK_FINALIZED = FINALIZED_BlockStatus
22+
BLOCK_SEALED = SEALED_BlockStatus
23+
)

engine/access/rest/common/models/model_block.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ type Block struct {
1414
ExecutionResult *ExecutionResult `json:"execution_result,omitempty"`
1515
Expandable *BlockExpandable `json:"_expandable,omitempty"`
1616
Links *Links `json:"_links,omitempty"`
17-
BlockStatus string `json:"block_status"`
17+
BlockStatus *BlockStatus `json:"block_status"`
1818
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Access API
3+
*
4+
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5+
*
6+
* API version: 1.0.0
7+
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
8+
*/
9+
package models
10+
11+
// BlockStatus : This value indicates the status of a block.
12+
type BlockStatus string
13+
14+
// List of BlockStatus
15+
const (
16+
UNKNOWN_BlockStatus BlockStatus = "BLOCK_UNKNOWN"
17+
FINALIZED_BlockStatus BlockStatus = "BLOCK_FINALIZED"
18+
SEALED_BlockStatus BlockStatus = "BLOCK_SEALED"
19+
)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,4 +325,4 @@ require (
325325
replace github.com/ipfs/boxo => github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483
326326

327327
// TODO: remove after PR on onflow/flow https://github.com/onflow/flow/pull/1539 merged and flow version bumped
328-
replace github.com/onflow/flow => github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd
328+
replace github.com/onflow/flow => github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX
8989
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
9090
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
9191
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
92-
github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd h1:M01VqGZiWoPVl0lHkQR6XHJsINWbtp03OsPGzJz0ZrY=
93-
github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd/go.mod h1:bIL/+5+AGyJnFfLGejMkZRGJiXopqdkMvkJNCjrpIa4=
92+
github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e h1:6dvEjGvcHRHDYSZjCdaJtBAk3CjR+AhXc9EOe+3CtyY=
93+
github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e/go.mod h1:bIL/+5+AGyJnFfLGejMkZRGJiXopqdkMvkJNCjrpIa4=
9494
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
9595
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
9696
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=

0 commit comments

Comments
 (0)