Skip to content

Commit

Permalink
fix: revert config changes from #1520 (#1522)
Browse files Browse the repository at this point in the history
Removes the extra defaults set as they are unnecessary.
  • Loading branch information
achingbrain committed Dec 20, 2022
1 parent 3e53c19 commit 2fa2893
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
13 changes: 2 additions & 11 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,7 @@ const DefaultConfig: Partial<Libp2pInit> = {
resolvers: {
dnsaddr: dnsaddrResolver
},
addressSorter: publicAddressesFirst,
maxEventLoopDelay: Infinity,
pollInterval: Infinity,
maxAddrsToDial: Infinity,
startupReconnectTimeout: Infinity,
allow: [],
deny: [],
maxIncomingPendingConnections: Infinity,
inboundConnectionThreshold: Infinity
addressSorter: publicAddressesFirst
},
connectionGater: {},
transportManager: {
Expand All @@ -50,8 +42,7 @@ const DefaultConfig: Partial<Libp2pInit> = {
enabled: true,
interval: 6e5,
bootDelay: 10e3
},
routers: []
}
},
nat: {
enabled: true,
Expand Down
8 changes: 7 additions & 1 deletion src/connection-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export interface DefaultConnectionManagerComponents {
dialer: Dialer
}

export type ConnectionManagerInit = Required<ConnectionManagerConfig>
export type ConnectionManagerInit = ConnectionManagerConfig

/**
* Responsible for managing known connections.
Expand Down Expand Up @@ -579,6 +579,12 @@ export class DefaultConnectionManager extends EventEmitter<ConnectionManagerEven
*/
async _checkMaxLimit (name: keyof ConnectionManagerInit, value: number, toPrune: number = 1) {
const limit = this.opts[name]

if (limit == null) {
log.trace('limit %s was not set so it cannot be applied', name)
return
}

log.trace('checking limit of %s. current value: %d of %d', name, value, limit)
if (value > limit) {
log('%s: limit exceeded: %p, %d/%d, pruning %d connection(s)', this.components.peerId, name, value, limit, toPrune)
Expand Down
4 changes: 2 additions & 2 deletions src/peer-routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface RefreshManagerInit {
}

export interface PeerRoutingInit {
routers: PeerRouting[]
routers?: PeerRouting[]
refreshManager?: RefreshManagerInit
}

Expand All @@ -69,7 +69,7 @@ export class DefaultPeerRouting implements PeerRouting, Startable {

constructor (components: DefaultPeerRoutingComponents, init: PeerRoutingInit) {
this.components = components
this.routers = init.routers
this.routers = init.routers ?? []
this.refreshManagerInit = init.refreshManager ?? {}
this.started = false

Expand Down

0 comments on commit 2fa2893

Please sign in to comment.