-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
feddc26
commit ef4fccf
Showing
4 changed files
with
69 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { BlockRepository } from '~/domain/Block/BlockRepository'; | ||
import { | ||
type QueueData, | ||
type QueueInputs, | ||
QueueNames, | ||
queue, | ||
} from '~/infra/queue/Queue'; | ||
|
||
type Input = QueueInputs[QueueNames.ADD_BLOCK_RANGE]; | ||
|
||
export class AddBlockRange { | ||
async execute({ data }: QueueData<Input>) { | ||
const { blocks } = data; | ||
const repo = new BlockRepository(); | ||
await repo.upsertMany(blocks); | ||
await queue.push(QueueNames.SYNC_TRANSACTIONS, { blocks }); | ||
} | ||
} | ||
|
||
export const addBlockRange = async (input: QueueData<Input>) => { | ||
try { | ||
const { execute } = new AddBlockRange(); | ||
await execute(input); | ||
} catch (error) { | ||
console.error(error); | ||
throw new Error('Sync transactions', { | ||
cause: error, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters