router: add SyncedHeight() method

The router subsystem has its own goroutine that receives chain updates
and then does its (quite time consuming) work on each new block. To make
it possible to find out what block the router currently is synced to, we
export its internal best height through a new method.
This commit is contained in:
Oliver Gugger 2021-05-07 19:11:19 +02:00
parent 6f2f23aae6
commit 9f0228b21c
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -2479,6 +2479,13 @@ func (r *ChannelRouter) CurrentBlockHeight() (uint32, error) {
return uint32(height), err
}
// SyncedHeight returns the block height to which the router subsystem currently
// is synced to. This can differ from the above chain height if the goroutine
// responsible for processing the blocks isn't yet up to speed.
func (r *ChannelRouter) SyncedHeight() uint32 {
return atomic.LoadUint32(&r.bestHeight)
}
// GetChannelByID return the channel by the channel id.
//
// NOTE: This method is part of the ChannelGraphSource interface.