mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 22:25:24 +01:00
lnwire: add LastBlockHeight method to QueryChannelRange
This commit is contained in:
parent
c7c0853531
commit
c4723ce3db
1 changed files with 12 additions and 0 deletions
|
@ -2,6 +2,7 @@ package lnwire
|
|||
|
||||
import (
|
||||
"io"
|
||||
"math"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
)
|
||||
|
@ -75,3 +76,14 @@ func (q *QueryChannelRange) MaxPayloadLength(uint32) uint32 {
|
|||
// 32 + 4 + 4
|
||||
return 40
|
||||
}
|
||||
|
||||
// LastBlockHeight returns the last block height covered by the range of a
|
||||
// QueryChannelRange message.
|
||||
func (q *QueryChannelRange) LastBlockHeight() uint32 {
|
||||
// Handle overflows by casting to uint64.
|
||||
lastBlockHeight := uint64(q.FirstBlockHeight) + uint64(q.NumBlocks) - 1
|
||||
if lastBlockHeight > math.MaxUint32 {
|
||||
return math.MaxUint32
|
||||
}
|
||||
return uint32(lastBlockHeight)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue