Skip to content

Commit

Permalink
api: fetch blocks and transactions from indexer rather than app Block…
Browse files Browse the repository at this point in the history
…Store

these endpoints now fetch blocks from indexer, return just `header` and include `txCount`
 * /chain/blocks
 * /chain/blocks/{height}
 * /chain/blocks/hash/{hash}

this new endpoint fetches the full tx from indexer, and includes `subtype` and `signer` fields
 * /chain/transactions/{hash}

this legacy endpoint is now marked as deprecated
 * /chain/transactions/{height}/{index}

this endpoint now accepts more filter params (subtype, signer)
 * /chain/transactions

refactor:
* api: rename chainBlockHandler -> chainBlockByHeightHandler
  • Loading branch information
altergui committed Sep 4, 2024
1 parent b34b5bb commit 1a47b20
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 79 deletions.
2 changes: 2 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const (
ParamHeight = "height"
ParamReference = "reference"
ParamType = "type"
ParamSubtype = "subtype"
ParamSigner = "signer"
ParamAccountIdFrom = "accountIdFrom"
ParamAccountIdTo = "accountIdTo"
ParamStartDateAfter = "startDateAfter"
Expand Down
18 changes: 11 additions & 7 deletions api/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ type AccountParams struct {
// TransactionParams allows the client to filter transactions
type TransactionParams struct {
PaginationParams
Height uint64 `json:"height,omitempty"`
Type string `json:"type,omitempty"`
Hash string `json:"hash,omitempty"`
Height uint64 `json:"height,omitempty"`
Type string `json:"type,omitempty"`
Subtype string `json:"subtype,omitempty"`
Signer string `json:"signer,omitempty"`
}

// BlockParams allows the client to filter blocks
Expand Down Expand Up @@ -292,9 +295,9 @@ type TransfersList struct {
}

type GenericTransactionWithInfo struct {
TxContent json.RawMessage `json:"tx"`
TxInfo indexertypes.Transaction `json:"txInfo"`
Signature types.HexBytes `json:"signature"`
TxContent json.RawMessage `json:"tx"`
TxInfo *indexertypes.Transaction `json:"txInfo"`
Signature types.HexBytes `json:"signature"`
}

type ChainInfo struct {
Expand Down Expand Up @@ -444,8 +447,9 @@ func CensusTypeToOrigin(ctype CensusTypeDescription) (models.CensusOrigin, []byt
}

type Block struct {
comettypes.Block `json:",inline"`
Hash types.HexBytes `json:"hash" `
comettypes.Header `json:"header"`
Hash types.HexBytes `json:"hash" `
TxCount int64 `json:"txCount"`
}

// BlockList is used to return a paginated list to the client
Expand Down
Loading

0 comments on commit 1a47b20

Please sign in to comment.