refactor: bug fixes and return early if the entry is the same
This commit is contained in:
parent
9ecea29244
commit
6388669ca8
|
@ -137,15 +137,18 @@ export async function createEntry(
|
|||
sk = createKeyPair(sk);
|
||||
}
|
||||
|
||||
let existing = true;
|
||||
let entry = await this.getEntry(sk.publicKey);
|
||||
|
||||
if (!entry) {
|
||||
existing = false;
|
||||
entry = {
|
||||
pk: sk,
|
||||
pk: sk.publicKey,
|
||||
data: cid.toRegistryEntry(),
|
||||
revision,
|
||||
} as unknown as SignedRegistryEntry;
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!equalBytes(sk.publicKey, entry.pk)) {
|
||||
throwValidationError(
|
||||
"entry.pk", // name of the variable
|
||||
|
@ -155,9 +158,13 @@ export async function createEntry(
|
|||
);
|
||||
}
|
||||
|
||||
entry.revision++;
|
||||
if (existing) {
|
||||
if (equalBytes(entry.data, cid.toRegistryEntry())) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
entry.revision++;
|
||||
}
|
||||
const signedEntry = signRegistryEntry({
|
||||
kp: sk,
|
||||
data: entry.data,
|
||||
|
|
Loading…
Reference in New Issue