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

Commit 27c3948

Browse files
authored
fix: add record validators and selectors (#304)
So we can store and validate public key records out of the box.
1 parent b08f907 commit 27c3948

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/kad-dht.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import type { CID } from 'multiformats/cid'
2222
import type { PeerDiscoveryEvents } from '@libp2p/interfaces/peer-discovery'
2323
import { Components, Initializable } from '@libp2p/interfaces/components'
2424
import type { KadDHTInit } from './index.js'
25+
import { validators as recordValidators } from '@libp2p/record/validators'
26+
import { selectors as recordSelectors } from '@libp2p/record/selectors'
2527

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

8082
this.providers = new Providers()
8183

82-
this.validators = validators ?? {}
83-
this.selectors = selectors ?? {}
84+
this.validators = {
85+
...recordValidators,
86+
...validators
87+
}
88+
this.selectors = {
89+
...recordSelectors,
90+
...selectors
91+
}
8492
this.network = new Network({
8593
protocol: this.protocol,
8694
lan: this.lan

0 commit comments

Comments
 (0)