Skip to content

Commit

Permalink
perf: add indexes for queried database columns
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Oct 8, 2023
1 parent 16fa4a9 commit bfa5ad9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/db/models/ReverseSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ class ReverseSwap extends Model implements ReverseSwapType {
unique: true,
fields: ['id'],
},
{
unique: false,
fields: ['status'],
},
{
unique: true,
fields: ['preimageHash'],
Expand All @@ -172,6 +176,14 @@ class ReverseSwap extends Model implements ReverseSwapType {
unique: false,
fields: ['referral'],
},
{
unique: false,
fields: ['lockupAddress'],
},
{
unique: false,
fields: ['transactionId'],
},
],
},
);
Expand Down
12 changes: 12 additions & 0 deletions lib/db/models/Swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class Swap extends Model implements SwapType {
unique: true,
fields: ['id'],
},
{
unique: false,
fields: ['status'],
},
{
unique: true,
fields: ['preimageHash'],
Expand All @@ -131,6 +135,14 @@ class Swap extends Model implements SwapType {
unique: false,
fields: ['referral'],
},
{
unique: false,
fields: ['lockupAddress'],
},
{
unique: false,
fields: ['lockupTransactionId'],
},
],
},
);
Expand Down
4 changes: 3 additions & 1 deletion test/unit/notifications/ExampleSwaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const pendingSwapExample: SwapType = {

id: '654321',
status: SwapUpdateEvent.SwapCreated,
lockupAddress: 'bcrt1q4fgsuxk4q0uhmqm4hlhwz2kv4k374f5ta2dqn3',
preimageHash:
'c77376aa6798bf9dea9d8b2f1a08151469d3823faca22d32ac6cf00a24261870',
invoice:
Expand Down Expand Up @@ -79,6 +80,7 @@ export const pendingReverseSwapExample = {
'5b2dc635c50a25de79b86be956db2fbc6a17e36d2562f1185aca3522a5a9edf6',
invoice:
'lnbcrt1p0xqpt2pp5l34c2393chx7eut4hvlt6h0333nfa562quksdqnx8ymd437dw5msdqqcqzpgsp5f88p6pf23hrn5l7j5sp0q26vtdzzfr838njchzc3lfp6xq2nnj0q9qy9qsq33agd2syjgxjkf6mshm5x482hsu99k2ukrv27wvgtatyzw0lgs83pc0yd3fmwgcn5kcav47h4483qqz9yh4w0vegzlq3cv7zcxssm2sp7l2rck',
lockupAddress: '2Mv9up2W4ADfj4Dm9EtfCCPSwgfwTp8Sy98',
};

export const channelSwapExample: SwapType = {
Expand All @@ -94,7 +96,7 @@ export const channelSwapExample: SwapType = {
onchainAmount: 1000000,
timeoutBlockHeight: 123,
status: SwapUpdateEvent.TransactionClaimed,
lockupAddress: 'bcrt1q4fgsuxk4q0uhmqm4hlhwz2kv4k374f5ta2dqn2',
lockupAddress: 'bcrt1q4fgsuxk4q0uhmqm4hlhwz2kv4k374f5ta2dqn4',
lockupTransactionId:
'6071400d052ffd911f47537aba80500d52f67077a8522ec6915c128228f71a69',
preimageHash:
Expand Down

0 comments on commit bfa5ad9

Please sign in to comment.