Explorer page with latest blocks. WIP

This commit is contained in:
Simon Lindh
2019-11-06 15:35:02 +08:00
parent 7344c518d3
commit 02d67e8406
22 changed files with 225 additions and 20 deletions

View File

@@ -7,4 +7,7 @@ export interface AbstractBitcoinApi {
getBlockCount(): Promise<number>;
getBlock(hash: string): Promise<IBlock>;
getBlockHash(height: number): Promise<string>;
getBlocks(): Promise<string>;
getBlocksFromHeight(height: number): Promise<string>;
}

View File

@@ -80,6 +80,14 @@ class BitcoindApi implements AbstractBitcoinApi {
});
});
}
getBlocks(): Promise<string> {
throw new Error('Method not implemented.');
}
getBlocksFromHeight(height: number): Promise<string> {
throw new Error('Method not implemented.');
}
}
export default BitcoindApi;

View File

@@ -94,6 +94,28 @@ class EsploraApi implements AbstractBitcoinApi {
}
});
}
getBlocks(): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
const response: AxiosResponse = await this.client.get('/blocks');
resolve(response.data);
} catch (error) {
reject(error);
}
});
}
getBlocksFromHeight(height: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
const response: AxiosResponse = await this.client.get('/blocks/' + height);
resolve(response.data);
} catch (error) {
reject(error);
}
});
}
}
export default EsploraApi;