Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/common/indexer/elastic/elastic.indexer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ export class ElasticIndexerService implements IndexerInterface {
.withSort([
{ name: 'timestamp', order: ElasticSortOrder.ascending },
{ name: 'timestampMs', order: ElasticSortOrder.ascending, missing: 0 },
{ name: 'nonce', order: ElasticSortOrder.ascending },
{ name: 'uuid.keyword', order: ElasticSortOrder.ascending },
])
.withMustMultiShouldCondition(transactionHashes, hash => QueryType.Match('originalTxHash', hash));
Expand Down Expand Up @@ -477,6 +478,7 @@ export class ElasticIndexerService implements IndexerInterface {
.withSort([
{ name: 'timestamp', order: ElasticSortOrder.descending },
{ name: 'timestampMs', order: ElasticSortOrder.descending, missing: 0 },
{ name: 'nonce', order: ElasticSortOrder.descending },
{ name: 'uuid.keyword', order: ElasticSortOrder.descending },
]);

Expand Down Expand Up @@ -514,6 +516,7 @@ export class ElasticIndexerService implements IndexerInterface {
.withSort([
{ name: 'timestamp', order: ElasticSortOrder.descending },
{ name: 'timestampMs', order: ElasticSortOrder.descending, missing: 0 },
{ name: 'nonce', order: ElasticSortOrder.descending },
{ name: 'uuid.keyword', order: ElasticSortOrder.descending },
]);

Expand Down Expand Up @@ -772,12 +775,13 @@ export class ElasticIndexerService implements IndexerInterface {
const originalTxHashQuery = QueryType.Match('originalTxHash', txHash);
const timestamp: ElasticSortProperty = { name: 'timestamp', order: ElasticSortOrder.ascending };
const timestampMs: ElasticSortProperty = { name: 'timestampMs', order: ElasticSortOrder.ascending, missing: 0 };
const nonce: ElasticSortProperty = { name: 'nonce', order: ElasticSortOrder.ascending };
const uuid: ElasticSortProperty = { name: 'uuid.keyword', order: ElasticSortOrder.ascending };

const elasticQuerySc = ElasticQuery.create()
.withMustMatchCondition('type', 'unsigned')
.withPagination({ from: 0, size: 100 })
.withSort([timestamp, timestampMs, uuid])
.withSort([timestamp, timestampMs, nonce, uuid])
.withCondition(QueryConditionOptions.must, [originalTxHashQuery]);

const results = await this.elasticService.getList('operations', 'hash', elasticQuerySc);
Expand All @@ -804,6 +808,7 @@ export class ElasticIndexerService implements IndexerInterface {
.withSort([
{ name: 'timestamp', order: ElasticSortOrder.ascending },
{ name: 'timestampMs', order: ElasticSortOrder.ascending, missing: 0 },
{ name: 'nonce', order: ElasticSortOrder.ascending },
{ name: 'uuid.keyword', order: ElasticSortOrder.ascending }
])
.withMustMultiShouldCondition(hashes, hash => QueryType.Match('originalTxHash', hash));
Expand Down Expand Up @@ -1278,6 +1283,8 @@ export class ElasticIndexerService implements IndexerInterface {
.withSort([
{ name: 'timestamp', order: ElasticSortOrder.descending },
{ name: 'timestampMs', order: ElasticSortOrder.descending, missing: 0 },
{ name: 'txOrder', order: ElasticSortOrder.descending, missing: 0 },
{ name: 'order', order: ElasticSortOrder.descending, missing: 0 },
{ name: 'uuid.keyword', order: ElasticSortOrder.descending },
]);

Expand Down
3 changes: 3 additions & 0 deletions src/endpoints/sc-results/entities/smart.contract.result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export class SmartContractResult {
@ApiProperty({ type: Number })
timestamp: number = 0;

@ApiProperty({ type: Number })
timestampMs: number = 0;

@ApiProperty({ type: Number })
nonce: number = 0;

Expand Down
7 changes: 6 additions & 1 deletion src/endpoints/transactions/transaction.get.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ export class TransactionGetService {

async getTransactionScResultsFromElastic(txHash: string): Promise<SmartContractResult[]> {
const scResults = await this.indexerService.getTransactionScResults(txHash);
return scResults.map(scResult => ApiUtils.mergeObjects(new SmartContractResult(), scResult));
return scResults.map(scResult => {
if (!scResult.timestampMs) {
scResult.timestampMs = scResult.timestamp * 1000;
}
return ApiUtils.mergeObjects(new SmartContractResult(), scResult);
});
}

async tryGetTransactionFromElastic(txHash: string, fields?: string[]): Promise<TransactionDetailed | null> {
Expand Down
Loading