routing: don't re-validate a channel update's edge if it already exists
By avoiding re-validating the channel edge, we avoid wasted network bandwidth and queries.
This commit is contained in:
parent
b069406d1e
commit
bc4ad34190
@ -674,7 +674,9 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
|
|
||||||
case *channeldb.ChannelEdgePolicy:
|
case *channeldb.ChannelEdgePolicy:
|
||||||
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||||
edge1Timestamp, edge2Timestamp, _, err := r.cfg.Graph.HasChannelEdge(msg.ChannelID)
|
edge1Timestamp, edge2Timestamp, exists, err := r.cfg.Graph.HasChannelEdge(
|
||||||
|
msg.ChannelID,
|
||||||
|
)
|
||||||
if err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
if err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
||||||
return errors.Errorf("unable to check for edge "+
|
return errors.Errorf("unable to check for edge "+
|
||||||
"existence: %v", err)
|
"existence: %v", err)
|
||||||
@ -710,19 +712,24 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before we can update the channel information, we'll ensure
|
if !exists {
|
||||||
// that the target channel is still open by querying the
|
// Before we can update the channel information, we'll
|
||||||
// utxo-set for its existence.
|
// ensure that the target channel is still open by
|
||||||
|
// querying the utxo-set for its existence.
|
||||||
chanPoint, err := r.fetchChanPoint(&channelID)
|
chanPoint, err := r.fetchChanPoint(&channelID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("unable to fetch chan point for "+
|
return errors.Errorf("unable to fetch chan "+
|
||||||
"chan_id=%v: %v", msg.ChannelID, err)
|
"point for chan_id=%v: %v",
|
||||||
|
msg.ChannelID, err)
|
||||||
}
|
}
|
||||||
_, err = r.cfg.Chain.GetUtxo(chanPoint, channelID.BlockHeight)
|
_, err = r.cfg.Chain.GetUtxo(
|
||||||
|
chanPoint, channelID.BlockHeight,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("unable to fetch utxo for "+
|
return errors.Errorf("unable to fetch utxo for "+
|
||||||
"chan_id=%v: %v", msg.ChannelID, err)
|
"chan_id=%v: %v", msg.ChannelID, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now that we know this isn't a stale update, we'll apply the
|
// Now that we know this isn't a stale update, we'll apply the
|
||||||
// new edge policy to the proper directional edge within the
|
// new edge policy to the proper directional edge within the
|
||||||
|
Loading…
Reference in New Issue
Block a user