Skip to content

Commit

Permalink
Revert "Fix error message when chain head changes (#3972)" (#4022)
Browse files Browse the repository at this point in the history
This reverts commit 9c77692.
  • Loading branch information
danield9tqh authored Jul 5, 2023
1 parent 9c77692 commit 1ccdf95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
6 changes: 1 addition & 5 deletions ironfish/src/blockchain/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ export class Blockchain {
}

if (previous && !previous.hash.equals(previousBlockHash)) {
throw new HeadChangedError(`Can't create a block not attached to the chain head`)
throw new Error('Cannot create a block with a previous header that does not match')
}

target = Target.calculateTarget(
Expand Down Expand Up @@ -1520,7 +1520,3 @@ export class VerifyError extends Error {
this.score = score
}
}

export class HeadChangedError extends Error {
name = this.constructor.name
}
16 changes: 4 additions & 12 deletions ironfish/src/mining/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { BufferSet } from 'buffer-map'
import { Assert } from '../assert'
import { Blockchain, HeadChangedError } from '../blockchain'
import { Blockchain } from '../blockchain'
import { isExpiredSequence } from '../consensus'
import { Event } from '../event'
import { MemPool } from '../memPool'
Expand Down Expand Up @@ -66,17 +66,9 @@ export class MiningManager {
this.chain.onConnectBlock.on(
(block) =>
void this.onConnectedBlock(block).catch((error) => {
if (error instanceof HeadChangedError) {
this.node.logger.debug(
`Chain head changed while creating block template for sequence ${
block.header.sequence + 1
}`,
)
} else {
this.node.logger.error(
`Error creating block template: ${ErrorUtils.renderError(error)}`,
)
}
this.node.logger.info(
`Error creating block template: ${ErrorUtils.renderError(error)}`,
)
}),
)
}
Expand Down

0 comments on commit 1ccdf95

Please sign in to comment.