MCPcopy Create free account
hub / github.com/subquery/subql / getBlockTimestamp

Method getBlockTimestamp

packages/node/src/blockchain.service.ts:116–130  ·  view source on GitHub ↗
(height: number)

Source from the content-addressed store, hash-verified

114 }
115
116 async getBlockTimestamp(height: number): Promise<Date> {
117 const block = await getBlockByHeight(this.apiService.api, height);
118
119 let timestamp = getTimestamp(block);
120 if (!timestamp) {
121 // Not all networks have a block timestamp, e.g. Shiden
122 const blockTimestamp = await (
123 await this.apiService.unsafeApi.at(block.hash)
124 ).query.timestamp.now();
125
126 timestamp = new Date(blockTimestamp.toNumber());
127 }
128
129 return timestamp;
130 }
131
132 getBlockSize(block: IBlock): number {
133 return getBlockSize(block);

Callers

nothing calls this directly

Calls 2

getBlockByHeightFunction · 0.90
getTimestampFunction · 0.90

Tested by

no test coverage detected