Skip to content

Commit

Permalink
Add parameters to endpoint GET /v2/blocks
Browse files Browse the repository at this point in the history
Add `updates` and `participation` parameters to the endpoint `GET /v2/blocks`.
  • Loading branch information
agodnic committed Oct 22, 2024
1 parent d8c260c commit 30fec05
Show file tree
Hide file tree
Showing 7 changed files with 571 additions and 411 deletions.
41 changes: 41 additions & 0 deletions api/converter_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,26 @@ func (si *ServerImplementation) blockParamsToBlockFilter(params generated.Search

// Address list
{
numParticipationFilters := 0
if params.Proposer != nil {
numParticipationFilters++
}
if params.Expired != nil {
numParticipationFilters++
}
if params.Absent != nil {
numParticipationFilters++
}
if params.Updates != nil {
numParticipationFilters++
}
if params.Participation != nil {
numParticipationFilters++
}
if numParticipationFilters > 1 {
errorArr = append(errorArr, "only one of `proposer`, `expired`, `absent`, `updates`, or `participation` can be specified")
}

filter.Proposers = make(map[sdk.Address]struct{}, 0)
if params.Proposer != nil {
for _, s := range *params.Proposer {
Expand All @@ -869,6 +889,27 @@ func (si *ServerImplementation) blockParamsToBlockFilter(params generated.Search
filter.AbsentParticipationAccounts[addr] = struct{}{}
}
}

// Updates = absent || expired
if params.Updates != nil {
for _, s := range *params.Updates {
var addr sdk.Address
addr, errorArr = decodeSdkAddress(s, "updates", errorArr)
filter.AbsentParticipationAccounts[addr] = struct{}{}
filter.ExpiredParticipationAccounts[addr] = struct{}{}
}
}

// Participation = proposer || absent || expired
if params.Participation != nil {
for _, s := range *params.Participation {
var addr sdk.Address
addr, errorArr = decodeSdkAddress(s, "participation", errorArr)
filter.Proposers[addr] = struct{}{}
filter.AbsentParticipationAccounts[addr] = struct{}{}
filter.ExpiredParticipationAccounts[addr] = struct{}{}
}
}
}

// If there were any errorArr while setting up the BlockFilter, return now.
Expand Down
369 changes: 185 additions & 184 deletions api/generated/common/routes.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions api/generated/common/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

464 changes: 240 additions & 224 deletions api/generated/v2/routes.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions api/generated/v2/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 31 additions & 3 deletions api/indexer.oas2.json
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,12 @@
},
{
"$ref": "#/parameters/absent"
},
{
"$ref": "#/parameters/updates"
},
{
"$ref": "#/parameters/participation"
}
],
"responses": {
Expand Down Expand Up @@ -2735,6 +2741,17 @@
}
},
"parameters": {
"proposer": {
"type": "array",
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"description": "Block proposer. Comma separated list of addresses.",
"name": "proposer",
"in": "query",
"required": false
},
"absent": {
"type": "array",
"items": {
Expand All @@ -2757,14 +2774,25 @@
"in": "query",
"required": false
},
"proposer": {
"updates": {
"type": "array",
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"description": "Block proposer. Comma separated list of addresses.",
"name": "proposer",
"description": "Expired or absent participation accounts. Comma separated list of addresses.",
"name": "updates",
"in": "query",
"required": false
},
"participation": {
"type": "array",
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"description": "Proposer, expired or absent participation accounts. Comma separated list of addresses.",
"name": "participation",
"in": "query",
"required": false
},
Expand Down
56 changes: 56 additions & 0 deletions api/indexer.oas3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,20 @@
},
"x-algorand-format": "base64"
},
"participation": {
"description": "Proposer, expired or absent participation accounts. Comma separated list of addresses.",
"explode": false,
"in": "query",
"name": "participation",
"schema": {
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"type": "array"
},
"style": "form"
},
"proposer": {
"description": "Block proposer. Comma separated list of addresses.",
"explode": false,
Expand Down Expand Up @@ -316,6 +330,20 @@
"schema": {
"type": "string"
}
},
"updates": {
"description": "Expired or absent participation accounts. Comma separated list of addresses.",
"explode": false,
"in": "query",
"name": "updates",
"schema": {
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"type": "array"
},
"style": "form"
}
},
"responses": {
Expand Down Expand Up @@ -4945,6 +4973,34 @@
"type": "array"
},
"style": "form"
},
{
"description": "Expired or absent participation accounts. Comma separated list of addresses.",
"explode": false,
"in": "query",
"name": "updates",
"schema": {
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"type": "array"
},
"style": "form"
},
{
"description": "Proposer, expired or absent participation accounts. Comma separated list of addresses.",
"explode": false,
"in": "query",
"name": "participation",
"schema": {
"items": {
"type": "string",
"x-algorand-format": "Address"
},
"type": "array"
},
"style": "form"
}
],
"responses": {
Expand Down

0 comments on commit 30fec05

Please sign in to comment.