lnwire: add LastBlockHeight method to QueryChannelRange
This commit is contained in:
parent
c7c0853531
commit
c4723ce3db
@ -2,6 +2,7 @@ package lnwire
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||||
)
|
)
|
||||||
@ -75,3 +76,14 @@ func (q *QueryChannelRange) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 4 + 4
|
// 32 + 4 + 4
|
||||||
return 40
|
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…
Reference in New Issue
Block a user