-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transaction history: add input addresses, metadata and slots filter (#…
…173) * transaction history: add input addresses, metadata and slots filter * remove outputs field from the response moved to the client * update .nvmrc * make input addresses and metadata optional (as an arg) * reformat slotBoundsPagination.sql Co-authored-by: Sebastien Guillemot <[email protected]> * add more comments in the code * update slotBOundsPagination.queries.ts after reformatting * update .nvmrc to lts/hydrogen * optimize slot filter tx filter query * add support to lower slot limit as -1 to get the full range * update openapi.json * update tx_count change to cml multiera after rebase * fix genesis_block task: missing tx_count * add comment explaining the <= :low condition --------- Co-authored-by: Sebastien Guillemot <[email protected]>
- Loading branch information
1 parent
577b658
commit e5c5ab1
Showing
17 changed files
with
531 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
indexer/migration/src/m20240229_000019_add_block_tx_count_column.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use sea_schema::migration::prelude::*; | ||
|
||
use entity::block::*; | ||
|
||
pub struct Migration; | ||
|
||
impl MigrationName for Migration { | ||
fn name(&self) -> &str { | ||
"m20240229_000019_add_block_tx_count_column" | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.alter_table( | ||
Table::alter() | ||
.table(Entity) | ||
.add_column(ColumnDef::new(Column::TxCount).integer()) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.alter_table( | ||
Table::alter() | ||
.table(Entity) | ||
.drop_column(Column::TxCount) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v14.17.0 | ||
lts/hydrogen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
webserver/server/app/models/pagination/slotBoundsPagination.queries.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** Types generated for queries found in "app/models/pagination/slotBoundsPagination.sql" */ | ||
import { PreparedQuery } from '@pgtyped/runtime'; | ||
|
||
/** 'SlotBoundsPagination' parameters type */ | ||
export interface ISlotBoundsPaginationParams { | ||
high: number; | ||
low: number; | ||
} | ||
|
||
/** 'SlotBoundsPagination' return type */ | ||
export interface ISlotBoundsPaginationResult { | ||
max_tx_id: string | null; | ||
min_tx_id: string | null; | ||
} | ||
|
||
/** 'SlotBoundsPagination' query type */ | ||
export interface ISlotBoundsPaginationQuery { | ||
params: ISlotBoundsPaginationParams; | ||
result: ISlotBoundsPaginationResult; | ||
} | ||
|
||
const slotBoundsPaginationIR: any = {"usedParamSet":{"low":true,"high":true},"params":[{"name":"low","required":true,"transform":{"type":"scalar"},"locs":[{"a":782,"b":786}]},{"name":"high","required":true,"transform":{"type":"scalar"},"locs":[{"a":1036,"b":1041}]}],"statement":"WITH\n low_block AS (\n SELECT\n \"Block\".id,\n \"Block\".slot\n FROM\n \"Block\"\n WHERE\n \n slot <= :low! AND tx_count > 0\n ORDER BY\n \"Block\".id DESC\n LIMIT\n 1\n ),\n high_block AS (\n SELECT\n \"Block\".id,\n \"Block\".slot\n FROM\n \"Block\"\n WHERE\n slot <= :high! AND tx_count > 0\n ORDER BY\n \"Block\".id DESC\n LIMIT 1\n ),\n min_hash AS (\n (SELECT\n COALESCE(MAX(\"Transaction\".id), -1) AS min_tx_id\n FROM\n \"Transaction\"\n JOIN low_block ON \"Transaction\".block_id = low_block.id\n GROUP BY\n low_block.slot\n LIMIT\n 1\n )\n UNION (SELECT min_tx_id FROM (values(-1)) s(min_tx_id))\n ORDER BY min_tx_id DESC\n LIMIT\n 1\n ),\n max_hash AS (\n SELECT\n COALESCE(MAX(\"Transaction\".id), -2) AS max_tx_id\n FROM\n \"Transaction\"\n JOIN high_block ON \"Transaction\".block_id = high_block.id\n GROUP BY\n high_block.slot\n )\nSELECT\n *\nFROM min_hash\nLEFT JOIN max_hash ON 1 = 1"}; | ||
|
||
/** | ||
* Query generated from SQL: | ||
* ``` | ||
* WITH | ||
* low_block AS ( | ||
* SELECT | ||
* "Block".id, | ||
* "Block".slot | ||
* FROM | ||
* "Block" | ||
* WHERE | ||
* | ||
* slot <= :low! AND tx_count > 0 | ||
* ORDER BY | ||
* "Block".id DESC | ||
* LIMIT | ||
* 1 | ||
* ), | ||
* high_block AS ( | ||
* SELECT | ||
* "Block".id, | ||
* "Block".slot | ||
* FROM | ||
* "Block" | ||
* WHERE | ||
* slot <= :high! AND tx_count > 0 | ||
* ORDER BY | ||
* "Block".id DESC | ||
* LIMIT 1 | ||
* ), | ||
* min_hash AS ( | ||
* (SELECT | ||
* COALESCE(MAX("Transaction".id), -1) AS min_tx_id | ||
* FROM | ||
* "Transaction" | ||
* JOIN low_block ON "Transaction".block_id = low_block.id | ||
* GROUP BY | ||
* low_block.slot | ||
* LIMIT | ||
* 1 | ||
* ) | ||
* UNION (SELECT min_tx_id FROM (values(-1)) s(min_tx_id)) | ||
* ORDER BY min_tx_id DESC | ||
* LIMIT | ||
* 1 | ||
* ), | ||
* max_hash AS ( | ||
* SELECT | ||
* COALESCE(MAX("Transaction".id), -2) AS max_tx_id | ||
* FROM | ||
* "Transaction" | ||
* JOIN high_block ON "Transaction".block_id = high_block.id | ||
* GROUP BY | ||
* high_block.slot | ||
* ) | ||
* SELECT | ||
* * | ||
* FROM min_hash | ||
* LEFT JOIN max_hash ON 1 = 1 | ||
* ``` | ||
*/ | ||
export const slotBoundsPagination = new PreparedQuery<ISlotBoundsPaginationParams,ISlotBoundsPaginationResult>(slotBoundsPaginationIR); | ||
|
||
|
Oops, something went wrong.