Skip to content

Commit

Permalink
Removed unnecessary async/await functions from PollService
Browse files Browse the repository at this point in the history
  • Loading branch information
pkcs8 committed Oct 5, 2022
1 parent 3ec96b4 commit c2fb856
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/processors/peersync/PollService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ class PollService {

client.getValidationsByLedgerRange(ledgerRangeRequest)
.on('data', async (validation: ValidationResponse) => {
await this.save(validation)
try {
const vm = new ValidationMessage(this.deserialize(validation))
await vm.create()
} catch {
}
this._totalDocs++
})
.on('end', () => {
Expand All @@ -55,17 +59,8 @@ class PollService {
})
}

private async save(validation: ValidationResponse) {
const doc = await this.deserialize(validation)
try {
const vm = new ValidationMessage(doc)
await vm.create()
} catch {
}
}

// Internal: Deserialize Protobuf message to object
private async deserialize(validation: ValidationResponse): Promise<IValidation> {
private deserialize(validation: ValidationResponse): IValidation {
return {
cookie: validation.getCookie(),
data: validation.getData(),
Expand Down

0 comments on commit c2fb856

Please sign in to comment.