Skip to content

Commit

Permalink
feat(mempool): add a sanity check (dymensionxyz#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt authored Apr 16, 2024
1 parent 5c496b4 commit c4379ff
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mempool/v1/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,11 @@ func (txmp *TxMempool) Update(
newPreFn mempool.PreCheckFunc,
newPostFn mempool.PostCheckFunc,
) error {
// TODO(creachadair): This would be a nice safety check but requires Go 1.18.
// // Safety check: The caller is required to hold the lock.
// if txmp.mtx.TryLock() {
// txmp.mtx.Unlock()
// panic("mempool: Update caller does not hold the lock")
// }
// Safety sanity check: The caller is required to hold the lock.
if txmp.mtx.TryLock() {
txmp.mtx.Unlock()
panic("mempool: Update caller does not hold the lock")
}
// Safety check: Transactions and responses must match in number.
if len(blockTxs) != len(deliverTxResponses) {
panic(fmt.Sprintf("mempool: got %d transactions but %d DeliverTx responses",
Expand Down

0 comments on commit c4379ff

Please sign in to comment.