Skip to content
Snippets Groups Projects
Commit ef9f351e authored by Igor Markin's avatar Igor Markin
Browse files

Fetch microblock for Verification and use it's time as the TX time

parent a50db5f2
No related branches found
No related tags found
1 merge request!8028 get seal time from aeternity api
...@@ -56,9 +56,11 @@ export interface BlockData { ...@@ -56,9 +56,11 @@ export interface BlockData {
export interface TxData { export interface TxData {
hash: string; hash: string;
blockHeight: number; blockHeight: number;
blockHash: string;
tx: { tx: {
callData: string; callData: string;
}; };
time?: number;
} }
export interface DecodedCallData { export interface DecodedCallData {
key: string; key: string;
......
...@@ -95,6 +95,7 @@ class AeternityService { ...@@ -95,6 +95,7 @@ class AeternityService {
tx: { tx: {
callData: data.tx.call_data, callData: data.tx.call_data,
}, },
blockHash: data.block_hash,
}; };
} }
...@@ -117,6 +118,20 @@ class AeternityService { ...@@ -117,6 +118,20 @@ class AeternityService {
}; };
} }
async getMicroBlock(
hash: string
): Promise<{ height: number; time: number; hash: string }> {
const { time, height } = await this.requestNode({
url: `/v2/micro-blocks/hash/${hash}/header`,
}).then(({ data }: Response<AeternityAPIBlockData>) => data);
return {
height,
time,
hash,
};
}
async getBlock( async getBlock(
height: number height: number
): Promise<{ height: number; time: number; hash: string }> { ): Promise<{ height: number; time: number; hash: string }> {
......
export interface AeternityAPITxData { export interface AeternityAPITxData {
hash: string; hash: string;
block_height: number; block_height: number;
block_hash: string;
tx: { tx: {
call_data: string; call_data: string;
}; };
......
...@@ -144,7 +144,14 @@ class VerificationService extends EventEmitter { ...@@ -144,7 +144,14 @@ class VerificationService extends EventEmitter {
this.emit(STATUS_BATCH_VERIFIED, batchVerificationDetails); this.emit(STATUS_BATCH_VERIFIED, batchVerificationDetails);
blockData = await this.getBlockData(txData.blockHeight); const blockRequests = await Promise.all([
this.getBlockData(txData.blockHeight),
this._aeternityService.getMicroBlock(txData.blockHash),
]);
blockData = blockRequests[0];
const microBlockData = blockRequests[1];
txData.time = microBlockData.time;
this.emit(BLOCK_DATA_RETRIEVED, blockData); this.emit(BLOCK_DATA_RETRIEVED, blockData);
} catch (e) { } catch (e) {
......
...@@ -65,9 +65,11 @@ export interface BlockData { ...@@ -65,9 +65,11 @@ export interface BlockData {
export interface TxData { export interface TxData {
hash: string; hash: string;
blockHeight: number; blockHeight: number;
blockHash: string;
tx: { tx: {
callData: string; callData: string;
}; };
time?: number;
} }
export interface DecodedCallData { export interface DecodedCallData {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment