Skip to content

Commit 1a47b20

Browse files
committed
api: fetch blocks and transactions from indexer rather than app BlockStore
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
1 parent b34b5bb commit 1a47b20

File tree

5 files changed

+174
-79
lines changed

5 files changed

+174
-79
lines changed

api/api.go

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ const (
7777
ParamHeight = "height"
7878
ParamReference = "reference"
7979
ParamType = "type"
80+
ParamSubtype = "subtype"
81+
ParamSigner = "signer"
8082
ParamAccountIdFrom = "accountIdFrom"
8183
ParamAccountIdTo = "accountIdTo"
8284
ParamStartDateAfter = "startDateAfter"

api/api_types.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ type AccountParams struct {
5050
// TransactionParams allows the client to filter transactions
5151
type TransactionParams struct {
5252
PaginationParams
53-
Height uint64 `json:"height,omitempty"`
54-
Type string `json:"type,omitempty"`
53+
Hash string `json:"hash,omitempty"`
54+
Height uint64 `json:"height,omitempty"`
55+
Type string `json:"type,omitempty"`
56+
Subtype string `json:"subtype,omitempty"`
57+
Signer string `json:"signer,omitempty"`
5558
}
5659

5760
// BlockParams allows the client to filter blocks
@@ -292,9 +295,9 @@ type TransfersList struct {
292295
}
293296

294297
type GenericTransactionWithInfo struct {
295-
TxContent json.RawMessage `json:"tx"`
296-
TxInfo indexertypes.Transaction `json:"txInfo"`
297-
Signature types.HexBytes `json:"signature"`
298+
TxContent json.RawMessage `json:"tx"`
299+
TxInfo *indexertypes.Transaction `json:"txInfo"`
300+
Signature types.HexBytes `json:"signature"`
298301
}
299302

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

446449
type Block struct {
447-
comettypes.Block `json:",inline"`
448-
Hash types.HexBytes `json:"hash" `
450+
comettypes.Header `json:"header"`
451+
Hash types.HexBytes `json:"hash" `
452+
TxCount int64 `json:"txCount"`
449453
}
450454

451455
// BlockList is used to return a paginated list to the client

0 commit comments

Comments
 (0)