Skip to content

Commit

Permalink
Merge pull request #3170 from cfromknecht/remove-router-reject-cache
Browse files Browse the repository at this point in the history
routing/router: remove router-level reject cache
  • Loading branch information
halseth committed Jun 11, 2019
2 parents e45d4d7 + f8db49e commit 5485101
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions routing/router.go
Expand Up @@ -381,9 +381,6 @@ type ChannelRouter struct {
// consistency between the various database accesses.
channelEdgeMtx *multimutex.Mutex

rejectMtx sync.RWMutex
rejectCache map[uint64]struct{}

sync.RWMutex

quit chan struct{}
Expand Down Expand Up @@ -413,7 +410,6 @@ func New(cfg Config) (*ChannelRouter, error) {
ntfnClientUpdates: make(chan *topologyClientUpdate),
channelEdgeMtx: multimutex.NewMutex(),
selfNode: selfNode,
rejectCache: make(map[uint64]struct{}),
quit: make(chan struct{}),
}

Expand Down Expand Up @@ -804,17 +800,9 @@ func (r *ChannelRouter) pruneZombieChans() error {
// TODO(roasbeef): add ability to delete single directional edge
chansToPrune = append(chansToPrune, info.ChannelID)

// As we're detecting this as a zombie channel, we'll add this
// to the set of recently rejected items so we don't re-accept
// it shortly after.
r.rejectCache[info.ChannelID] = struct{}{}

return nil
}

r.rejectMtx.Lock()
defer r.rejectMtx.Unlock()

err := r.cfg.Graph.ForEachChannel(filterPruneChans)
if err != nil {
return fmt.Errorf("unable to filter local zombie channels: "+
Expand Down Expand Up @@ -1120,16 +1108,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
log.Infof("Updated vertex data for node=%x", msg.PubKeyBytes)

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(ErrRejected, "recently rejected "+
"chan_id=%v", msg.ChannelID)
}
r.rejectMtx.RUnlock()

// Prior to processing the announcement we first check if we
// already know of this channel, if so, then we can exit early.
_, _, exists, isZombie, err := r.cfg.Graph.HasChannelEdge(
Expand Down Expand Up @@ -1169,10 +1147,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
fundingPoint, _, err := r.fetchChanPoint(&channelID)
if err != nil {
r.rejectMtx.Lock()
r.rejectCache[msg.ChannelID] = struct{}{}
r.rejectMtx.Unlock()

return errors.Errorf("unable to fetch chan point for "+
"chan_id=%v: %v", msg.ChannelID, err)
}
Expand All @@ -1199,10 +1173,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
r.quit,
)
if err != nil {
r.rejectMtx.Lock()
r.rejectCache[msg.ChannelID] = struct{}{}
r.rejectMtx.Unlock()

return fmt.Errorf("unable to fetch utxo "+
"for chan_id=%v, chan_point=%v: %v",
msg.ChannelID, fundingPoint, err)
Expand Down Expand Up @@ -1251,16 +1221,6 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
}

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(ErrRejected, "recently rejected "+
"chan_id=%v", msg.ChannelID)
}
r.rejectMtx.RUnlock()

// We make sure to hold the mutex for this channel ID,
// such that no other goroutine is concurrently doing
// database accesses for the same channel ID.
Expand Down

0 comments on commit 5485101

Please sign in to comment.