mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-29 18:10:48 +02:00
routing: ensure access to r.bestHeight is thread-safe
This commit is contained in:
@ -565,7 +565,7 @@ func (r *ChannelRouter) networkHandler() {
|
|||||||
// Since this block is stale, we update our best height
|
// Since this block is stale, we update our best height
|
||||||
// to the previous block.
|
// to the previous block.
|
||||||
blockHeight := uint32(chainUpdate.Height)
|
blockHeight := uint32(chainUpdate.Height)
|
||||||
r.bestHeight = blockHeight - 1
|
atomic.StoreUint32(&r.bestHeight, blockHeight-1)
|
||||||
|
|
||||||
// Update the channel graph to reflect that this block
|
// Update the channel graph to reflect that this block
|
||||||
// was disconnected.
|
// was disconnected.
|
||||||
@ -596,7 +596,7 @@ func (r *ChannelRouter) networkHandler() {
|
|||||||
// Once a new block arrives, we update our running
|
// Once a new block arrives, we update our running
|
||||||
// track of the height of the chain tip.
|
// track of the height of the chain tip.
|
||||||
blockHeight := uint32(chainUpdate.Height)
|
blockHeight := uint32(chainUpdate.Height)
|
||||||
r.bestHeight = blockHeight
|
atomic.StoreUint32(&r.bestHeight, blockHeight)
|
||||||
log.Infof("Pruning channel graph using block %v (height=%v)",
|
log.Infof("Pruning channel graph using block %v (height=%v)",
|
||||||
chainUpdate.Hash, blockHeight)
|
chainUpdate.Hash, blockHeight)
|
||||||
|
|
||||||
@ -919,7 +919,9 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
// FilteredChainView so we are notified if/when this channel is
|
// FilteredChainView so we are notified if/when this channel is
|
||||||
// closed.
|
// closed.
|
||||||
filterUpdate := []wire.OutPoint{*fundingPoint}
|
filterUpdate := []wire.OutPoint{*fundingPoint}
|
||||||
err = r.cfg.ChainView.UpdateFilter(filterUpdate, r.bestHeight)
|
err = r.cfg.ChainView.UpdateFilter(
|
||||||
|
filterUpdate, atomic.LoadUint32(&r.bestHeight),
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("unable to update chain "+
|
return errors.Errorf("unable to update chain "+
|
||||||
"view: %v", err)
|
"view: %v", err)
|
||||||
|
Reference in New Issue
Block a user