Skip to content

Commit

Permalink
fix: make block range configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
wrap-that-potassium committed Aug 20, 2022
1 parent ded015a commit 4bd4fc8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wban-backend",
"version": "1.4.0",
"version": "1.4.2",
"description": "wBAN backend for swaps",
"main": "dist/app.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export default {
process.env.BC_WALLET_MMENOMIC_SIGNER_INDEX ?? 0,
BlockchainWalletPendingTransactionsThreadEnabled:
process.env.BC_PENDING_TXN_THREAD ?? true,
BlockchainWalletBlockRangeMax: Number.parseInt(
process.env.BC_BLOCK_RANGE_MAX ?? "3000",
10
),
BlockchainWalletPendingTransactionsStartFromBlock: Number.parseInt(
process.env.BC_PENDING_BLOCKS_START ?? "0",
10
Expand All @@ -64,7 +68,7 @@ export default {
process.env.BC_GASLESS_BAN_THRESHOLD ?? 1000,
BlockchainGasLessCryptoBalanceThreshold:
process.env.BC_GASLESS_CRYPTO_THRESHOLD ?? 1,
BlockchainRelayerEnabled: process.env.BC_RELAYER_ENABLED === 'true',
BlockchainRelayerEnabled: process.env.BC_RELAYER_ENABLED === "true",
BlockchainRelayerApiKey: process.env.BC_RELAYER_API_KEY ?? "",
BlockchainRelayerSecretKey: process.env.BC_RELAYER_SECRET_KEY ?? "",

Expand Down
8 changes: 6 additions & 2 deletions src/services/queuing/RedisBlockchainScanQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ class RedisBlockchainScanQueue implements BlockchainScanQueue {
}
);
this.worker.registerProcessorForJobNamed("bc-scan-repeat", async () => {
const latestBlockProcessed: number = await usersDepositsService.getLastBlockchainBlockProcessed();
const latestBlockProcessed: number =
await usersDepositsService.getLastBlockchainBlockProcessed();
const currentBlock: number = await provider.getBlockNumber();
this.queue.add(
"bc-scan",
{
blockFrom: latestBlockProcessed + 1,
blockTo: Math.min(latestBlockProcessed + 10_000, currentBlock),
blockTo: Math.min(
latestBlockProcessed + config.BlockchainWalletBlockRangeMax,
currentBlock
),
},
{
jobId: `${latestBlockProcessed + 1}-${currentBlock}`,
Expand Down

0 comments on commit 4bd4fc8

Please sign in to comment.