Skip to content

Commit f17dee9

Browse files
committed
refactor: use the built-in max/min to simplify the code
Signed-off-by: careworry <[email protected]>
1 parent 40bb571 commit f17dee9

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

backend/coins/btc/headers/headers.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,7 @@ func (headers *Headers) reorg(db DBInterface, tip int) {
366366
// Simple reorg method: re-fetch headers up to the maximum reorg limit. The server can shorten
367367
// our chain by sending a fake header and set us back by `reorgLimit` blocks, but it needs to
368368
// contain the correct PoW to do so.
369-
newTip := tip - reorgLimit
370-
if newTip < -1 {
371-
newTip = -1
372-
}
369+
newTip := max(tip-reorgLimit, -1)
373370
if err := db.RevertTo(newTip); err != nil {
374371
panic(err)
375372
}

0 commit comments

Comments
 (0)