Skip to content

Commit 72abe72

Browse files
committed
fix: should not prune a peer that is in the allow list once the connection limit is reached (#1515)
1 parent 12ace2b commit 72abe72

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/connection-manager/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,15 @@ export class DefaultConnectionManager extends EventEmitter<ConnectionManagerEven
683683

684684
for (const connection of sortedConnections) {
685685
log('too many connections open - closing a connection to %p', connection.remotePeer)
686-
toClose.push(connection)
686+
// check allow list
687+
const connectionInAllowList = this.allow.some((ma) => {
688+
return ma.getPeerId() === connection.remotePeer.toString()
689+
})
690+
691+
// Connections in the allow list should be excluded from pruning
692+
if (!connectionInAllowList) {
693+
toClose.push(connection)
694+
}
687695

688696
if (toClose.length === toPrune) {
689697
break

0 commit comments

Comments
 (0)