diff --git a/doc/migrations/v0.44-v0.45.md b/doc/migrations/v0.44-v0.45.md index 275882b8ab..1bf99acae8 100644 --- a/doc/migrations/v0.44-v0.45.md +++ b/doc/migrations/v0.44-v0.45.md @@ -58,14 +58,14 @@ const node = createLibp2p({ ```js import { createLibp2p } from 'libp2p' -import { autonatService } from 'libp2p/autonat' +import { autoNATService } from 'libp2p/autonat' import { circuitRelayServer } from 'libp2p/circuit-relay' import { identifyService } from 'libp2p/identify' import { pingService } from 'libp2p/ping' import { fetchService } from 'libp2p/fetch' import { uPnPNATService } from 'libp2p/upnp-nat' import { kadDHT } from '@libp2p/kad-dht' -import { gossipSub } from '@ChainSafe/libp2p-gossipsub' +import { gossipsub } from '@ChainSafe/libp2p-gossipsub' const node = createLibp2p({ // ... other options here @@ -82,10 +82,10 @@ const node = createLibp2p({ uPnPNAT: uPnPNATService({ /** UPnP NAT options **/ }), - autonat: autonatService({ + autoNAT: autoNATService({ /** AutoNAT options **/ }), - pubsub: gossipSub(), + pubsub: gossipsub(), dht: kadDHT(), relay: circuitRelayServer() } diff --git a/src/autonat/index.ts b/src/autonat/index.ts index 1cf28dabe0..34a367f7f5 100644 --- a/src/autonat/index.ts +++ b/src/autonat/index.ts @@ -34,7 +34,7 @@ const log = logger('libp2p:autonat') // https://github.com/libp2p/specs/blob/master/autonat/README.md#autonat-protocol const REQUIRED_SUCCESSFUL_DIALS = 4 -export interface AutonatServiceInit { +export interface AutoNATServiceInit { /** * Allows overriding the protocol prefix used */ @@ -56,17 +56,17 @@ export interface AutonatServiceInit { refreshInterval?: number /** - * How many parallel inbound autonat streams we allow per-connection + * How many parallel inbound autoNAT streams we allow per-connection */ maxInboundStreams?: number /** - * How many parallel outbound autonat streams we allow per-connection + * How many parallel outbound autoNAT streams we allow per-connection */ maxOutboundStreams?: number } -export interface AutonatComponents { +export interface AutoNATComponents { registrar: Registrar addressManager: AddressManager transportManager: TransportManager @@ -75,8 +75,8 @@ export interface AutonatComponents { peerRouting: PeerRouting } -class DefaultAutonatService implements Startable { - private readonly components: AutonatComponents +class DefaultAutoNATService implements Startable { + private readonly components: AutoNATComponents private readonly startupDelay: number private readonly refreshInterval: number private readonly protocol: string @@ -86,7 +86,7 @@ class DefaultAutonatService implements Startable { private verifyAddressTimeout?: ReturnType private started: boolean - constructor (components: AutonatComponents, init: AutonatServiceInit) { + constructor (components: AutoNATComponents, init: AutoNATServiceInit) { this.components = components this.started = false this.protocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}` @@ -130,7 +130,7 @@ class DefaultAutonatService implements Startable { } /** - * Handle an incoming autonat request + * Handle an incoming AutoNAT request */ async handleIncomingAutonatStream (data: IncomingStreamData): Promise { const signal = anySignal([AbortSignal.timeout(this.timeout)]) @@ -565,8 +565,8 @@ class DefaultAutonatService implements Startable { } } -export function autonatService (init: AutonatServiceInit = {}): (components: AutonatComponents) => {} { +export function autoNATService (init: AutoNATServiceInit = {}): (components: AutoNATComponents) => {} { return (components) => { - return new DefaultAutonatService(components, init) + return new DefaultAutoNATService(components, init) } } diff --git a/test/autonat/index.spec.ts b/test/autonat/index.spec.ts index c3e0dac643..32a3298880 100644 --- a/test/autonat/index.spec.ts +++ b/test/autonat/index.spec.ts @@ -5,7 +5,7 @@ import { expect } from 'aegir/chai' import sinon from 'sinon' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { start, stop } from '@libp2p/interfaces/startable' -import { autonatService, AutonatServiceInit } from '../../src/autonat/index.js' +import { autoNATService, AutoNATServiceInit } from '../../src/autonat/index.js' import { StubbedInstance, stubInterface } from 'sinon-ts' import type { PeerRouting } from '@libp2p/interface-peer-routing' import { Multiaddr, multiaddr } from '@multiformats/multiaddr' @@ -26,7 +26,7 @@ import { Components, defaultComponents } from '../../src/components.js' import { Uint8ArrayList } from 'uint8arraylist' import type { PeerInfo } from '@libp2p/interface-peer-info' -const defaultInit: AutonatServiceInit = { +const defaultInit: AutoNATServiceInit = { protocolPrefix: 'libp2p', maxInboundStreams: 1, maxOutboundStreams: 1, @@ -65,7 +65,7 @@ describe('autonat', () => { peerStore }) - service = autonatService(defaultInit)(components) + service = autoNATService(defaultInit)(components) await start(components) await start(service)