routing: reject any new announcements which were pruned as zombies
This commit is contained in:
parent
6d05cb5aae
commit
b54b8dd7f1
@ -237,6 +237,9 @@ type ChannelRouter struct {
|
|||||||
// consistency between the various database accesses.
|
// consistency between the various database accesses.
|
||||||
channelEdgeMtx *multimutex.Mutex
|
channelEdgeMtx *multimutex.Mutex
|
||||||
|
|
||||||
|
rejectMtx sync.RWMutex
|
||||||
|
rejectCache map[uint64]struct{}
|
||||||
|
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
|
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
@ -268,6 +271,7 @@ func New(cfg Config) (*ChannelRouter, error) {
|
|||||||
channelEdgeMtx: multimutex.NewMutex(),
|
channelEdgeMtx: multimutex.NewMutex(),
|
||||||
selfNode: selfNode,
|
selfNode: selfNode,
|
||||||
routeCache: make(map[routeTuple][]*Route),
|
routeCache: make(map[routeTuple][]*Route),
|
||||||
|
rejectCache: make(map[uint64]struct{}),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -566,9 +570,10 @@ func (r *ChannelRouter) pruneZombieChans() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.rejectMtx.Lock()
|
r.rejectMtx.Lock()
|
||||||
|
defer r.rejectMtx.Unlock()
|
||||||
|
|
||||||
err := r.cfg.Graph.ForEachChannel(filterPruneChans)
|
err := r.cfg.Graph.ForEachChannel(filterPruneChans)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.rejectMtx.Unlock()
|
|
||||||
return fmt.Errorf("Unable to filter local zombie "+
|
return fmt.Errorf("Unable to filter local zombie "+
|
||||||
"chans: %v", err)
|
"chans: %v", err)
|
||||||
}
|
}
|
||||||
@ -582,12 +587,10 @@ func (r *ChannelRouter) pruneZombieChans() error {
|
|||||||
|
|
||||||
err := r.cfg.Graph.DeleteChannelEdge(&chanToPrune)
|
err := r.cfg.Graph.DeleteChannelEdge(&chanToPrune)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.rejectMtx.Unlock()
|
|
||||||
return fmt.Errorf("Unable to prune zombie "+
|
return fmt.Errorf("Unable to prune zombie "+
|
||||||
"chans: %v", err)
|
"chans: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.rejectMtx.Unlock()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -861,6 +864,16 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
log.Infof("Updated vertex data for node=%x", msg.PubKeyBytes)
|
log.Infof("Updated vertex data for node=%x", msg.PubKeyBytes)
|
||||||
|
|
||||||
case *channeldb.ChannelEdgeInfo:
|
case *channeldb.ChannelEdgeInfo:
|
||||||
|
// If we recently rejected this channel edge, then we won't
|
||||||
|
// attempt to re-process it.
|
||||||
|
r.rejectMtx.RLock()
|
||||||
|
if _, ok := r.rejectCache[msg.ChannelID]; ok {
|
||||||
|
r.rejectMtx.RUnlock()
|
||||||
|
return newErrf(ErrIgnored, "recently rejected "+
|
||||||
|
"chan_id=%v", msg.ChannelID)
|
||||||
|
}
|
||||||
|
r.rejectMtx.RUnlock()
|
||||||
|
|
||||||
// Prior to processing the announcement we first check if we
|
// Prior to processing the announcement we first check if we
|
||||||
// already know of this channel, if so, then we can exit early.
|
// already know of this channel, if so, then we can exit early.
|
||||||
_, _, exists, err := r.cfg.Graph.HasChannelEdge(msg.ChannelID)
|
_, _, exists, err := r.cfg.Graph.HasChannelEdge(msg.ChannelID)
|
||||||
@ -972,6 +985,16 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case *channeldb.ChannelEdgePolicy:
|
case *channeldb.ChannelEdgePolicy:
|
||||||
|
// If we recently rejected this channel edge, then we won't
|
||||||
|
// attempt to re-process it.
|
||||||
|
r.rejectMtx.RLock()
|
||||||
|
if _, ok := r.rejectCache[msg.ChannelID]; ok {
|
||||||
|
r.rejectMtx.RUnlock()
|
||||||
|
return newErrf(ErrIgnored, "recently rejected "+
|
||||||
|
"chan_id=%v", msg.ChannelID)
|
||||||
|
}
|
||||||
|
r.rejectMtx.RUnlock()
|
||||||
|
|
||||||
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||||
|
|
||||||
// We make sure to hold the mutex for this channel ID,
|
// We make sure to hold the mutex for this channel ID,
|
||||||
|
Loading…
Reference in New Issue
Block a user