mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 07:35:07 +02:00
rpcperms: re-init mw lookup map after removal of one
After removing a registered middlware from the slice, we need to update the index lookup map with the updated index for each middleware.
This commit is contained in:
@@ -489,10 +489,17 @@ func (r *InterceptorChain) RemoveMiddleware(middlewareName string) {
|
||||
return
|
||||
}
|
||||
delete(r.registeredMiddlewareNames, middlewareName)
|
||||
|
||||
r.registeredMiddleware = append(
|
||||
r.registeredMiddleware[:index],
|
||||
r.registeredMiddleware[index+1:]...,
|
||||
)
|
||||
|
||||
// Re-initialise the middleware look-up map with the updated indexes.
|
||||
r.registeredMiddlewareNames = make(map[string]int)
|
||||
for i, mw := range r.registeredMiddleware {
|
||||
r.registeredMiddlewareNames[mw.middlewareName] = i
|
||||
}
|
||||
}
|
||||
|
||||
// CustomCaveatSupported makes sure a middleware that handles the given custom
|
||||
|
Reference in New Issue
Block a user