Skip to content

Commit fa271f6

Browse files
Merge pull request #831 from NilFoundation/no-timestamp
[explorere_backend] remove timestamp usage from db queries
2 parents d5a7a3b + 60fb164 commit fa271f6

4 files changed

Lines changed: 1 addition & 15 deletions

File tree

explorer_backend/daos/blocks.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ hex(${prefix ? `${prefix}.` : ""}prev_block) as prev_block,
88
hex(${prefix ? `${prefix}.` : ""}main_chain_hash) as master_chain_hash,
99
${prefix ? `${prefix}.` : ""}out_transaction_num as out_txn_num,
1010
${prefix ? `${prefix}.` : ""}in_txn_num as in_txn_num,
11-
${prefix ? `${prefix}.` : ""}timestamp as timestamp,
1211
${prefix ? `${prefix}.` : ""}id as id`;
1312

1413
export type BlockListElement = {
@@ -18,7 +17,6 @@ export type BlockListElement = {
1817
master_chain_hash: string;
1918
out_txn_num: string;
2019
in_txn_num: string;
21-
timestamp: string;
2220
id: string;
2321
};
2422

@@ -29,7 +27,6 @@ export const BlockListElementScheme = z.object({
2927
master_chain_hash: z.string(),
3028
out_txn_num: z.string(),
3129
in_txn_num: z.string(),
32-
timestamp: z.string(),
3330
id: z.string(),
3431
});
3532

explorer_backend/daos/transactions.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export type ClickhouseTransactionElem = {
1818
value: string;
1919
method: string;
2020
flags: number;
21-
timestamp: string;
2221
outgoing: boolean;
2322
token: [string, string][];
2423
};
@@ -44,7 +43,6 @@ export const TransactionElemSchema = z.object({
4443
value: z.string(),
4544
method: z.string(),
4645
flags: z.number(),
47-
timestamp: z.string(),
4846
outgoing: z.boolean(),
4947
});
5048

@@ -62,7 +60,6 @@ export const TransactionFullSchema = z.object({
6260
value: z.string(),
6361
method: z.string(),
6462
flags: z.number(),
65-
timestamp: z.string(),
6663
outgoing: z.boolean(),
6764
token: z.array(TokenSchema),
6865
});
@@ -84,7 +81,6 @@ gas_used,
8481
seqno,
8582
value,
8683
fee_credit,
87-
timestamp,
8884
substring(arrayStringConcat(arrayMap(x -> hex(x), data)), 1, 8) as method`;
8985

9086
const fieldsFull = `hex(hash) as hash,
@@ -100,7 +96,6 @@ gas_used,
10096
seqno,
10197
value,
10298
fee_credit,
103-
timestamp,
10499
arrayStringConcat(arrayMap(x -> hex(x), data)) as method,
105100
arrayMap(x -> tuple(hex(tupleElement(x, 1)), tupleElement(x, 2)), token) as token`;
106101

@@ -119,7 +114,6 @@ export const getTransactionsByBlockHash = async (hash: string): Promise<Transact
119114
${fieldsElem}
120115
FROM transactions WHERE block_hash = {hash: String}
121116
ORDER BY
122-
timestamp DESC,
123117
block_id DESC,
124118
transaction_index ASC,
125119
seqno DESC,
@@ -146,7 +140,6 @@ export const getTransactionsByBlock = async (
146140
${fieldsElem}
147141
FROM transactions WHERE block_id = {id: Int32} AND shard_id = {shard: Int32}
148142
ORDER BY
149-
timestamp DESC,
150143
block_id DESC,
151144
transaction_index ASC,
152145
seqno DESC,
@@ -176,15 +169,14 @@ export const getTransactionsByAddress = async (address: string, offset: number,
176169
console.log(`SELECT
177170
${fieldsElem}
178171
FROM transactions
179-
WHERE from = {address: String} OR to = {address: String} ORDER BY timestamp DESC LIMIT {limit: Int32} OFFSET {offset: Int32}
172+
WHERE from = {address: String} OR to = {address: String} ORDER BY block_id DESC LIMIT {limit: Int32} OFFSET {offset: Int32}
180173
`);
181174
const query = await client.query({
182175
query: `SELECT
183176
${fieldsElem}
184177
FROM transactions
185178
WHERE from = {address: String} OR to = {address: String}
186179
ORDER BY
187-
timestamp DESC,
188180
block_id DESC,
189181
seqno DESC,
190182
outgoing ASC
@@ -255,7 +247,6 @@ export const getChildTransactionsByHash = async (hash: string) => {
255247
incoming.seqno as seqno,
256248
incoming.value as value,
257249
incoming.fee_credit as fee_credit,
258-
incoming.timestamp as timestamp,
259250
substring(arrayStringConcat(arrayMap(x -> hex(x), incoming.data)), 1, 8) as method
260251
FROM transactions as outgoing
261252
LEFT OUTER JOIN transactions as incoming

explorer_backend/validations/BlockSchema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { z } from "zod";
33
export const BlockSchema = z.object({
44
shard_id: z.number(),
55
prev_block: z.string(),
6-
timestamp: z.string(),
76
master_chain_hash: z.string(),
87
hash: z.string(),
98
out_transaction_num: z.number(),

explorer_backend/validations/TransactionSchema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export const TransactionSchema = z.object({
44
shard: z.string(),
55
seqno: z.number(),
66
payload: z.string(),
7-
timestamp: z.number(),
87
hash: z.string(),
98
account: z.string(),
109
fee: z.string(),

0 commit comments

Comments
 (0)