Rearange network dropdown.
API for Bisq block height tip. Loading indicators on transactions/blocks view. Total sent now correctly display burnt on Pay trade fee txs.
This commit is contained in:
@@ -5,6 +5,7 @@ import { BisqBlocks, BisqBlock, BisqTransaction, BisqStats, BisqTrade } from '..
|
||||
import { Common } from './common';
|
||||
|
||||
class Bisq {
|
||||
private latestBlockHeight = 0;
|
||||
private blocks: BisqBlock[] = [];
|
||||
private transactions: BisqTransaction[] = [];
|
||||
private transactionIndex: { [txId: string]: BisqTransaction } = {};
|
||||
@@ -70,6 +71,10 @@ class Bisq {
|
||||
this.priceUpdateCallbackFunction = fn;
|
||||
}
|
||||
|
||||
getLatestBlockHeight(): number {
|
||||
return this.latestBlockHeight;
|
||||
}
|
||||
|
||||
private updatePrice() {
|
||||
request('https://markets.bisq.network/api/trades/?market=bsq_btc', { json: true }, (err, res, trades: BisqTrade[]) => {
|
||||
if (err) { return console.log(err); }
|
||||
@@ -180,6 +185,7 @@ class Bisq {
|
||||
if (data.blocks && data.blocks.length !== this.blocks.length) {
|
||||
this.blocks = data.blocks.filter((block) => block.txs.length > 0);
|
||||
this.blocks.reverse();
|
||||
this.latestBlockHeight = data.chainHeight;
|
||||
const time = new Date().getTime() - start;
|
||||
console.log('Bisq dump loaded in ' + time + ' ms');
|
||||
} else {
|
||||
|
||||
@@ -96,6 +96,7 @@ class Server {
|
||||
.get(config.API_ENDPOINT + 'bisq/stats', routes.getBisqStats)
|
||||
.get(config.API_ENDPOINT + 'bisq/tx/:txId', routes.getBisqTransaction)
|
||||
.get(config.API_ENDPOINT + 'bisq/block/:hash', routes.getBisqBlock)
|
||||
.get(config.API_ENDPOINT + 'bisq/blocks/tip/height', routes.getBisqTip)
|
||||
.get(config.API_ENDPOINT + 'bisq/blocks/:index/:length', routes.getBisqBlocks)
|
||||
.get(config.API_ENDPOINT + 'bisq/address/:address', routes.getBisqAddress)
|
||||
.get(config.API_ENDPOINT + 'bisq/txs/:index/:length', routes.getBisqTransactions)
|
||||
|
||||
@@ -92,6 +92,11 @@ class Routes {
|
||||
res.send(result);
|
||||
}
|
||||
|
||||
public getBisqTip(req: Request, res: Response) {
|
||||
const result = bisq.getLatestBlockHeight();
|
||||
res.send(result.toString());
|
||||
}
|
||||
|
||||
public getBisqTransaction(req: Request, res: Response) {
|
||||
const result = bisq.getTransaction(req.params.txId);
|
||||
if (result) {
|
||||
|
||||
Reference in New Issue
Block a user