Skip to content

Commit

Permalink
feat: filter multiaddrs for origins
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Sep 6, 2023
1 parent 654ddfa commit caffdbf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"dependencies": {
"@libp2p/logger": "^3.0.2",
"@multiformats/multiaddr": "^12.1.6",
"@multiformats/multiaddr-matcher": "^1.0.1",
"multiformats": "^12.0.1",
"p-retry": "^6.0.0"
},
Expand Down
5 changes: 4 additions & 1 deletion src/heliaRemotePinner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type RemotePinningServiceClient, type Pin, type PinStatus, type PinsRequestidPostRequest, Status } from '@ipfs-shipyard/pinning-service-client'
import { logger } from '@libp2p/logger'
import { multiaddr } from '@multiformats/multiaddr'
import { P2P } from '@multiformats/multiaddr-matcher'
import pRetry, { type Options as pRetryOptions } from 'p-retry'
import { FailedToConnectToDelegates } from './errors.js'
import type { Helia } from '@helia/interface'
Expand Down Expand Up @@ -45,7 +46,9 @@ export class HeliaRemotePinner {
}

private getOrigins (otherOrigins: Pin['origins']): Set<string> {
const origins = new Set(this.heliaInstance.libp2p.getMultiaddrs().map(multiaddr => multiaddr.toString()))
const multiaddrs = this.heliaInstance.libp2p.getMultiaddrs().filter(multiaddr => P2P.matches(multiaddr))
const origins = new Set(multiaddrs.map(multiaddr => multiaddr.toString()))

if (otherOrigins != null) {
for (const origin of otherOrigins) {
origins.add(origin)
Expand Down

0 comments on commit caffdbf

Please sign in to comment.