From 73c6d158e045095a33449e762149c151b4f38e8b Mon Sep 17 00:00:00 2001 From: Gregor MacLennan Date: Thu, 21 Sep 2023 14:29:25 +0100 Subject: [PATCH] fix: rename versionObj.coreKey to coreDiscoveryKey (#145) --- proto/common/v1.proto | 2 +- schema/common/v1.json | 2 +- src/lib/utils.ts | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/proto/common/v1.proto b/proto/common/v1.proto index 5e085bef..1e3b62c4 100644 --- a/proto/common/v1.proto +++ b/proto/common/v1.proto @@ -8,7 +8,7 @@ message Common_1 { // 32-byte random generated number optional bytes docId = 1 [(required) = true]; message Link { - bytes coreKey = 1; + bytes coreDiscoveryKey = 1; int32 index = 2; } repeated Link links = 2; diff --git a/schema/common/v1.json b/schema/common/v1.json index fcef4373..de9c91a9 100644 --- a/schema/common/v1.json +++ b/schema/common/v1.json @@ -10,7 +10,7 @@ "type": "string" }, "versionId": { - "description": "core id (hex-encoded 32-byte buffer) and core index number, separated by '/'", + "description": "core discovery id (hex-encoded 32-byte buffer) and core index number, separated by '/'", "type": "string" }, "schemaName": { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 269b15a6..57b1dd1e 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -16,7 +16,7 @@ function capitalize(str: T): Capitalize { } export type VersionIdObject = { - coreKey: Buffer + coreDiscoveryKey: Buffer index: number } @@ -27,8 +27,8 @@ export type VersionIdObject = { * @param versionIdObject * @returns versionId string */ -export function getVersionId({ coreKey, index }: VersionIdObject) { - return coreKey.toString('hex') + '/' + index +export function getVersionId({ coreDiscoveryKey, index }: VersionIdObject) { + return coreDiscoveryKey.toString('hex') + '/' + index } /** @@ -41,9 +41,9 @@ export function getVersionId({ coreKey, index }: VersionIdObject) { export function parseVersionId(versionId: string): VersionIdObject { const items = versionId.split('/') if (!items[0] || !items[1]) throw new Error('Invalid versionId') - const coreKey = Buffer.from(items[0], 'hex') - if (coreKey.length !== 32) throw new Error('Invalid versionId') + const coreDiscoveryKey = Buffer.from(items[0], 'hex') + if (coreDiscoveryKey.length !== 32) throw new Error('Invalid versionId') const index = Number.parseInt(items[1]) if (isNaN(index)) throw new Error('Invalid versionId') - return { coreKey, index } + return { coreDiscoveryKey, index } }