Explorer page with latest blocks. WIP
This commit is contained in:
@@ -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>;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user