Skip to content

Commit

Permalink
chore: update export name for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed May 9, 2023
1 parent 124ca8a commit ceed8d8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions doc/migrations/v0.44-v0.45.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
Expand Down
20 changes: 10 additions & 10 deletions src/autonat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -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
Expand All @@ -86,7 +86,7 @@ class DefaultAutonatService implements Startable {
private verifyAddressTimeout?: ReturnType<typeof setTimeout>
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}`
Expand Down Expand Up @@ -130,7 +130,7 @@ class DefaultAutonatService implements Startable {
}

/**
* Handle an incoming autonat request
* Handle an incoming AutoNAT request
*/
async handleIncomingAutonatStream (data: IncomingStreamData): Promise<void> {
const signal = anySignal([AbortSignal.timeout(this.timeout)])
Expand Down Expand Up @@ -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)
}
}
6 changes: 3 additions & 3 deletions test/autonat/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('autonat', () => {
peerStore
})

service = autonatService(defaultInit)(components)
service = autoNATService(defaultInit)(components)

await start(components)
await start(service)
Expand Down

0 comments on commit ceed8d8

Please sign in to comment.