Skip to content

Commit

Permalink
chore: update event names
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Mar 13, 2024
1 parent 79300d7 commit 4203a8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/ipns/src/dnslink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { CodeError, type Logger } from '@libp2p/interface'
import { peerIdFromString } from '@libp2p/peer-id'
import { RecordType } from '@multiformats/dns'
import { CID } from 'multiformats/cid'
import type { ResolveDNSOptions } from './index.js'
import type { ResolveDNSLinkOptions } from './index.js'
import type { DNS } from '@multiformats/dns'

const MAX_RECURSIVE_DEPTH = 32

async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSOptions = {}): Promise<string> {
async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise<string> {
if (depth === 0) {
throw new Error('recursion limit exceeded')
}

Check warning on line 13 in packages/ipns/src/dnslink.ts

View check run for this annotation

Codecov / codecov/patch

packages/ipns/src/dnslink.ts#L12-L13

Added lines #L12 - L13 were not covered by tests
Expand Down Expand Up @@ -103,7 +103,7 @@ async function recursiveResolveDnslink (domain: string, depth: number, dns: DNS,
throw new CodeError(`No DNSLink records found for domain: ${domain}`, 'ERR_DNSLINK_NOT_FOUND')
}

Check warning on line 104 in packages/ipns/src/dnslink.ts

View check run for this annotation

Codecov / codecov/patch

packages/ipns/src/dnslink.ts#L102-L104

Added lines #L102 - L104 were not covered by tests

async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSOptions = {}): Promise<string> {
async function recursiveResolveDomain (domain: string, depth: number, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise<string> {
if (depth === 0) {
throw new Error('recursion limit exceeded')
}

Check warning on line 109 in packages/ipns/src/dnslink.ts

View check run for this annotation

Codecov / codecov/patch

packages/ipns/src/dnslink.ts#L108-L109

Added lines #L108 - L109 were not covered by tests
Expand Down Expand Up @@ -137,6 +137,6 @@ async function recursiveResolveDomain (domain: string, depth: number, dns: DNS,
}
}

export async function resolveDNSLink (domain: string, dns: DNS, log: Logger, options: ResolveDNSOptions = {}): Promise<string> {
export async function resolveDNSLink (domain: string, dns: DNS, log: Logger, options: ResolveDNSLinkOptions = {}): Promise<string> {
return recursiveResolveDomain(domain, options.maxRecursiveDepth ?? MAX_RECURSIVE_DEPTH, dns, log, options)
}
16 changes: 8 additions & 8 deletions packages/ipns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ import { localStore, type LocalStore } from './routing/local-store.js'
import type { IPNSRouting, IPNSRoutingEvents } from './routing/index.js'
import type { Routing } from '@helia/interface'
import type { AbortOptions, ComponentLogger, Logger, PeerId } from '@libp2p/interface'
import type { DNS, ResolveDnsProgressEvents, DNSResponse } from '@multiformats/dns'
import type { DNS, ResolveDnsProgressEvents } from '@multiformats/dns'
import type { Datastore } from 'interface-datastore'
import type { IPNSRecord } from 'ipns'
import type { ProgressEvent, ProgressOptions } from 'progress-events'
Expand Down Expand Up @@ -269,10 +269,10 @@ export type RepublishProgressEvents =
ProgressEvent<'ipns:republish:success', IPNSRecord> |
ProgressEvent<'ipns:republish:error', { record: IPNSRecord, err: Error }>

export type ResolveDnsLinkProgressEvents =
ProgressEvent<'dnslink:cache', string> |
ProgressEvent<'dnslink:query', string> |
ProgressEvent<'dnslink:answer', DNSResponse>
export type ResolveDNSLinkProgressEvents =
ResolveProgressEvents |
IPNSRoutingEvents |
ResolveDnsProgressEvents

export interface PublishOptions extends AbortOptions, ProgressOptions<PublishProgressEvents | IPNSRoutingEvents> {
/**
Expand All @@ -299,7 +299,7 @@ export interface ResolveOptions extends AbortOptions, ProgressOptions<ResolvePro
offline?: boolean
}

export interface ResolveDNSOptions extends AbortOptions, ProgressOptions<ResolveProgressEvents | IPNSRoutingEvents | ResolveDnsProgressEvents> {
export interface ResolveDNSLinkOptions extends AbortOptions, ProgressOptions<ResolveDNSLinkProgressEvents> {
/**
* Do not query the network for the IPNS record
*
Expand Down Expand Up @@ -352,7 +352,7 @@ export interface IPNS {
/**
* Resolve a CID from a dns-link style IPNS record
*/
resolveDNSLink(domain: string, options?: ResolveDNSOptions): Promise<ResolveResult>
resolveDNSLink(domain: string, options?: ResolveDNSLinkOptions): Promise<ResolveResult>

/**
* Periodically republish all IPNS records found in the datastore
Expand Down Expand Up @@ -423,7 +423,7 @@ class DefaultIPNS implements IPNS {
return this.#resolve(record.value, options)
}

async resolveDNSLink (domain: string, options: ResolveDNSOptions = {}): Promise<ResolveResult> {
async resolveDNSLink (domain: string, options: ResolveDNSLinkOptions = {}): Promise<ResolveResult> {
const dnslink = await resolveDNSLink(domain, this.dns, this.log, options)

return this.#resolve(dnslink, options)
Expand Down

0 comments on commit 4203a8a

Please sign in to comment.