Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Bisq API to fix scalability issues #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/src/__fixtures__/mempool-config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
},
"BISQ": {
"ENABLED": true,
"DATA_PATH": "__BISQ_DATA_PATH__"
"HOST": "127.0.0.1",
"PORT": 8081
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also update this in the production config file.
https://github.com/bisq-network/mempool/blob/main/production/mempool-config.bisq.json#L36

},
"SOCKS5PROXY": {
"ENABLED": true,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Mempool Backend Config', () => {

expect(config.STATISTICS).toStrictEqual({ ENABLED: true, TX_PER_SECOND_SAMPLE_PERIOD: 150 });

expect(config.BISQ).toStrictEqual({ ENABLED: false, DATA_PATH: '/bisq/statsnode-data/btc_mainnet/db' });
expect(config.BISQ).toStrictEqual({ ENABLED: false, 'HOST': '127.0.0.1', 'PORT': 8081 });

expect(config.SOCKS5PROXY).toStrictEqual({
ENABLED: false,
Expand Down
20 changes: 10 additions & 10 deletions backend/src/api/bisq/bisq.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ class BisqRoutes {
res.send(result.toString());
}

private getBisqTransaction(req: Request, res: Response) {
const result = bisq.getTransaction(req.params.txId);
private async getBisqTransaction(req: Request, res: Response) {
const result = await bisq.$getTransaction(req.params.txId);
if (result) {
res.json(result);
} else {
res.status(404).send('Bisq transaction not found');
}
}

private getBisqTransactions(req: Request, res: Response) {
private async getBisqTransactions(req: Request, res: Response) {
const types: string[] = [];
req.query.types = req.query.types || [];
if (!Array.isArray(req.query.types)) {
Expand All @@ -64,30 +64,30 @@ class BisqRoutes {

const index = parseInt(req.params.index, 10) || 0;
const length = parseInt(req.params.length, 10) > 100 ? 100 : parseInt(req.params.length, 10) || 25;
const [transactions, count] = bisq.getTransactions(index, length, types);
const [transactions, count] = await bisq.$getTransactions(index, length, types);
res.header('X-Total-Count', count.toString());
res.json(transactions);
}

private getBisqBlock(req: Request, res: Response) {
const result = bisq.getBlock(req.params.hash);
private async getBisqBlock(req: Request, res: Response) {
const result = await bisq.$getBlock(req.params.hash);
if (result) {
res.json(result);
} else {
res.status(404).send('Bisq block not found');
}
}

private getBisqBlocks(req: Request, res: Response) {
private async getBisqBlocks(req: Request, res: Response) {
const index = parseInt(req.params.index, 10) || 0;
const length = parseInt(req.params.length, 10) > 100 ? 100 : parseInt(req.params.length, 10) || 25;
const [transactions, count] = bisq.getBlocks(index, length);
const [transactions, count] = await bisq.$getBlocks(index, length);
res.header('X-Total-Count', count.toString());
res.json(transactions);
}

private getBisqAddress(req: Request, res: Response) {
const result = bisq.getAddress(req.params.address.substr(1));
private async getBisqAddress(req: Request, res: Response) {
const result = await bisq.$getAddress(req.params.address.substr(1));
if (result) {
res.json(result);
} else {
Expand Down
Loading
Loading