Skip to content

Commit

Permalink
temp replace errors with assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Sep 30, 2024
1 parent a8299a4 commit 8b5cdd6
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions processor/batch-processor/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,10 @@ export class Processor<B extends BlockBase, S> {
}

private async processBatch(prevState: HotDatabaseState, finalizedHead: HashAndHeight, blocks: B[]): Promise<HotDatabaseState> {
if (prevState.height > finalizedHead.height) {
throw new FinalizedHeadBelowStateError(finalizedHead, prevState)
}

if (prevState.height === finalizedHead.height && prevState.hash !== finalizedHead.hash) {
throw new Error()
}

if (prevState.height > blocks[0].header.height) {
throw new Error()
}

if (prevState.height === blocks[0].header.height && prevState.hash !== blocks[0].header.hash) {
throw new Error()
}
assert(prevState.height <= finalizedHead.height)
assert(prevState.height !== finalizedHead.height || prevState.hash === finalizedHead.hash)
assert(prevState.height <= blocks[0].header.height)
assert(prevState.height !== blocks[0].header.height || prevState.hash === blocks[0].header.hash)

let lastBlock = last(blocks).header
let nextState: HotDatabaseState =
Expand Down

0 comments on commit 8b5cdd6

Please sign in to comment.