Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: add record validators and selectors (#304)
Browse files Browse the repository at this point in the history
So we can store and validate public key records out of the box.
  • Loading branch information
achingbrain authored Mar 23, 2022
1 parent b08f907 commit 27c3948
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/kad-dht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import type { CID } from 'multiformats/cid'
import type { PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery'
import { Components, Initializable } from '@libp2p/interfaces/components'
import type { KadDHTInit } from './index.js'
import { validators as recordValidators } from '@libp2p/record/validators'
import { selectors as recordSelectors } from '@libp2p/record/selectors'

/**
* A DHT implementation modelled after Kademlia with S/Kademlia modifications.
Expand Down Expand Up @@ -79,8 +81,14 @@ export class KadDHT extends EventEmitter<PeerDiscoveryEvents> implements DHT, In

this.providers = new Providers()

this.validators = validators ?? {}
this.selectors = selectors ?? {}
this.validators = {
...recordValidators,
...validators
}
this.selectors = {
...recordSelectors,
...selectors
}
this.network = new Network({
protocol: this.protocol,
lan: this.lan
Expand Down

0 comments on commit 27c3948

Please sign in to comment.