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

Commit 2d26f9b

Browse files
authored
fix: remove trailing slash from datastore prefixes (#241)
Otherwise you get double slashes in datastore keys.
1 parent 506f7bf commit 2d26f9b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ exports.MAX_RECORD_AGE = 36 * hour
1515

1616
exports.PROTOCOL_DHT = '/kad/1.0.0'
1717

18-
exports.RECORD_KEY_PREFIX = '/dht/record/'
18+
exports.RECORD_KEY_PREFIX = '/dht/record'
1919

20-
exports.PROVIDER_KEY_PREFIX = '/dht/provider/'
20+
exports.PROVIDER_KEY_PREFIX = '/dht/provider'
2121

2222
exports.PROVIDERS_LRU_CACHE_SIZE = 256
2323

src/providers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class Providers {
223223
function makeProviderKey (cid) {
224224
cid = typeof cid === 'string' ? cid : uint8ArrayToString(cid.multihash.bytes, 'base32')
225225

226-
return PROVIDER_KEY_PREFIX + cid
226+
return `${PROVIDER_KEY_PREFIX}/${cid}`
227227
}
228228

229229
/**

test/generate-peers/generate-peers.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ async function fromGo (targetCpl, randPrefix, localKadId) {
2727
}
2828

2929
describe('generate peers', function () {
30+
this.timeout(540 * 1000)
3031
const go = which.sync('go', { nothrow: true })
3132

3233
if (!go) {
@@ -43,8 +44,7 @@ describe('generate peers', function () {
4344
})
4445
})
4546

46-
beforeEach(async function () {
47-
this.timeout(540 * 1000)
47+
beforeEach(async () => {
4848
const id = await PeerId.create({ bits: 512 })
4949

5050
const table = new RoutingTable({
@@ -73,7 +73,7 @@ describe('generate peers', function () {
7373
randPrefix: 49898
7474
}]
7575

76-
TEST_CASES.forEach(({ targetCpl, randPrefix }, index) => {
76+
TEST_CASES.forEach(({ targetCpl, randPrefix }) => {
7777
it(`should generate peers targetCpl ${targetCpl} randPrefix ${randPrefix}`, async () => {
7878
const peerId = await PeerId.create({ bits: 512 })
7979
const localKadId = await convertPeerId(peerId)

0 commit comments

Comments
 (0)